# HG changeset patch # User Adam Domurad # Date 1343140448 14400 # Node ID b1b5b91b9830d2c906bc01e8a90580e884e3d175 # Parent c9d0e375f07cea36ece69b43ba0d6c5ba8a4bb17 Refactor launch type of JNLPFile into its own type, LaunchDesc diff -r c9d0e375f07c -r b1b5b91b9830 ChangeLog --- a/ChangeLog Fri Jul 20 10:44:46 2012 -0400 +++ b/ChangeLog Tue Jul 24 10:34:08 2012 -0400 @@ -1,3 +1,19 @@ +2012-07-24 Adam Domurad + + Refactor JNLPFile#launchType into its own interface type (as opposed to + Object), LaunchDesc. + * netx/net/sourceforge/jnlp/AppletDesc.java: Add override annotation to + getMainClass(). + * netx/net/sourceforge/jnlp/ApplicationDesc.java: Same as above + * netx/net/sourceforge/jnlp/InstallerDesc.java: Same as above + * netx/net/sourceforge/jnlp/JNLPFile.java: Make launchType a + LaunchDesc object. Update getLaunchInfo() accordingly. + * netx/net/sourceforge/jnlp/LaunchDesc.java: New launch description. + * netx/net/sourceforge/jnlp/Parser.java + (getLauncher): Return type changed to LaunchDesc + * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Replace + occurences of instanceof with respect to launchType. + 2012-07-18 Danesh Dadachanji Fix RH838417, Fix RH838559: Disambiguate signed applet security prompt diff -r c9d0e375f07c -r b1b5b91b9830 netx/net/sourceforge/jnlp/AppletDesc.java --- a/netx/net/sourceforge/jnlp/AppletDesc.java Fri Jul 20 10:44:46 2012 -0400 +++ b/netx/net/sourceforge/jnlp/AppletDesc.java Tue Jul 24 10:34:08 2012 -0400 @@ -25,7 +25,7 @@ * @author Jon A. Maxwell (JAM) - initial author * @version $Revision: 1.8 $ */ -public class AppletDesc { +public class AppletDesc implements LaunchDesc { /** the applet name */ private String name; @@ -75,6 +75,7 @@ /** * Returns the main class name in the dot-separated form (eg: foo.bar.Baz) */ + @Override public String getMainClass() { return mainClass; } diff -r c9d0e375f07c -r b1b5b91b9830 netx/net/sourceforge/jnlp/ApplicationDesc.java --- a/netx/net/sourceforge/jnlp/ApplicationDesc.java Fri Jul 20 10:44:46 2012 -0400 +++ b/netx/net/sourceforge/jnlp/ApplicationDesc.java Tue Jul 24 10:34:08 2012 -0400 @@ -24,7 +24,7 @@ * @author Jon A. Maxwell (JAM) - initial author * @version $Revision: 1.7 $ */ -public class ApplicationDesc { +public class ApplicationDesc implements LaunchDesc { /** the main class name and package */ private String mainClass; @@ -46,6 +46,7 @@ /** * Returns the main class name */ + @Override public String getMainClass() { return mainClass; } diff -r c9d0e375f07c -r b1b5b91b9830 netx/net/sourceforge/jnlp/InstallerDesc.java --- a/netx/net/sourceforge/jnlp/InstallerDesc.java Fri Jul 20 10:44:46 2012 -0400 +++ b/netx/net/sourceforge/jnlp/InstallerDesc.java Tue Jul 24 10:34:08 2012 -0400 @@ -22,7 +22,7 @@ * @author Jon A. Maxwell (JAM) - initial author * @version $Revision: 1.6 $ */ -public class InstallerDesc { +public class InstallerDesc implements LaunchDesc { /** the main class name and package. */ private String mainClass; @@ -39,6 +39,7 @@ /** * Returns the main class name and package. */ + @Override public String getMainClass() { return mainClass; } diff -r c9d0e375f07c -r b1b5b91b9830 netx/net/sourceforge/jnlp/JNLPFile.java --- a/netx/net/sourceforge/jnlp/JNLPFile.java Fri Jul 20 10:44:46 2012 -0400 +++ b/netx/net/sourceforge/jnlp/JNLPFile.java Tue Jul 24 10:34:08 2012 -0400 @@ -91,7 +91,7 @@ protected ResourcesDesc sharedResources = new ResourcesDesc(this, null, null, null); /** the application description */ - protected Object launchType; + protected LaunchDesc launchType; /** the component description */ protected ComponentDesc component; @@ -446,7 +446,7 @@ * Returns an object of one of the following types: AppletDesc, * ApplicationDesc and InstallerDesc */ - public Object getLaunchInfo() { + public LaunchDesc getLaunchInfo() { return launchType; } diff -r c9d0e375f07c -r b1b5b91b9830 netx/net/sourceforge/jnlp/LaunchDesc.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netx/net/sourceforge/jnlp/LaunchDesc.java Tue Jul 24 10:34:08 2012 -0400 @@ -0,0 +1,42 @@ +/* LaunchDesc -- Represents a launch description + Copyright (C) 2012 Red Hat + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package net.sourceforge.jnlp; + +public interface LaunchDesc { + public String getMainClass(); +} diff -r c9d0e375f07c -r b1b5b91b9830 netx/net/sourceforge/jnlp/Parser.java --- a/netx/net/sourceforge/jnlp/Parser.java Fri Jul 20 10:44:46 2012 -0400 +++ b/netx/net/sourceforge/jnlp/Parser.java Tue Jul 24 10:34:08 2012 -0400 @@ -609,7 +609,7 @@ * @param parent the parent node * @throws ParseException if the JNLP file is invalid */ - public Object getLauncher(Node parent) throws ParseException { + public LaunchDesc getLauncher(Node parent) throws ParseException { // check for other than one application type if (1 < getChildNodes(parent, "applet-desc").length + getChildNodes(parent, "application-desc").length diff -r c9d0e375f07c -r b1b5b91b9830 netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Fri Jul 20 10:44:46 2012 -0400 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Jul 24 10:34:08 2012 -0400 @@ -67,6 +67,7 @@ import net.sourceforge.jnlp.JNLPFile; import net.sourceforge.jnlp.JNLPMatcher; import net.sourceforge.jnlp.JNLPMatcherException; +import net.sourceforge.jnlp.LaunchDesc; import net.sourceforge.jnlp.LaunchException; import net.sourceforge.jnlp.ParseException; import net.sourceforge.jnlp.PluginBridge; @@ -636,8 +637,7 @@ // If jar with main class was not found and there are no more // available jars, throw a LaunchException - if (file.getLaunchInfo() instanceof AppletDesc || - file.getLaunchInfo() instanceof ApplicationDesc) { + if (file.getLaunchInfo() != null) { if (!foundMainJar && (available == null || available.size() == 0)) throw new LaunchException(file, null, R("LSFatal"), @@ -729,17 +729,14 @@ */ private void checkForMain(List jars) throws LaunchException { + // Check launch info if (mainClass == null) { - Object obj = file.getLaunchInfo(); + LaunchDesc launchDesc = file.getLaunchInfo(); + if (launchDesc == null) { + return; + } - if (obj instanceof ApplicationDesc) { - ApplicationDesc ad = (ApplicationDesc) file.getLaunchInfo(); - mainClass = ad.getMainClass(); - } else if (obj instanceof AppletDesc) { - AppletDesc ad = (AppletDesc) file.getLaunchInfo(); - mainClass = ad.getMainClass(); - } else - return; + mainClass = launchDesc.getMainClass(); } // The main class may be specified in the manifest