Mercurial > hg > release > icedtea-web-1.6
changeset 1210:5837261a12aa
Fixed javadoc warnings and errors to pass doclint
line wrap: on
line diff
--- a/ChangeLog Wed Apr 15 10:43:53 2015 +0200 +++ b/ChangeLog Thu Apr 16 19:34:18 2015 +0200 @@ -1,3 +1,8 @@ +2015-04-15 Jiri Vanek <jvanek@redhat.com> + + Fixed javadoc warnings and errors to pass doclint + * /netx: nearly all files in main package get rid of doclint errors + 2015-04-15 Jiri Vanek <jvanek@redhat.com> jnlp-signing mechanism now uses general parser (and so also tagsoup if enabled)
--- a/Makefile.am Wed Apr 15 10:43:53 2015 +0200 +++ b/Makefile.am Thu Apr 16 19:34:18 2015 +0200 @@ -648,11 +648,12 @@ stamps/netx-docs.stamp: if ENABLE_DOCS - $(SYSTEM_JDK_DIR)/bin/javadoc $(JAVADOC_MEM_OPTS) $(JAVADOC_OPTS) \ + $(SYSTEM_JDK_DIR)/bin/javadoc $(JAVADOC_MEM_OPTS) $( _OPTS) \ -d ${abs_top_builddir}/docs/netx -sourcepath $(NETX_SRCDIR) \ -doctitle 'IcedTea-Web: NetX API Specification' \ -windowtitle 'IcedTea-Web: NetX ' \ -header '<strong>IcedTea-Web<br/>NetX</strong>' \ + $(call composeclasspath, $(TAGSOUP_JAR) $(RHINO_JAR)) \ $(NETX_PKGS) endif mkdir -p stamps @@ -670,6 +671,7 @@ -doctitle 'IcedTea-Web: Plugin API Specification' \ -windowtitle 'IcedTea-Web: Plugin ' \ -header '<strong>IcedTea-Web<br/>Plugin</strong>' \ + $(call composeclasspath, $(TAGSOUP_JAR) $(RHINO_JAR)) \ $(PLUGIN_PKGS) endif endif
--- a/launcher/launchers.in Wed Apr 15 10:43:53 2015 +0200 +++ b/launcher/launchers.in Thu Apr 16 19:34:18 2015 +0200 @@ -7,7 +7,7 @@ BINARY_LOCATION=@BIN_LOCATION@ SPLASH_LOCATION=@JAVAWS_SPLASH_LOCATION@ PROGRAM_NAME=@PROGRAM_NAME@ -CP=@JRE@/lib/rt.jar +CP=@JRE@/lib/rt.jar:@JRE@/lib/ext/jfxrt.jar CONFIG_HOME=$XDG_CONFIG_HOME if [ "x$CONFIG_HOME" = "x" ] ; then @@ -27,7 +27,7 @@ if [ "x$CUSTOM_JRE" != "x" ] ; then if [ -e "$CUSTOM_JRE" -a -e "$CUSTOM_JRE/bin/java" -a -e "$CUSTOM_JRE/lib/rt.jar" ] ; then JAVA=$CUSTOM_JRE/bin/java - CP=$CUSTOM_JRE/lib/rt.jar + CP=$CUSTOM_JRE/lib/rt.jar:$CUSTOM_JRE/lib/ext/jfxrt.jar else echo "Your custom JRE $CUSTOM_JRE read from deployment.properties under key $PROPERTY_NAME as $CUSTOM_JRE is not valid. Using default ($JAVA, $CP) in attempt to start. Please fix this." fi
--- a/netx/net/sourceforge/jnlp/AbstractLaunchHandler.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/AbstractLaunchHandler.java Thu Apr 16 19:34:18 2015 +0200 @@ -50,6 +50,7 @@ /** * Print a message + * @param ex exception to be printed out */ protected void printMessage(LaunchException ex) { StringBuilder result = new StringBuilder();
--- a/netx/net/sourceforge/jnlp/AppletDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/AppletDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -28,22 +28,22 @@ public class AppletDesc implements LaunchDesc { /** the applet name */ - private String name; + private final String name; /** the main class name and package */ - private String mainClass; + private final String mainClass; /** the document base */ - private URL documentBase; + private final URL documentBase; /** the width */ - private int width; + private final int width; /** the height */ - private int height; + private final int height; /** the parameters */ - private Map<String, String> parameters; + private final Map<String, String> parameters; /** * Create an Applet descriptor. @@ -62,18 +62,18 @@ this.documentBase = documentBase; this.width = width; this.height = height; - this.parameters = new HashMap<String, String>(parameters); + this.parameters = new HashMap<>(parameters); } /** - * Returns the applet name + * @return the applet name */ public String getName() { return name; } /** - * Returns the main class name in the dot-separated form (eg: foo.bar.Baz) + * @return the main class name in the dot-separated form (eg: foo.bar.Baz) */ @Override public String getMainClass() { @@ -81,31 +81,31 @@ } /** - * Returns the document base + * @return the document base */ public URL getDocumentBase() { return documentBase; } /** - * Returns the width + * @return the width */ public int getWidth() { return width; } /** - * Returns the height + * @return the height */ public int getHeight() { return height; } /** - * Returns the applet parameters + * @return the applet parameters */ public Map<String, String> getParameters() { - return new HashMap<String, String>(parameters); + return new HashMap<>(parameters); } /** @@ -113,6 +113,8 @@ * exists then it is overwritten with the new value. Adding a * parameter will have no effect on already-running applets * launched from this JNLP file. + * @param name key of value + * @param value value to be added */ public void addParameter(String name, String value) { parameters.put(name, value);
--- a/netx/net/sourceforge/jnlp/ApplicationDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/ApplicationDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -27,7 +27,7 @@ public class ApplicationDesc implements LaunchDesc { /** the main class name and package */ - private String mainClass; + private final String mainClass; /** the arguments */ private String arguments[]; @@ -44,7 +44,7 @@ } /** - * Returns the main class name + * @return the main class name */ @Override public String getMainClass() { @@ -52,7 +52,7 @@ } /** - * Returns the arguments + * @return the arguments */ public String[] getArguments() { return arguments.clone(); @@ -60,9 +60,10 @@ /** * Add an argument to the end of the arguments. + * @param arg argument of command */ public void addArgument(String arg) { - List<String> l = new ArrayList<String>(Arrays.asList(arguments)); + List<String> l = new ArrayList<>(Arrays.asList(arguments)); l.add(arg); arguments = l.toArray(arguments);
--- a/netx/net/sourceforge/jnlp/AssociationDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/AssociationDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -19,10 +19,10 @@ public final class AssociationDesc { /** the extensions this application wants to register with */ - private String[] extensions; + private final String[] extensions; /** the mime type for the association */ - private String mimeType; + private final String mimeType; public AssociationDesc(String mimeType, String[] extensions) throws ParseException { checkMimeType(mimeType); @@ -31,14 +31,14 @@ } /** - * Return the extensions for this association + * @return the extensions for this association */ public String[] getExtensions() { return extensions; } /** - * Return the mimetype for this association + * @return the mimetype for this association */ public String getMimeType() { return mimeType;
--- a/netx/net/sourceforge/jnlp/ExtensionDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/ExtensionDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -22,7 +22,6 @@ import java.net.*; import java.util.*; -import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.logging.OutputController; /** @@ -34,22 +33,22 @@ public class ExtensionDesc { /** the extension name */ - private String name; + private final String name; /** the required extension version */ - private Version version; + private final Version version; /** the location of the extension JNLP file */ - private URL location; + private final URL location; /** the JNLPFile the extension refers to */ private JNLPFile file; /** map from ext-part to local part */ - private Map<String, String> extToPart = new HashMap<String, String>(); + private final Map<String, String> extToPart = new HashMap<>(); /** eager ext parts */ - private List<String> eagerExtParts = new ArrayList<String>(); + private final List<String> eagerExtParts = new ArrayList<>(); /** * Create an extention descriptor. @@ -82,7 +81,8 @@ } /** - * Returns the parts in the extension JNLP file mapped to the + * @param thisPart unimplemented + * @return the parts in the extension JNLP file mapped to the * part of the main file. */ public String[] getExtensionParts(String thisPart) { @@ -91,21 +91,21 @@ } /** - * Returns the name of the extension. + * @return the name of the extension. */ public String getName() { return name; } /** - * Returns the required version of the extension JNLP file. + * @return the required version of the extension JNLP file. */ public Version getVersion() { return version; } /** - * Returns the location of the extension JNLP file. + * @return the location of the extension JNLP file. */ public URL getLocation() { return location; @@ -133,7 +133,7 @@ } /** - * Returns a JNLPFile for the extension, or null if the JNLP + * @return a JNLPFile for the extension, or null if the JNLP * file has not been resolved. */ public JNLPFile getJNLPFile() {
--- a/netx/net/sourceforge/jnlp/IconDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/IconDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -45,22 +45,22 @@ public static final Object SHORTCUT = "shortcut"; /** the location of the icon */ - private URL location; + private final URL location; /** the type of icon*/ - private Object kind; + private final Object kind; /** the width, or -1 if unknown*/ - private int width; + private final int width; /** the height, or -1 if unknown*/ - private int height; + private final int height; /** the depth, or -1 if unknown*/ - private int depth; + private final int depth; /** the size, or -1 if unknown*/ - private int size; + private final int size; /** * Creates an icon descriptor with the specified information. @@ -82,21 +82,21 @@ } /** - * Returns the location of the icon. + * @return the location of the icon. */ public URL getLocation() { return location; } /** - * Returns the icon type. + * @return the icon type. */ public Object getKind() { return kind; } /** - * Returns the icon width or -1 if not specified in the + * @return the icon width or -1 if not specified in the * JNLPFile. */ public int getWidth() { @@ -104,7 +104,7 @@ } /** - * Returns the icon height or -1 if not specified in the + * @return the icon height or -1 if not specified in the * JNLPFile. */ public int getHeight() { @@ -112,14 +112,14 @@ } /** - * Returns the icon size or -1 if not specified in the JNLPFile. + * @return the icon size or -1 if not specified in the JNLPFile. */ public int getSize() { return size; } /** - * Returns the icon depth or -1 if not specified in the + * @return the icon depth or -1 if not specified in the * JNLPFile. */ public int getDepth() {
--- a/netx/net/sourceforge/jnlp/InformationDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/InformationDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -57,6 +57,7 @@ * Create an information element object. * * @param locales the locales the information is for + * @param strict whether parser was strict */ public InformationDesc(Locale locales[], boolean strict) { this.locales = locales; @@ -68,28 +69,28 @@ } /** - * Returns the application's title. + * @return the application's title. */ public String getTitle() { return (String) getItem("title"); } /** - * Returns the application's vendor. + * @return the application's vendor. */ public String getVendor() { return (String) getItem("vendor"); } /** - * Returns the application's homepage. + * @return the application's homepage. */ public URL getHomepage() { return (URL) getItem("homepage"); } /** - * Returns the default description for the application. + * @return the default description for the application. */ public String getDescription() { String result = getDescription(DEFAULT); @@ -106,7 +107,7 @@ } /** - * Returns the application's description of the specified type. + * @return the application's description of the specified type. * * @param kind one of Information.SHORT, Information.ONE_LINE, * Information.TOOLTIP, Information.DEFAULT @@ -120,7 +121,7 @@ } /** - * Returns the application's description of the specified type. + * @return the application's description of the specified type. * * @param kind one of Information.SHORT, Information.ONE_LINE, * Information.TOOLTIP, Information.DEFAULT @@ -160,15 +161,14 @@ return null; IconDesc best = null; - for (int i = 0; i < icons.length; i++) { - if (icons[i].getWidth() >= width && - icons[i].getHeight() >= height) { - if (best == null) - best = icons[i]; - - if (icons[i].getWidth() <= best.getWidth() && // Use <= so last specified of - icons[i].getHeight() <= best.getHeight()) // equivalent icons is chosen. - best = icons[i]; + for (IconDesc icon : icons) { + if (icon.getWidth() >= width && icon.getHeight() >= height) { + if (best == null) { + best = icon; + } + if (icon.getWidth() <= best.getWidth() && icon.getHeight() <= best.getHeight()) { + best = icon; + } } } @@ -181,14 +181,14 @@ } /** - * Returns the locales for the information. + * @return the locales for the information. */ public Locale[] getLocales() { return locales; } /** - * Returns whether offline execution allowed. + * @return whether offline execution allowed. */ public boolean isOfflineAllowed() { if (strict) { @@ -200,7 +200,7 @@ } /** - * Returns whether the resources specified in the JNLP file may + * @return whether the resources specified in the JNLP file may * be shared by more than one instance in the same JVM * (JNLP extension). This is an extension to the JNLP spec and * will always return false for standard JNLP files. @@ -210,7 +210,7 @@ } /** - * Returns the associations specified in the JNLP file + * @return the associations specified in the JNLP file */ public AssociationDesc[] getAssociations() { List<Object> associations = getItems("association"); @@ -219,14 +219,14 @@ } /** - * Returns the shortcut specified by this JNLP file + * @return the shortcut specified by this JNLP file */ public ShortcutDesc getShortcut() { return (ShortcutDesc) getItem("shortcut"); } /** - * Returns the related-contents specified by this JNLP file + * @return the related-contents specified by this JNLP file */ public RelatedContentDesc[] getRelatedContents() { List<Object> relatedContents = getItems("related-content"); @@ -235,24 +235,26 @@ } /** - * Returns the last item matching the specified key. + * @param key key to find item + * @return the last item matching the specified key. */ protected Object getItem(Object key) { List<Object> items = getItems(key); - if (items.size() == 0) + if (items.isEmpty()) return null; else return items.get(items.size() - 1); } /** - * Returns all items matching the specified key. + * @param key key to find item + * @return all items matching the specified key. */ protected List<Object> getItems(Object key) { if (info == null) return Collections.emptyList(); - List<Object> result = new ArrayList<Object>(); + List<Object> result = new ArrayList<>(); for (int i = 0; i < info.size(); i += 2) if (info.get(i).equals(key)) result.add(info.get(i + 1)); @@ -263,10 +265,12 @@ /** * Add an information item (description, icon, etc) under a * specified key name. + * @param key key to place value to + * @param value value to be placed to key */ protected void addItem(String key, Object value) { if (info == null) - info = new ArrayList<Object>(); + info = new ArrayList<>(); info.add(key); info.add(value);
--- a/netx/net/sourceforge/jnlp/JARDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/JARDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -70,21 +70,21 @@ } /** - * Returns the URL of the JAR file. + * @return the URL of the JAR file. */ public URL getLocation() { return location; } /** - * Returns the required version of the JAR file. + * @return the required version of the JAR file. */ public Version getVersion() { return version; } /** - * Returns the part name, or null if not specified in the JNLP + * @return the part name, or null if not specified in the JNLP * file. */ public String getPart() { @@ -92,7 +92,7 @@ } /** - * Returns true if the JAR file contains native code + * @return true if the JAR file contains native code * libraries. */ public boolean isNative() { @@ -103,7 +103,7 @@ // where !lazy would no longer imply eager. /** - * Returns true if the JAR file should be downloaded before + * @return true if the JAR file should be downloaded before * starting the application. */ public boolean isEager() { @@ -111,14 +111,14 @@ } /** - * Returns true if the JAR file should be downloaded on demand. + * @return true if the JAR file should be downloaded on demand. */ public boolean isLazy() { return lazy; } /** - * Returns true if the JNLP file defined this JAR as containing + * @return true if the JNLP file defined this JAR as containing * the main class. If no JARs were defined as the main JAR then * the first JAR should be used to locate the main class. *
--- a/netx/net/sourceforge/jnlp/JNLPFile.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/JNLPFile.java Thu Apr 16 19:34:18 2015 +0200 @@ -134,7 +134,7 @@ /** * List of acceptable properties (not-special) */ - private String[] generalProperties = SecurityDesc.getJnlpRIAPermissions(); + final private String[] generalProperties = SecurityDesc.getJnlpRIAPermissions(); /** important manifests' attributes */ private final ManifestsAttributes manifestsAttributes = new ManifestsAttributes(); @@ -269,6 +269,8 @@ /** * Create a JNLPFile from an input stream. * + * @param input input stream from which create jnlp file + * @param settings settings of parser * @throws ParseException if the JNLP file was invalid */ public JNLPFile(InputStream input, ParserSettings settings) throws ParseException { @@ -295,6 +297,11 @@ * download to the cache. * Unless file is find in cache, this method blocks until it is downloaded. * This is the best way in itw how to download and cache file + * @param location of resource to open + * @param version of resource + * @param policy update policy of resource + * @return opened streamfrom given url + * @throws java.io.IOException if something goes wrong */ public static InputStream openURL(URL location, Version version, UpdatePolicy policy) throws IOException { if (location == null || policy == null) @@ -311,7 +318,7 @@ } /** - * Returns the JNLP file's best localized title. This method returns the same + * @return the JNLP file's best localized title. This method returns the same * value as InformationDesc.getTitle(). * * Since jdk7 u45, also manifest title, and mainclass are taken to consideration; @@ -337,7 +344,7 @@ } /** - * Returns the JNLP file's best localized title. This method returns the same + * @return the JNLP file's best localized title. This method returns the same * value as InformationDesc.getTitle(). */ public String getTitleFromJnlp() { @@ -355,7 +362,7 @@ /** - * Returns the JNLP file's best localized vendor. This method returns the same + * @return the JNLP file's best localized vendor. This method returns the same * value as InformationDesc.getVendor(). */ public String getVendor() { @@ -363,7 +370,7 @@ } /** - * Returns the JNLP file's network location as specified in the + * @return the JNLP file's network location as specified in the * JNLP file. */ public URL getSourceLocation() { @@ -371,7 +378,7 @@ } /** - * Returns the location of the file parsed to create the JNLP + * @return the location of the file parsed to create the JNLP * file, or null if it was not created from a URL. */ public URL getFileLocation() { @@ -379,42 +386,42 @@ } /** - * Returns the location of the parent file if it exists, null otherwise + * @return the location of the parent file if it exists, null otherwise */ public String getUniqueKey() { return uniqueKey; } /** - * Returns the ParserSettings that was used to parse this file + * @return the ParserSettings that was used to parse this file */ public ParserSettings getParserSettings() { return parserSettings; } /** - * Returns the JNLP file's version. + * @return the JNLP file's version. */ public Version getFileVersion() { return fileVersion; } /** - * Returns the specification version required by the file. + * @return the specification version required by the file. */ public Version getSpecVersion() { return specVersion; } /** - * Returns the codebase URL for the JNLP file. + * @return the codebase URL for the JNLP file. */ public URL getCodeBase() { return codeBase; } /** - * Returns the information section of the JNLP file as viewed + * @return the information section of the JNLP file as viewed * through the default locale. */ public InformationDesc getInformation() { @@ -422,7 +429,8 @@ } /** - * Returns the information section of the JNLP file as viewed + * @param locale preferred locale of informations + * @return the information section of the JNLP file as viewed * through the specified locale. */ public InformationDesc getInformation(final Locale locale) { @@ -438,7 +446,7 @@ return new InformationDesc(new Locale[] { locale }, strict) { @Override protected List<Object> getItems(Object key) { - List<Object> result = new ArrayList<Object>(); + List<Object> result = new ArrayList<>(); for (Match precision : Match.values()) { for (InformationDesc infoDesc : JNLPFile.this.info) { @@ -487,14 +495,14 @@ } /** - * Returns the update section of the JNLP file. + * @return the update section of the JNLP file. */ public UpdateDesc getUpdate() { return update; } /** - * Returns the security section of the JNLP file. + * @return the security section of the JNLP file. */ public SecurityDesc getSecurity() { return security; @@ -505,7 +513,7 @@ } /** - * Returns the resources section of the JNLP file as viewed + * @return the resources section of the JNLP file as viewed * through the default locale and the os.name and os.arch * properties. */ @@ -514,7 +522,10 @@ } /** - * Returns the resources section of the JNLP file for the + * @param locale preferred locale of resource + * @param os preferred os of resource + * @param arch preferred arch of resource + * @return the resources section of the JNLP file for the * specified locale, os, and arch. */ public ResourcesDesc getResources(final Locale locale, final String os, final String arch) { @@ -522,7 +533,7 @@ @Override public <T> List<T> getResources(Class<T> launchType) { - List<T> result = new ArrayList<T>(); + List<T> result = new ArrayList<>(); for (ResourcesDesc rescDesc : resources) { boolean hasUsableLocale = false; @@ -549,7 +560,7 @@ } /** - * Returns the resources section of the JNLP file as viewed + * @return the resources section of the JNLP file as viewed * through the default locale and the os.name and os.arch * properties. * XXX: Before overriding this method or changing its implementation, @@ -560,11 +571,14 @@ } /** - * Returns the resources section of the JNLP file for the + * @param locale preferred locale of resource + * @param os preferred os of resource + * @param arch preferred arch of resource + * @return the resources section of the JNLP file for the * specified locale, os, and arch. */ public ResourcesDesc[] getResourcesDescs(final Locale locale, final String os, final String arch) { - List<ResourcesDesc> matchingResources = new ArrayList<ResourcesDesc>(); + List<ResourcesDesc> matchingResources = new ArrayList<>(); for (ResourcesDesc rescDesc: resources) { boolean hasUsableLocale = false; for (Match match : Match.values()) { @@ -580,7 +594,7 @@ } /** - * Returns an object of one of the following types: AppletDesc, + * @return an object of one of the following types: AppletDesc, * ApplicationDesc and InstallerDesc */ public LaunchDesc getLaunchInfo() { @@ -588,7 +602,7 @@ } /** - * Returns the launch information for an applet. + * @return the launch information for an applet. * * @throws UnsupportedOperationException if there is no applet information */ @@ -600,7 +614,7 @@ } /** - * Returns the launch information for an application. + * @return the launch information for an application. * * @throws UnsupportedOperationException if there is no application information */ @@ -612,7 +626,7 @@ } /** - * Returns the launch information for a component. + * @return the launch information for a component. * * @throws UnsupportedOperationException if there is no component information */ @@ -624,7 +638,7 @@ } /** - * Returns the launch information for an installer. + * @return the launch information for an installer. * * @throws UnsupportedOperationException if there is no installer information */ @@ -636,28 +650,28 @@ } /** - * Returns whether the lauch descriptor describes an Applet. + * @return whether the lauch descriptor describes an Applet. */ public boolean isApplet() { return launchType instanceof AppletDesc; } /** - * Returns whether the lauch descriptor describes an Application. + * @return whether the lauch descriptor describes an Application. */ public boolean isApplication() { return launchType instanceof ApplicationDesc; } /** - * Returns whether the lauch descriptor describes a Component. + * @return whether the lauch descriptor describes a Component. */ public boolean isComponent() { return component != null; } /** - * Returns whether the lauch descriptor describes an Installer. + * @return whether the lauch descriptor describes an Installer. */ public boolean isInstaller() { return launchType instanceof InstallerDesc; @@ -668,6 +682,9 @@ * getInformation, getResources, etc. If unset, the defaults * are the properties os.name, os.arch, and the locale returned * by Locale.getDefault(). + * @param os preferred os of resource + * @param arch preferred arch of resource + * @param locale preferred locale of resource */ public void setDefaults(String os, String arch, Locale locale) { defaultOS = os; @@ -729,7 +746,7 @@ } /** - * Returns whether the string is a prefix for any of the strings + * @return whether the string is a prefix for any of the strings * in the specified array. * * @param prefixStr the prefix string @@ -741,9 +758,11 @@ if (available == null || available.length == 0) return true; - for (int i = 0; i < available.length; i++) - if (available[i] != null && available[i].startsWith(prefixStr)) + for (String available1 : available) { + if (available1 != null && available1.startsWith(prefixStr)) { return true; + } + } return false; } @@ -816,11 +835,7 @@ */ public boolean needsNewVM() { - if (getNewVMArgs().size() == 0) { - return false; - } else { - return true; - } + return !getNewVMArgs().isEmpty(); } /** @@ -829,21 +844,19 @@ */ public List<String> getNewVMArgs() { - List<String> newVMArgs = new LinkedList<String>(); + List<String> newVMArgs = new LinkedList<>(); JREDesc[] jres = getResources().getJREs(); - for (int jreIndex = 0; jreIndex < jres.length; jreIndex++) { - String initialHeapSize = jres[jreIndex].getInitialHeapSize(); + for (JREDesc jre : jres) { + String initialHeapSize = jre.getInitialHeapSize(); if (initialHeapSize != null) { newVMArgs.add("-Xms" + initialHeapSize); } - - String maxHeapSize = jres[jreIndex].getMaximumHeapSize(); + String maxHeapSize = jre.getMaximumHeapSize(); if (maxHeapSize != null) { newVMArgs.add("-Xmx" + maxHeapSize); } - - String vmArgsFromJre = jres[jreIndex].getVMArgs(); + String vmArgsFromJre = jre.getVMArgs(); if (vmArgsFromJre != null) { String[] args = vmArgsFromJre.split(" "); newVMArgs.addAll(Arrays.asList(args)); @@ -918,6 +931,7 @@ /** * main class can be defined outside of manifest. * This method is mostly for completeness + * @return main-class as it is specified in application */ public String getMainClass(){ if (loader == null) { @@ -930,6 +944,7 @@ /** * * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/security/manifest.html#entry_pt + * @return values of Entry-Points attribute */ public String[] getEntryPoints() { return splitEntryPoints(getEntryPointString()); @@ -941,6 +956,7 @@ /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#app_name + * @return value of Application-Name manifest attribute */ public String getApplicationName(){ return getAttribute(APP_NAME); @@ -948,6 +964,7 @@ /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#caller_allowable + * @return values of Caller-Allowable-Codebase manifest attribute */ public ClasspathMatcher.ClasspathMatchers getCallerAllowableCodebase() { return getCodeBaseMatchersAttribute(CALLER_ALLOWABLE, false); @@ -955,6 +972,7 @@ /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#app_library + * @return values of Application-Library-Allowable-Codebase manifest attribute */ public ClasspathMatcher.ClasspathMatchers getApplicationLibraryAllowableCodebase() { return getCodeBaseMatchersAttribute(APP_LIBRARY_ALLOWABLE, true); @@ -962,6 +980,7 @@ /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#codebase + * @return values of Codebase manifest attribute */ public ClasspathMatcher.ClasspathMatchers getCodebase() { return getCodeBaseMatchersAttribute(CODEBASE, false); @@ -969,6 +988,7 @@ /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#trusted_only + * @return value of Trusted-Only manifest attribute */ public ManifestBoolean isTrustedOnly() { return processBooleanAttribute(TRUSTED_ONLY); @@ -977,6 +997,7 @@ /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#trusted_library + * @return value of Trusted-Library manifest attribute */ public ManifestBoolean isTrustedLibrary() { return processBooleanAttribute(TRUSTED_LIBRARY); @@ -985,6 +1006,7 @@ /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#permissions + * @return value of Permissions manifest attribute */ public ManifestBoolean isSandboxForced() { String s = getAttribute(PERMISSIONS); @@ -1002,6 +1024,7 @@ } /** * http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/manifest.html#permissions + * @return plain string values of Permissions manifest attribute */ public String permissionsToString() { String s = getAttribute(PERMISSIONS); @@ -1019,12 +1042,14 @@ /** * get custom attribute. */ - public String getAttribute(String name) { + String getAttribute(String name) { return getAttribute(new Attributes.Name(name)); } /** * get standard attribute + * @param name name of the manifest attribute to find in application + * @return plain attribute value */ public String getAttribute(Attributes.Name name) { if (loader == null) { @@ -1052,12 +1077,13 @@ return ManifestBoolean.UNDEFINED; } else { s = s.toLowerCase().trim(); - if (s.equals("true")) { - return ManifestBoolean.TRUE; - } else if (s.equals("false")) { - return ManifestBoolean.FALSE; - } else { - throw new IllegalArgumentException("Unknown value of " + id + " attribute " + s + ". Expected true or false"); + switch (s) { + case "true": + return ManifestBoolean.TRUE; + case "false": + return ManifestBoolean.FALSE; + default: + throw new IllegalArgumentException("Unknown value of " + id + " attribute " + s + ". Expected true or false"); } } }
--- a/netx/net/sourceforge/jnlp/JNLPSplashScreen.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/JNLPSplashScreen.java Thu Apr 16 19:34:18 2015 +0200 @@ -43,13 +43,11 @@ import java.awt.Graphics2D; import java.awt.Image; import java.awt.Insets; -import java.awt.Rectangle; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.JDialog; import net.sourceforge.jnlp.cache.ResourceTracker; -import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.splashscreen.SplashPanel; import net.sourceforge.jnlp.splashscreen.SplashUtils; import net.sourceforge.jnlp.splashscreen.parts.InformationElement;
--- a/netx/net/sourceforge/jnlp/JREDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/JREDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -16,12 +16,12 @@ package net.sourceforge.jnlp; +import java.net.URL; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static net.sourceforge.jnlp.runtime.Translator.R; -import java.net.*; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * The J2SE/Java element. @@ -57,9 +57,11 @@ * @param version the platform version or the product version * if location is not null * @param location the location of a JRE product or null - * @param initialHeapSize inital heap size + * @param vmArgs arguments to VM + * @param initialHeapSize initial heap size * @param maximumHeapSize maximum head size * @param resources list of ResourceDesc objects + * @throws net.sourceforge.jnlp.ParseException is something goes wrong */ public JREDesc(Version.JreVersion version, URL location, String vmArgs, String initialHeapSize, @@ -73,7 +75,7 @@ } /** - * Returns the JRE version. Use isPlatformVersion to + * @return the JRE version. Use isPlatformVersion to * determine if this version corresponds to a platform or * product version. */ @@ -82,7 +84,7 @@ } /** - * Returns true if the JRE version is a Java platform version + * @return true if the JRE version is a Java platform version * (java.specification.version property) or false if it is a * product version (java.version property). */ @@ -91,35 +93,35 @@ } /** - * Returns the JRE version string. + * @return the JRE version string. */ public URL getLocation() { return location; } /** - * Returns the maximum heap size in bytes. + * @return the maximum heap size in bytes. */ public String getMaximumHeapSize() { return maximumHeapSize; } /** - * Returns the initial heap size in bytes. + * @return the initial heap size in bytes. */ public String getInitialHeapSize() { return initialHeapSize; } /** - * Returns the resources defined for this JRE. + * @return the resources defined for this JRE. */ public List<ResourcesDesc> getResourcesDesc() { return resources; } /** - * Returns the additional arguments to pass to the Java VM + * @return the additional arguments to pass to the Java VM * Can be null */ public String getVMArgs() { @@ -128,7 +130,7 @@ /** * Check for valid heap size string - * @return trimed heapSize if correct + * @return trimmed heapSize if correct * @throws ParseException if heapSize is invalid */ static String checkHeapSize(String heapSize) throws ParseException {
--- a/netx/net/sourceforge/jnlp/LaunchException.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/LaunchException.java Thu Apr 16 19:34:18 2015 +0200 @@ -56,22 +56,28 @@ private static final long serialVersionUID = 7283827853612357423L; /** the file being launched */ - private JNLPFile file; + private final JNLPFile file; /** the category of the exception */ - private String category; + final private String category; /** summary */ - private String summary; + final private String summary; /** description of the action that was taking place */ - private String description; + final private String description; /** severity of the warning/error */ - private String severity; + final private String severity; /** * Creates a LaunchException without detail message. + * @param file jnlp-file which caused exception + * @param cause cause of exception + * @param severity severity of exception + * @param category category of exception + * @param summary short summary of exception + * @param description full description of exception */ public LaunchException(JNLPFile file, Exception cause, String severity, String category, String summary, String description) { super(severity + ": " + category + ": " + summary + " " @@ -87,17 +93,30 @@ /** * Creates a LaunchException with a cause. + * @param cause cause of exception */ public LaunchException(Throwable cause) { super(cause); + this.file = null; + this.category = null; + this.summary = null; + this.description = null; + this.severity = null; saveLaunchException(this); } /** * Creates a LaunchException with a cause and detail message + * @param message text of exception + * @param cause cause of exception */ public LaunchException(String message, Throwable cause) { super(message, cause); + this.file = null; + this.category = null; + this.summary = null; + this.description = null; + this.severity = null; saveLaunchException(this); } @@ -109,18 +128,23 @@ */ public LaunchException(String message) { super(message); + this.file = null; + this.category = null; + this.summary = null; + this.description = null; + this.severity = null; saveLaunchException(this); } /** - * Returns the JNLPFile being launched. + * @return the JNLPFile being launched. */ public JNLPFile getFile() { return file; } /** - * Returns the category string, a short description of the + * @return the category string, a short description of the * exception suitable for displaying in a window title. */ public String getCategory() { @@ -128,14 +152,14 @@ } /** - * Returns a one-sentence summary of the problem. + * @return a one-sentence summary of the problem. */ public String getSummary() { return summary; } /** - * Return a description of the exception and the action being + * @return a description of the exception and the action being * performed when the exception occurred. */ public String getDescription() { @@ -143,7 +167,7 @@ } /** - * Returns a short description of the severity of the problem. + * @return a short description of the severity of the problem. */ public String getSeverity() { return severity;
--- a/netx/net/sourceforge/jnlp/LaunchHandler.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/LaunchHandler.java Thu Apr 16 19:34:18 2015 +0200 @@ -31,6 +31,7 @@ * Called when the application could not be launched due to a * fatal error, such as the inability to find the main class or * non-parseable XML. + * @param exception to be re-thrown as launch error */ public void launchError(LaunchException exception); @@ -40,6 +41,7 @@ * is not strictly correct yet does not necessarily prohibit the * system from attempting to launch the application. * + * @param warning exception to be consummed as warning * @return true if the launch should continue, false to abort */ public boolean launchWarning(LaunchException warning); @@ -48,6 +50,7 @@ * Called when a security validation error occurs while * launching the application. * + * @param error to be rethrown as launch error * @return true to allow the application to continue, false to stop it. */ public boolean validationError(LaunchException error);
--- a/netx/net/sourceforge/jnlp/Launcher.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/Launcher.java Thu Apr 16 19:34:18 2015 +0200 @@ -139,6 +139,7 @@ /** * Sets the update policy used by launched applications. + * @param policy to be used for resources */ public void setUpdatePolicy(UpdatePolicy policy) { if (policy == null) { @@ -149,7 +150,7 @@ } /** - * Returns the update policy used when launching applications. + * @return the update policy used when launching applications. */ public UpdatePolicy getUpdatePolicy() { return updatePolicy; @@ -160,13 +161,14 @@ * (a separate event queue, look and feel, etc). If the * sun.awt.SunToolkit class is not present then this method * has no effect. The default value is true. + * @param context appcontext to be set */ public void setCreateAppContext(boolean context) { this.context = context; } /** - * Returns whether applications are launched in their own + * @return whether applications are launched in their own * AppContext. */ public boolean isCreateAppContext() { @@ -174,9 +176,8 @@ } /** - * Set the parser settings to use when the Launcher initiates parsing of + * @param settings the parser settings to use when the Launcher initiates parsing of * a JNLP file. - * @param settings */ public void setParserSettings(ParserSettings settings) { parserSettings = settings; @@ -494,6 +495,9 @@ /** * Launches a JNLP application. This method should be called * from a thread in the application's thread group. + * @param file jnlpfile - source of application + * @return application to be launched + * @throws net.sourceforge.jnlp.LaunchException if launch fails on unrecoverable exception */ protected ApplicationInstance launchApplication(JNLPFile file) throws LaunchException { if (!file.isApplication()) { @@ -622,6 +626,9 @@ * * @param file the JNLP file * @param enableCodeBase whether to add the codebase URL to the classloader + * @param cont container where to put application + * @return application + * @throws net.sourceforge.jnlp.LaunchException if deploy unrecoverably die */ protected ApplicationInstance launchApplet(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException { if (!file.isApplet()) { @@ -663,6 +670,11 @@ /** * Gets an ApplicationInstance, but does not launch the applet. + * @param file the JNLP file + * @param enableCodeBase whether to add the codebase URL to the classloader + * @param cont container where to put applet + * @return applet + * @throws net.sourceforge.jnlp.LaunchException if deploy unrecoverably die */ protected ApplicationInstance getApplet(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException { if (!file.isApplet()) { @@ -688,6 +700,9 @@ /** * Launches a JNLP installer. This method should be called from * a thread in the application's thread group. + * @param file jnlp file to read installer from + * @return application + * @throws net.sourceforge.jnlp.LaunchException if deploy unrecoverably die */ protected ApplicationInstance launchInstaller(JNLPFile file) throws LaunchException { // TODO Check for an existing single instance once implemented. @@ -698,7 +713,11 @@ /** * Create an AppletInstance. * - * @param enableCodeBase whether to add the code base URL to the classloader + * @param file the JNLP file + * @param enableCodeBase whether to add the codebase URL to the classloader + * @param cont container where to put applet + * @return applet + * @throws net.sourceforge.jnlp.LaunchException if deploy unrecoverably die */ //FIXME - when multiple applets are on one page, this method is visited simultaneously //and then appelts creates in little bit strange manner. This issue is visible with @@ -751,6 +770,9 @@ * gcjwebplugin. * @param file the PluginBridge to be used. * @param enableCodeBase whether to add the code base URL to the classloader. + * @param cont container where to put applet + * @return applet + * @throws net.sourceforge.jnlp.LaunchException if deploy unrecoverably dien */ protected Applet createAppletObject(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException { try { @@ -774,6 +796,9 @@ /** * Creates an Application. + * @param file the JNLP file + * @return application + * @throws net.sourceforge.jnlp.LaunchException if deploy unrecoverably die */ protected ApplicationInstance createApplication(JNLPFile file) throws LaunchException { try { @@ -791,10 +816,11 @@ /** * Create a thread group for the JNLP file. - * + * @param file the JNLP file * Note: if the JNLPFile is an applet (ie it is a subclass of PluginBridge) * then this method simply returns the existing ThreadGroup. The applet * ThreadGroup has to be created at an earlier point in the applet code. + * @return ThreadGroup for this app/applet */ protected ThreadGroup createThreadGroup(JNLPFile file) { final ThreadGroup tg;
--- a/netx/net/sourceforge/jnlp/MalformedXMLParser.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/MalformedXMLParser.java Thu Apr 16 19:34:18 2015 +0200 @@ -65,10 +65,11 @@ public class MalformedXMLParser extends XMLParser { /** - * Parses the data from an {@link InputStream} to create a XML tree. + * Parses the data from an {@link java.io.InputStream} to create a XML tree. * Returns a {@link Node} representing the root of the tree. * - * @param input the {@link InputStream} to read data from + * @param input the {@link java.io.InputStream} to read data from + * @return root node of document * @throws ParseException if an exception occurs while parsing the input */ @Override @@ -82,10 +83,10 @@ * Reads malformed XML from the InputStream original and returns a new * InputStream which can be used to read a well-formed version of the input * - * @param original + * @param original original input * @return an {@link InputStream} which can be used to read a well-formed * version of the input XML - * @throws ParseException + * @throws ParseException if an exception occurs while parsing the input */ public static InputStream xmlizeInputStream(InputStream original) throws ParseException { try {
--- a/netx/net/sourceforge/jnlp/MenuDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/MenuDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -19,17 +19,18 @@ public class MenuDesc { /** the submenu for this menu entry */ - private String subMenu; + private final String subMenu; /** * Create a new menu descriptor + * @param subMenu sub-menu of this menu if any or null. */ public MenuDesc(String subMenu) { this.subMenu = subMenu; } /** - * Returns the submenu for this menu entry. + * @return the submenu for this menu entry. */ public String getSubMenu() { return subMenu;
--- a/netx/net/sourceforge/jnlp/NetxPanel.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/NetxPanel.java Thu Apr 16 19:34:18 2015 +0200 @@ -54,7 +54,7 @@ // We use this so that we can create exactly one thread group // for all panels with the same uKey. private static final Map<String, ThreadGroup> uKeyToTG = - new HashMap<String, ThreadGroup>(); + new HashMap<>(); private static final Object TGMapMutex = new Object(); // This map is actually a set (unfortunately there is no ConcurrentSet
--- a/netx/net/sourceforge/jnlp/PackageDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/PackageDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -25,13 +25,13 @@ public class PackageDesc { /** the package name */ - private String name; + private final String name; /** the part required by the package */ - private String part; + private final String part; /** whether the package includes subpackages */ - private boolean recursive; + private final boolean recursive; /** * Create a package descriptor. @@ -47,9 +47,10 @@ } /** - * Returns whether the specified class is part of this package. + * @return whether the specified class is part of this package. * * @param className the fully qualified class name + */ public boolean matches(String className) { // form 1: exact class @@ -72,21 +73,21 @@ } /** - * Returns the package name. + * @return the package name. */ public String getName() { return name; } /** - * Returns the part name. + * @return the part name. */ public String getPart() { return part; } /** - * Returns whether subpackages should be matched by this + * @return whether subpackages should be matched by this * package. */ public boolean isRecursive() {
--- a/netx/net/sourceforge/jnlp/ParseException.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/ParseException.java Thu Apr 16 19:34:18 2015 +0200 @@ -16,8 +16,6 @@ package net.sourceforge.jnlp; -import java.io.*; - /** * Thrown to indicate that an error has occurred while parsing a * JNLP file. @@ -33,6 +31,7 @@ /** * Create a parse exception with the specified message. + * @param message to be shown in exception */ public ParseException(String message) { super(message); @@ -41,6 +40,8 @@ /** * Create a parse exception with the specified message and * cause. + * @param message to be used by exception + * @param cause cause of exception */ public ParseException(String message, Throwable cause) { super(message, cause);
--- a/netx/net/sourceforge/jnlp/Parser.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/Parser.java Thu Apr 16 19:34:18 2015 +0200 @@ -37,7 +37,7 @@ * @author <a href="mailto:jmaxwell@users.sourceforge.net">Jon A. Maxwell (JAM)</a> - initial author * @version $Revision: 1.13 $ */ -public class Parser { +public final class Parser { private static String CODEBASE = "codebase"; @@ -110,7 +110,7 @@ * @param settings the parser settings to use when parsing the JNLP file * @throws ParseException if the JNLP file is invalid */ - public Parser(JNLPFile file, URL base, Node root, ParserSettings settings) throws ParseException { + Parser(JNLPFile file, URL base, Node root, ParserSettings settings) throws ParseException { this(file, base, root, settings, null); } @@ -130,7 +130,7 @@ * @param codebase codebase to use if we did not parse one from JNLP file. * @throws ParseException if the JNLP file is invalid */ - public Parser(JNLPFile file, URL base, Node root, ParserSettings settings, URL codebase) throws ParseException { + Parser(JNLPFile file, URL base, Node root, ParserSettings settings, URL codebase) throws ParseException { this.file = file; this.root = root; this.strict = settings.isStrict(); @@ -161,6 +161,7 @@ /** * Returns the file version. + * @return version of file */ public Version getFileVersion() { return getVersion(root, "version", null); @@ -168,26 +169,28 @@ /** * Returns the file location. + * @return url of source file */ public URL getFileLocation() { return fileLocation; } /** - * Returns the codebase. + * @return the codebase. */ public URL getCodeBase() { return codebase; } /** - * Returns the specification version. + * @return the specification version. + * */ public Version getSpecVersion() { return spec; } - public UpdateDesc getUpdate(Node parent) throws ParseException { + UpdateDesc getUpdate(Node parent) throws ParseException { UpdateDesc updateDesc = null; Node child = parent.getFirstChild(); while (child != null) { @@ -200,26 +203,36 @@ Check check; String checkValue = getAttribute(node, "check", "timeout"); - if (checkValue.equals("always")) { - check = Check.ALWAYS; - } else if (checkValue.equals("timeout")) { - check = Check.TIMEOUT; - } else if (checkValue.equals("background")) { - check = Check.BACKGROUND; - } else { - check = Check.TIMEOUT; + switch (checkValue) { + case "always": + check = Check.ALWAYS; + break; + case "timeout": + check = Check.TIMEOUT; + break; + case "background": + check = Check.BACKGROUND; + break; + default: + check = Check.TIMEOUT; + break; } String policyString = getAttribute(node, "policy", "always"); Policy policy; - if (policyString.equals("always")) { - policy = Policy.ALWAYS; - } else if (policyString.equals("prompt-update")) { - policy = Policy.PROMPT_UPDATE; - } else if (policyString.equals("prompt-run")) { - policy = Policy.PROMPT_RUN; - } else { - policy = Policy.ALWAYS; + switch (policyString) { + case "always": + policy = Policy.ALWAYS; + break; + case "prompt-update": + policy = Policy.PROMPT_UPDATE; + break; + case "prompt-run": + policy = Policy.PROMPT_RUN; + break; + default: + policy = Policy.ALWAYS; + break; } updateDesc = new UpdateDesc(check, policy); @@ -239,37 +252,36 @@ // /** - * Returns all of the ResourcesDesc elements under the specified + * @return all of the ResourcesDesc elements under the specified * node (jnlp or j2se). * * @param parent the parent node (either jnlp or j2se) * @param j2se true if the resources are located under a j2se or java node * @throws ParseException if the JNLP file is invalid */ - public List<ResourcesDesc> getResources(Node parent, boolean j2se) + List<ResourcesDesc> getResources(Node parent, boolean j2se) throws ParseException { - List<ResourcesDesc> result = new ArrayList<ResourcesDesc>(); + List<ResourcesDesc> result = new ArrayList<>(); Node resources[] = getChildNodes(parent, "resources"); // ensure that there are at least one information section present if (resources.length == 0 && !j2se) { throw new ParseException(R("PNoResources")); } - // create objects from the resources sections - for (int i = 0; i < resources.length; i++) { - result.add(getResourcesDesc(resources[i], j2se)); + for (Node resource : resources) { + result.add(getResourcesDesc(resource, j2se)); } return result; } /** - * Returns the ResourcesDesc element at the specified node. + * @return the ResourcesDesc element at the specified node. * * @param node the resources node * @param j2se true if the resources are located under a j2se or java node * @throws ParseException if the JNLP file is invalid */ - public ResourcesDesc getResourcesDesc(Node node, boolean j2se) throws ParseException { + private ResourcesDesc getResourcesDesc(Node node, boolean j2se) throws ParseException { boolean mainFlag = false; // if found a main tag // create resources @@ -331,12 +343,12 @@ } /** - * Returns the JRE element at the specified node. + * @return the JRE element at the specified node. * * @param node the j2se/java node * @throws ParseException if the JNLP file is invalid */ - public JREDesc getJRE(Node node) throws ParseException { + private JREDesc getJRE(Node node) throws ParseException { Version version = getVersion(node, "version", null); URL location = getURL(node, "href", base); String vmArgs = getAttribute(node, "java-vm-args", null); @@ -361,7 +373,7 @@ * @param node the jar or nativelib node * @throws ParseException if the JNLP file is invalid */ - public JARDesc getJAR(Node node) throws ParseException { + private JARDesc getJAR(Node node) throws ParseException { boolean nativeJar = "nativelib".equals(node.getNodeName()); URL location = getRequiredURL(node, "href", base); Version version = getVersion(node, "version", null); @@ -378,12 +390,12 @@ } /** - * Returns the Extension element at the specified node. + * @return the Extension element at the specified node. * * @param node the extension node * @throws ParseException if the JNLP file is invalid */ - public ExtensionDesc getExtension(Node node) throws ParseException { + private ExtensionDesc getExtension(Node node) throws ParseException { String name = getAttribute(node, "name", null); Version version = getVersion(node, "version", null); URL location = getRequiredURL(node, "href", base); @@ -391,24 +403,21 @@ ExtensionDesc ext = new ExtensionDesc(name, version, location); Node dload[] = getChildNodes(node, "ext-download"); - for (int i = 0; i < dload.length; i++) { - boolean lazy = "lazy".equals(getAttribute(dload[i], "download", "eager")); - - ext.addPart(getRequiredAttribute(dload[i], "ext-part", null), - getAttribute(dload[i], "part", null), - lazy); + for (Node dload1 : dload) { + boolean lazy = "lazy".equals(getAttribute(dload1, "download", "eager")); + ext.addPart(getRequiredAttribute(dload1, "ext-part", null), getAttribute(dload1, "part", null), lazy); } return ext; } /** - * Returns the Property element at the specified node. + * @return the Property element at the specified node. * * @param node the property node * @throws ParseException if the JNLP file is invalid */ - public PropertyDesc getProperty(Node node) throws ParseException { + private PropertyDesc getProperty(Node node) throws ParseException { String name = getRequiredAttribute(node, "name", null); String value = getRequiredAttribute(node, "value", ""); @@ -416,12 +425,12 @@ } /** - * Returns the Package element at the specified node. + * @return the Package element at the specified node. * * @param node the package node * @throws ParseException if the JNLP file is invalid */ - public PackageDesc getPackage(Node node) throws ParseException { + private PackageDesc getPackage(Node node) throws ParseException { String name = getRequiredAttribute(node, "name", null); String part = getRequiredAttribute(node, "part", ""); boolean recursive = getAttribute(node, "recursive", "false").equals("true"); @@ -459,15 +468,15 @@ } /** - * Returns all of the information elements under the specified + * @return all of the information elements under the specified * node. * * @param parent the parent node (jnlp) * @throws ParseException if the JNLP file is invalid */ - public List<InformationDesc> getInfo(Node parent) + List<InformationDesc> getInfo(Node parent) throws ParseException { - List<InformationDesc> result = new ArrayList<InformationDesc>(); + List<InformationDesc> result = new ArrayList<>(); Node info[] = getChildNodes(parent, "information"); // ensure that there are at least one information section present @@ -483,13 +492,13 @@ } /** - * Returns the information element at the specified node. + * @return the information element at the specified node. * * @param node the information node * @throws ParseException if the JNLP file is invalid */ - public InformationDesc getInformationDesc(Node node) throws ParseException { - List<String> descriptionsUsed = new ArrayList<String>(); + InformationDesc getInformationDesc(Node node) throws ParseException { + List<String> descriptionsUsed = new ArrayList<>(); // locale Locale locales[] = getLocales(node); @@ -560,12 +569,12 @@ } /** - * Returns the icon element at the specified node. + * @return the icon element at the specified node. * * @param node the icon node * @throws ParseException if the JNLP file is invalid */ - public IconDesc getIcon(Node node) throws ParseException { + private IconDesc getIcon(Node node) throws ParseException { int width = Integer.parseInt(getAttribute(node, "width", "-1")); int height = Integer.parseInt(getAttribute(node, "height", "-1")); int size = Integer.parseInt(getAttribute(node, "size", "-1")); @@ -581,14 +590,14 @@ // /** - * Returns the security descriptor element. If no security + * @return the security descriptor element. If no security * element was specified in the JNLP file then a SecurityDesc * with applet permissions is returned. * * @param parent the parent node * @throws ParseException if the JNLP file is invalid */ - public SecurityDesc getSecurity(Node parent) throws ParseException { + SecurityDesc getSecurity(Node parent) throws ParseException { Node nodes[] = getChildNodes(parent, "security"); // test for too many security elements @@ -623,7 +632,7 @@ * Returns whether the JNLP file requests a trusted execution * environment. */ - protected boolean isTrustedEnvironment() { + private boolean isTrustedEnvironment() { Node security = getChildNode(root, "security"); if (security != null) @@ -639,13 +648,13 @@ // /** - * Returns the launch descriptor element, either AppletDesc, + * @return the launch descriptor element, either AppletDesc, * ApplicationDesc, or InstallerDesc. * * @param parent the parent node * @throws ParseException if the JNLP file is invalid */ - public LaunchDesc getLauncher(Node parent) throws ParseException { + 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 @@ -671,15 +680,16 @@ } /** - * Returns the applet descriptor. + * @param node + * @return the applet descriptor. * * @throws ParseException if the JNLP file is invalid */ - public AppletDesc getApplet(Node node) throws ParseException { + private AppletDesc getApplet(Node node) throws ParseException { String name = getRequiredAttribute(node, "name", R("PUnknownApplet")); String main = getRequiredAttribute(node, "main-class", null); URL docbase = getURL(node, "documentbase", base); - Map<String, String> paramMap = new HashMap<String, String>(); + Map<String, String> paramMap = new HashMap<>(); int width = 0; int height = 0; @@ -694,33 +704,32 @@ // read params Node params[] = getChildNodes(node, "param"); - for (int i = 0; i < params.length; i++) { - paramMap.put(getRequiredAttribute(params[i], "name", null), - getRequiredAttribute(params[i], "value", "")); + for (Node param : params) { + paramMap.put(getRequiredAttribute(param, "name", null), getRequiredAttribute(param, "value", "")); } return new AppletDesc(name, main, docbase, width, height, paramMap); } /** - * Returns the application descriptor. + * @return the application descriptor. * + * @param node * @throws ParseException if the JNLP file is invalid */ - public ApplicationDesc getApplication(Node node) throws ParseException { + private ApplicationDesc getApplication(Node node) throws ParseException { String main = getAttribute(node, "main-class", null); - List<String> argsList = new ArrayList<String>(); + List<String> argsList = new ArrayList<>(); // if (main == null) // only ok if can be found in main jar file (can't check here but make a note) // read parameters Node args[] = getChildNodes(node, "argument"); - for (int i = 0; i < args.length; i++) { + for (Node arg : args) { //argsList.add( args[i].getNodeValue() ); - //This approach was not finding the argument text - argsList.add(getSpanText(args[i])); + argsList.add(getSpanText(arg)); } String argStrings[] = argsList.toArray(new String[argsList.size()]); @@ -729,9 +738,11 @@ } /** - * Returns the component descriptor. + * @param parent + * @return the component descriptor. + * @throws net.sourceforge.jnlp.ParseException */ - public ComponentDesc getComponent(Node parent) throws ParseException { + ComponentDesc getComponent(Node parent) throws ParseException { if (1 < getChildNodes(parent, "component-desc").length) { throw new ParseException(R("PTwoDescriptors")); @@ -751,18 +762,21 @@ } /** - * Returns the installer descriptor. + * @param node + * @return the installer descriptor. */ - public InstallerDesc getInstaller(Node node) { + private InstallerDesc getInstaller(Node node) { String main = getAttribute(node, "main-class", null); return new InstallerDesc(main); } /** - * Returns the association descriptor. + * @return the association descriptor. + * @param node + * @throws net.sourceforge.jnlp.ParseException */ - public AssociationDesc getAssociation(Node node) throws ParseException { + private AssociationDesc getAssociation(Node node) throws ParseException { String[] extensions = getRequiredAttribute(node, "extensions", null).split(" "); String mimeType = getRequiredAttribute(node, "mime-type", null); @@ -770,9 +784,9 @@ } /** - * Returns the shortcut descriptor. + * @return the shortcut descriptor. */ - public ShortcutDesc getShortcut(Node node) throws ParseException { + private ShortcutDesc getShortcut(Node node) throws ParseException { String online = getAttribute(node, "online", "true"); boolean shortcutIsOnline = Boolean.valueOf(online); @@ -785,16 +799,17 @@ while (child != null) { String name = child.getNodeName(); - if ("desktop".equals(name)) { - if (showOnDesktop && strict) { - throw new ParseException(R("PTwoDesktops")); - } - showOnDesktop = true; - } else if ("menu".equals(name)) { - if (menu != null && strict) { - throw new ParseException(R("PTwoMenus")); - } - menu = getMenu(child); + if (null != name) switch (name) { + case "desktop": + if (showOnDesktop && strict) { + throw new ParseException(R("PTwoDesktops")); + } showOnDesktop = true; + break; + case "menu": + if (menu != null && strict) { + throw new ParseException(R("PTwoMenus")); + } menu = getMenu(child); + break; } child = child.getNextSibling(); @@ -808,18 +823,18 @@ } /** - * Returns the menu descriptor. + * @return the menu descriptor. */ - public MenuDesc getMenu(Node node) { + private MenuDesc getMenu(Node node) { String subMenu = getAttribute(node, "submenu", null); return new MenuDesc(subMenu); } /** - * Returns the related-content descriptor. + * @return the related-content descriptor. */ - public RelatedContentDesc getRelatedContent(Node node) throws ParseException { + private RelatedContentDesc getRelatedContent(Node node) throws ParseException { getRequiredAttribute(node, "href", null); URL location = getURL(node, "href", base); @@ -833,21 +848,22 @@ while (child != null) { String name = child.getNodeName(); - if ("title".equals(name)) { - if (title != null && strict) { - throw new ParseException(R("PTwoTitles")); - } - title = getSpanText(child, false); - } else if ("description".equals(name)) { - if (description != null && strict) { - throw new ParseException(R("PTwoDescriptions")); - } - description = getSpanText(child, false); - } else if ("icon".equals(name)) { - if (icon != null && strict) { - throw new ParseException(R("PTwoIcons")); - } - icon = getIcon(child); + if (null != name) switch (name) { + case "title": + if (title != null && strict) { + throw new ParseException(R("PTwoTitles")); + } title = getSpanText(child, false); + break; + case "description": + if (description != null && strict) { + throw new ParseException(R("PTwoDescriptions")); + } description = getSpanText(child, false); + break; + case "icon": + if (icon != null && strict) { + throw new ParseException(R("PTwoIcons")); + } icon = getIcon(child); + break; } child = child.getNextSibling(); @@ -865,12 +881,12 @@ // other methods /** - * Returns an array of substrings seperated by spaces (spaces + * @return an array of substrings seperated by spaces (spaces * escaped with backslash do not separate strings). This method * splits strings as per the spec except that it does replace * escaped other characters with their own value. */ - public String[] splitString(String source) { + private String[] splitString(String source) { if (source == null) return new String[0]; @@ -903,17 +919,17 @@ } /** - * Returns the Locale object(s) from a node's locale attribute. + * @return the Locale object(s) from a node's locale attribute. * * @param node the node with a locale attribute */ - public Locale[] getLocales(Node node) { - List<Locale> locales = new ArrayList<Locale>(); + private Locale[] getLocales(Node node) { + List<Locale> locales = new ArrayList<>(); String localeParts[] = splitString(getAttribute(node, "locale", "")); - for (int i = 0; i < localeParts.length; i++) { - Locale l = getLocale(localeParts[i]); + for (String localePart : localeParts) { + Locale l = getLocale(localePart); if (l != null) locales.add(l); } @@ -925,6 +941,7 @@ * Returns a {@link Locale} from a single locale. * * @param localeStr the locale string + * @return locale of document */ public Locale getLocale(String localeStr) { if (localeStr.length() < 2) @@ -941,18 +958,19 @@ // XML junk /** * Returns the implied text under a node, for example "text" in - * "<description>text</description>". + * "<description>text</description>". * * @param node the node with text under it + * @return * @throws ParseException if the JNLP file is invalid */ - public String getSpanText(Node node) throws ParseException { + private String getSpanText(Node node) throws ParseException { return getSpanText(node, true); } /** * Returns the implied text under a node, for example "text" in - * "<description>text</description>". If preserveSpacing is false, + * "<description>text</description>". If preserveSpacing is false, * sequences of whitespace characters are turned into a single * space character. * @@ -960,7 +978,7 @@ * @param preserveSpacing if true, preserve whitespace * @throws ParseException if the JNLP file is invalid */ - public String getSpanText(Node node, boolean preserveSpacing) + private String getSpanText(Node node, boolean preserveSpacing) throws ParseException { if (node == null) return null; @@ -995,7 +1013,7 @@ /** * Returns the first child node with the specified name. */ - public static Node getChildNode(Node node, String name) { + private static Node getChildNode(Node node, String name) { Node[] result = getChildNodes(node, name); if (result.length == 0) return null; @@ -1006,8 +1024,8 @@ /** * Returns all child nodes with the specified name. */ - public static Node[] getChildNodes(Node node, String name) { - List<Node> result = new ArrayList<Node>(); + private static Node[] getChildNodes(Node node, String name) { + List<Node> result = new ArrayList<>(); Node child = node.getFirstChild(); while (child != null) { @@ -1038,7 +1056,7 @@ } /** - * Returns the same result as getURL except that a + * @return the same result as getURL except that a * ParseException is thrown if the attribute is null or empty. * * @param node the node @@ -1046,7 +1064,7 @@ * @param base the base URL * @throws ParseException if the JNLP file is invalid */ - public URL getRequiredURL(Node node, String name, URL base) throws ParseException { + private URL getRequiredURL(Node node, String name, URL base) throws ParseException { // probably should change "" to null so that url is always // required even if !strict getRequiredAttribute(node, name, ""); @@ -1055,7 +1073,7 @@ } /** - * Returns a URL object from a href string relative to the + * @return a URL object from a href string relative to the * code base. If the href denotes a relative URL, it must * reference a location that is a subdirectory of the * codebase. @@ -1065,7 +1083,7 @@ * @param base the base URL * @throws ParseException if the JNLP file is invalid */ - public URL getURL(Node node, String name, URL base) throws ParseException { + URL getURL(Node node, String name, URL base) throws ParseException { String href; if (CODEBASE.equals(name)) { href = getCleanAttribute(node, name); @@ -1114,7 +1132,7 @@ } /** - * Returns a Version from the specified attribute and default + * @return a Version from the specified attribute and default * value. * * @param node the node @@ -1122,7 +1140,7 @@ * @param defaultValue default if no such attribute * @return a Version, or null if no such attribute and default is null */ - public Version getVersion(Node node, String name, String defaultValue) { + private Version getVersion(Node node, String name, String defaultValue) { String version = getAttribute(node, name, defaultValue); if (version == null) return null; @@ -1144,7 +1162,7 @@ List<String> validStartingArguments = Arrays.asList(getValidStartingVMArguments()); String[] arguments = vmArgs.split(" "); - boolean argumentIsValid = false; + boolean argumentIsValid; for (String argument : arguments) { argumentIsValid = false; @@ -1236,7 +1254,7 @@ } /** - * Returns the same result as getAttribute except that if strict + * @return the same result as getAttribute except that if strict * mode is enabled or the default value is null a parse * exception is thrown instead of returning the default value. * @@ -1245,7 +1263,7 @@ * @param defaultValue default value * @throws ParseException if the attribute does not exist or is empty */ - public String getRequiredAttribute(Node node, String name, String defaultValue) throws ParseException { + private String getRequiredAttribute(Node node, String name, String defaultValue) throws ParseException { String result = getAttribute(node, name, null); if (result == null || result.length() == 0) @@ -1259,14 +1277,14 @@ } /** - * Retuns an attribute or the specified defaultValue if there is + * @return an attribute or the specified defaultValue if there is * no such attribute. * * @param node the node * @param name the attribute * @param defaultValue default if no such attribute */ - public String getAttribute(Node node, String name, String defaultValue) { + private String getAttribute(Node node, String name, String defaultValue) { // SAX // String result = ((Element) node).getAttribute(name); String result = getCleanAttribute(node, name); @@ -1287,12 +1305,12 @@ public static final String MALFORMED_PARSER_CLASS = "net.sourceforge.jnlp.MalformedXMLParser"; public static final String NORMAL_PARSER_CLASS = "net.sourceforge.jnlp.XMLParser"; /** - * Return the root node from the XML document in the specified + * @return the root node from the XML document in the specified * input stream. * * @throws ParseException if the JNLP file is invalid */ - public static Node getRootNode(InputStream input, ParserSettings settings) throws ParseException { + static Node getRootNode(InputStream input, ParserSettings settings) throws ParseException { String className; if (settings.isMalformedXmlAllowed()) { className = MALFORMED_PARSER_CLASS; @@ -1301,7 +1319,7 @@ } try { - Class<?> klass = null; + Class<?> klass; try { klass = Class.forName(className); } catch (ClassNotFoundException e) {
--- a/netx/net/sourceforge/jnlp/ParserSettings.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/ParserSettings.java Thu Apr 16 19:34:18 2015 +0200 @@ -57,7 +57,11 @@ this(false, true, true); } - /** Create a new ParserSettings object */ + /** Create a new ParserSettings object + * @param strict true if parser should be stric + * @param extensionAllowed true if extensions are allowed + * @param malformedXmlAllowed true if xml sanitizer should be used + */ public ParserSettings(boolean strict, boolean extensionAllowed, boolean malformedXmlAllowed) { this.isStrict = strict; this.extensionAllowed = extensionAllowed; @@ -80,7 +84,7 @@ } /** - * Return the global parser settings in use. + * @return the global parser settings in use. */ public static ParserSettings getGlobalParserSettings() { return globalParserSettings; @@ -88,13 +92,15 @@ /** * Set the global ParserSettings to match the given settings. + * @param parserSettings to be used */ public static void setGlobalParserSettings(ParserSettings parserSettings) { globalParserSettings = parserSettings; } /** - * Return the ParserSettings to be used according to arguments specified + * @param optionParser to be read as source for globaPArserSettings + * @return the ParserSettings to be used according to arguments specified * at boot on the command line. These settings are also stored so they * can be retrieved at a later time. */
--- a/netx/net/sourceforge/jnlp/PluginBridge.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/PluginBridge.java Thu Apr 16 19:34:18 2015 +0200 @@ -47,7 +47,7 @@ * Allows reuse of code that expects a JNLPFile object, * while overriding behaviour specific to applets. */ -public class PluginBridge extends JNLPFile { +public final class PluginBridge extends JNLPFile { private final PluginParameters params; final private Set<String> jars = new HashSet<>(); @@ -63,6 +63,14 @@ /** * Creates a new PluginBridge using a default JNLPCreator. + * @param codebase as specified in attribute + * @param documentBase as specified in attribute + * @param jar jar attribute value + * @param main main method attribute value + * @param width width of appelt as specified in attribute + * @param height height of applet as specified in attribute + * @param params parameters as parsed from source html + * @throws java.lang.Exception general exception as anything can happen */ public PluginBridge(URL codebase, URL documentBase, String jar, String main, int width, int height, PluginParameters params) @@ -108,7 +116,7 @@ if (fileLocation == null){ fileLocation = jnlp; } - JNLPFile jnlpFile = null; + JNLPFile jnlpFile; if (params.getJNLPEmbedded() != null) { InputStream jnlpInputStream = new ByteArrayInputStream(decodeBase64String(params.getJNLPEmbedded())); @@ -163,7 +171,7 @@ } } else { // Should we populate this list with applet attribute tags? - info = new ArrayList<InformationDesc>(); + info = new ArrayList<>(); useJNLPHref = false; } @@ -179,12 +187,12 @@ versions = cacheVersion.split(","); } - String[] jars = cacheArchive.split(","); - cacheJars = new String[jars.length]; + String[] ljars = cacheArchive.split(","); + cacheJars = new String[ljars.length]; - for (int i = 0; i < jars.length; i++) { + for (int i = 0; i < ljars.length; i++) { - cacheJars[i] = jars[i].trim(); + cacheJars[i] = ljars[i].trim(); if (versions.length > 0) { cacheJars[i] += ";" + versions[i].trim(); @@ -226,10 +234,13 @@ for (String s : jargs.split(" ")) { String[] parts = s.trim().split("="); if (parts.length == 2 && Boolean.valueOf(parts[1])) { - if ("-Djnlp.packEnabled".equals(parts[0])) { - usePack = true; - } else if ("-Djnlp.versionEnabled".equals(parts[0])) { - useVersion = true; + if (null != parts[0]) switch (parts[0]) { + case "-Djnlp.packEnabled": + usePack = true; + break; + case "-Djnlp.versionEnabled": + useVersion = true; + break; } } } @@ -272,6 +283,7 @@ /** * {@inheritDoc } + * @return options of download */ @Override public DownloadOptions getDownloadOptions() { @@ -396,14 +408,14 @@ } /** - * Returns the list of folders to be added to the codebase + * @return the list of folders to be added to the codebase */ public List<String> getCodeBaseFolders() { return new ArrayList<>(codeBaseFolders); } /** - * Returns the resources section of the JNLP file for the + * @return the resources section of the JNLP file for the * specified locale, os, and arch. */ @Override
--- a/netx/net/sourceforge/jnlp/PropertyDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/PropertyDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -30,6 +30,7 @@ * * @param prop - the property to be parsed from format key=value * @return new PropertyDesc based on parsed key=value, though composed from key and value + * @throws net.sourceforge.jnlp.LaunchException if creations fails */ public static PropertyDesc fromString(String prop) throws LaunchException { // allows empty property, not sure about validity of that. @@ -62,14 +63,14 @@ } /** - * Returns the property's key + * @return the property's key */ public String getKey() { return key; } /** - * Returns the property's value + * @return the property's value */ public String getValue() { return value;
--- a/netx/net/sourceforge/jnlp/RelatedContentDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/RelatedContentDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -49,7 +49,7 @@ } /** - * Returns the title of this content.. + * @return the title of this content.. */ public String getTitle() { return title; @@ -57,20 +57,21 @@ /** * Set the description of this related content + * @param description to be set */ public void setDescription(String description) { this.description = description; } /** - * Returns the description of the related content + * @return the description of the related content */ public String getDescription() { return description; } /** - * Returns the location of the related content. Not null + * @return the location of the related content. Not null */ public URL getLocation() { return location; @@ -78,13 +79,14 @@ /** * Set the icon for this related content + * @param icon set to be used */ public void setIconDesc(IconDesc icon) { this.icon = icon; } /** - * Returns the icon descriptor for the realted content + * @return the icon descriptor for the realted content */ public IconDesc getIcon() { return icon;
--- a/netx/net/sourceforge/jnlp/ResourcesDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/ResourcesDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -27,19 +27,19 @@ public class ResourcesDesc { /** the locales of these resources */ - private Locale locales[]; + private final Locale locales[]; /** the OS for these resources */ - private String os[]; + private final String os[]; /** the arch for these resources */ - private String arch[]; + private final String arch[]; /** the JNLPFile this information is for */ - private JNLPFile jnlpFile; + private final JNLPFile jnlpFile; /** list of jars, packages, properties, and extensions */ - private List<Object> resources = new ArrayList<Object>(); + private final List<Object> resources = new ArrayList<>(); // mixed list makes easier for lookup code @@ -60,11 +60,11 @@ } /** - * Returns the JVMs. + * @return the JVMs. */ public JREDesc[] getJREs() { - List<JREDesc> resources = getResources(JREDesc.class); - return resources.toArray(new JREDesc[resources.size()]); + List<JREDesc> lresources = getResources(JREDesc.class); + return lresources.toArray(new JREDesc[lresources.size()]); } public static JARDesc getMainJAR(JARDesc jars[] ) { @@ -85,7 +85,7 @@ } } /** - * Returns the main JAR for these resources. There first JAR + * @return the main JAR for these resources. There first JAR * is returned if no JARs are specified as the main JAR, and if * there are no JARs defined then null is returned. */ @@ -94,45 +94,45 @@ } /** - * Returns all of the JARs. + * @return all of the JARs. */ public JARDesc[] getJARs() { - List<JARDesc> resources = getResources(JARDesc.class); - return resources.toArray(new JARDesc[resources.size()]); + List<JARDesc> lresources = getResources(JARDesc.class); + return lresources.toArray(new JARDesc[lresources.size()]); } /** - * Returns the JARs with the specified part name. + * @return the JARs with the specified part name. * * @param partName the part name, null and "" equivalent */ public JARDesc[] getJARs(String partName) { - List<JARDesc> resources = getResources(JARDesc.class); + List<JARDesc> lresources = getResources(JARDesc.class); - for (int i = resources.size(); i-- > 0;) { - JARDesc jar = resources.get(i); + for (int i = lresources.size(); i-- > 0;) { + JARDesc jar = lresources.get(i); if (!("" + jar.getPart()).equals("" + partName)) - resources.remove(i); + lresources.remove(i); } - return resources.toArray(new JARDesc[resources.size()]); + return lresources.toArray(new JARDesc[lresources.size()]); } /** - * Returns the Extensions. + * @return the Extensions. */ public ExtensionDesc[] getExtensions() { - List<ExtensionDesc> resources = getResources(ExtensionDesc.class); - return resources.toArray(new ExtensionDesc[resources.size()]); + List<ExtensionDesc> lresources = getResources(ExtensionDesc.class); + return lresources.toArray(new ExtensionDesc[lresources.size()]); } /** - * Returns the Packages. + * @return the Packages. */ public PackageDesc[] getPackages() { - List<PackageDesc> resources = getResources(PackageDesc.class); - return resources.toArray(new PackageDesc[resources.size()]); + List<PackageDesc> lresources = getResources(PackageDesc.class); + return lresources.toArray(new PackageDesc[lresources.size()]); } /** @@ -142,33 +142,33 @@ * @return the PackageDesc objects matching the class name */ public PackageDesc[] getPackages(String className) { - List<PackageDesc> resources = getResources(PackageDesc.class); + List<PackageDesc> lresources = getResources(PackageDesc.class); - for (int i = resources.size(); i-- > 0;) { - PackageDesc pk = resources.get(i); + for (int i = lresources.size(); i-- > 0;) { + PackageDesc pk = lresources.get(i); if (!pk.matches(className)) - resources.remove(i); + lresources.remove(i); } - return resources.toArray(new PackageDesc[resources.size()]); + return lresources.toArray(new PackageDesc[lresources.size()]); } /** - * Returns the Properties as a list. + * @return the Properties as a list. */ public PropertyDesc[] getProperties() { - List<PropertyDesc> resources = getResources(PropertyDesc.class); - return resources.toArray(new PropertyDesc[resources.size()]); + List<PropertyDesc> lresources = getResources(PropertyDesc.class); + return lresources.toArray(new PropertyDesc[lresources.size()]); } /** - * Returns the properties as a map. + * @return the properties as a map. */ public Map<String, String> getPropertiesMap() { - Map<String, String> properties = new HashMap<String, String>(); - List<PropertyDesc> resources = getResources(PropertyDesc.class); - for (PropertyDesc prop : resources) { + Map<String, String> properties = new HashMap<>(); + List<PropertyDesc> lresources = getResources(PropertyDesc.class); + for (PropertyDesc prop : lresources) { properties.put(prop.getKey(), prop.getValue()); } @@ -176,7 +176,7 @@ } /** - * Returns the os required by these resources, or null if no + * @return the os required by these resources, or null if no * locale was specified in the JNLP file. */ public String[] getOS() { @@ -184,7 +184,7 @@ } /** - * Returns the architecture required by these resources, or null + * @return the architecture required by these resources, or null * if no locale was specified in the JNLP file. */ public String[] getArch() { @@ -192,7 +192,7 @@ } /** - * Returns the locale required by these resources, or null if no + * @return the locale required by these resources, or null if no * locale was specified in the JNLP file. */ public Locale[] getLocales() { @@ -200,17 +200,19 @@ } /** - * Returns the JNLPFile the resources are for. + * @return the JNLPFile the resources are for. */ public JNLPFile getJNLPFile() { return jnlpFile; } /** - * Returns all resources of the specified type. + * @param <T> type of resource to be found + * @param type resource to be found + * @return all resources of the specified type. */ public <T> List<T> getResources(Class<T> type) { - List<T> result = new ArrayList<T>(); + List<T> result = new ArrayList<>(); for (Object resource : resources) { if (type.isAssignableFrom(resource.getClass())) @@ -222,6 +224,7 @@ /** * Add a resource. + * @param resource to be added */ public void addResource(Object resource) { // if this is going to stay public it should probably take an
--- a/netx/net/sourceforge/jnlp/SecurityDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/SecurityDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -308,7 +308,7 @@ } /** - * Returns the permissions type, one of: ALL_PERMISSIONS, + * @return the permissions type, one of: ALL_PERMISSIONS, * SANDBOX_PERMISSIONS, J2EE_PERMISSIONS. */ public Object getSecurityType() { @@ -316,7 +316,7 @@ } /** - * Returns a PermissionCollection containing the basic + * @return a PermissionCollection containing the basic * permissions granted depending on the security type. * * @param cs the CodeSource to get permissions for @@ -337,8 +337,9 @@ // add j2ee to sandbox if needed if (J2EE_PERMISSIONS.equals(type)) - for (int i = 0; i < j2eePermissions.length; i++) - permissions.add(j2eePermissions[i]); + for (Permission j2eePermission : j2eePermissions) { + permissions.add(j2eePermission); + } return permissions; } @@ -351,13 +352,14 @@ } /** - * Returns a PermissionCollection containing the sandbox permissions + * @return a PermissionCollection containing the sandbox permissions */ public PermissionCollection getSandBoxPermissions() { final Permissions permissions = new Permissions(); - for (int i = 0; i < sandboxPermissions.length; i++) - permissions.add(sandboxPermissions[i]); + for (Permission sandboxPermission : sandboxPermissions) { + permissions.add(sandboxPermission); + } if (grantAwtPermissions) { permissions.add(new AWTPermission("showWindowWithoutWarningBanner")); @@ -367,8 +369,8 @@ throw new NullJnlpFileException("Can not return sandbox permissions, file is null"); } if (file.isApplication()) { - for (int i = 0; i < jnlpRIAPermissions.length; i++) { - permissions.add(jnlpRIAPermissions[i]); + for (Permission jnlpRIAPermission : jnlpRIAPermissions) { + permissions.add(jnlpRIAPermission); } } } @@ -471,7 +473,7 @@ } /** - * Returns all the names of the basic JNLP system properties accessible by RIAs + * @return all the names of the basic JNLP system properties accessible by RIAs */ public static String[] getJnlpRIAPermissions() { String[] jnlpPermissions = new String[jnlpRIAPermissions.length];
--- a/netx/net/sourceforge/jnlp/ShortcutDesc.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/ShortcutDesc.java Thu Apr 16 19:34:18 2015 +0200 @@ -65,28 +65,28 @@ } /** - * Returns whether the shortcut requires being online + * @return whether the shortcut requires being online */ public boolean isOnline() { throw new RuntimeException("icedtea-web is not saving online-enforcing attribute. See Xoffline impelmentations if needed."); } /** * For testing purposes. Verify if it have been parsed out correctly. - * Returns whether the shortcut requires being online. + * @return whether the shortcut requires being online. */ boolean isOnlineValue() { return requiresOnline; } /** - * Return whether the shortcut should be placed on the desktop + * @return whether the shortcut should be placed on the desktop */ public boolean onDesktop() { return onDesktop; } /** - * Return whether the shortcut should be placed to the menus + * @return whether the shortcut should be placed to the menus */ public boolean toMenu() { return getMenu() != null; @@ -102,7 +102,7 @@ } /** - * Returns the menu this shortcut should be added to + * @return the menu this shortcut should be added to */ public MenuDesc getMenu() { return menu;
--- a/netx/net/sourceforge/jnlp/Version.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/Version.java Thu Apr 16 19:34:18 2015 +0200 @@ -119,24 +119,22 @@ /** * Create a Version object based on a version string (ie, * "1.2.3+ 4.56*"). + * @param versions string describing version */ public Version(String versions) { versionString = versions; } /** - * Returns true if the version represents a <i>version-id</i> (a + * @return true if the version represents a <i>version-id</i> (a * single version number such as 1.2) and false otherwise. */ public boolean isVersionId() { - if (-1 != versionString.indexOf(" ")) - return false; - - return true; + return -1 == versionString.indexOf(" "); } /** - * Returns true if all of this version's version-ids match one + * @return true if all of this version's version-ids match one * or more of the specifed version's version-id. * * @param version a version string @@ -146,7 +144,7 @@ } /** - * Returns true if all of this version's version-ids match one + * @return true if all of this version's version-ids match one * or more of the specifed version's version-id. * * @param version a Version object @@ -154,16 +152,17 @@ public boolean matches(Version version) { List<String> versionStrings = version.getVersionStrings(); - for (int i = 0; i < versionStrings.size(); i++) { - if (!this.matchesSingle(versionStrings.get(i))) + for (String versionString1 : versionStrings) { + if (!this.matchesSingle(versionString1)) { return false; + } } return true; } /** - * Returns true if any of this version's version-ids match one + * @return true if any of this version's version-ids match one * or more of the specifed version's version-id. * * @param version a version string @@ -173,7 +172,7 @@ } /** - * Returns true if any of this version's version-ids match one + * @return true if any of this version's version-ids match one * or more of the specifed version's version-id. * * @param version a Version object @@ -181,9 +180,10 @@ public boolean matchesAny(Version version) { List<String> versionStrings = version.getVersionStrings(); - for (int i = 0; i < versionStrings.size(); i++) { - if (this.matchesSingle(versionStrings.get(i))) + for (String versionString1 : versionStrings) { + if (this.matchesSingle(versionString1)) { return true; + } } return false; @@ -197,9 +197,10 @@ */ private boolean matchesSingle(String version) { List<String> versionStrings = this.getVersionStrings(); - for (int i = 0; i < versionStrings.size(); i++) { - if (matches(version, versionStrings.get(i))) + for (String versionString1 : versionStrings) { + if (matches(version, versionString1)) { return true; + } } return false; } @@ -219,7 +220,7 @@ if (version.endsWith("*")) // star means rest of parts irrelevant: truncate them maxLength = parts.size(); - List<List<String>> versions = new ArrayList<List<String>>(); + List<List<String>> versions = new ArrayList<>(); versions.add(subparts); versions.add(parts); normalize(versions, maxLength); @@ -227,14 +228,11 @@ if (equal(subparts, parts)) return true; - if (version.endsWith("+") && greater(subparts, parts)) - return true; - - return false; + return version.endsWith("+") && greater(subparts, parts); } /** - * Returns whether the parts of one version are equal to the + * @return whether the parts of one version are equal to the * parts of another version. * * @param parts1 normalized version parts @@ -250,7 +248,7 @@ } /** - * Returns whether the parts of one version are greater than + * @return whether the parts of one version are greater than * the parts of another version. * * @param parts1 normalized version parts @@ -288,8 +286,8 @@ * @return comparison of the two parts */ protected int compare(String part1, String part2) { - Integer number1 = Integer.valueOf(0); - Integer number2 = Integer.valueOf(0); + Integer number1 = 0; + Integer number2 = 0; // compare as integers // for normalization key, compare exact object, not using .equals @@ -340,10 +338,10 @@ } /** - * Return the individual version strings that make up a Version. + * @return the individual version strings that make up a Version. */ protected List<String> getVersionStrings() { - ArrayList<String> strings = new ArrayList<String>(); + ArrayList<String> strings = new ArrayList<>(); StringTokenizer st = new StringTokenizer(versionString, " "); while (st.hasMoreTokens()) @@ -353,12 +351,12 @@ } /** - * Return the constituent parts of a version string. + * @return the constituent parts of a version string. * * @param oneVersion a single version id string (not compound) */ protected List<String> getParts(String oneVersion) { - ArrayList<String> strings = new ArrayList<String>(); + ArrayList<String> strings = new ArrayList<>(); StringTokenizer st = new StringTokenizer(oneVersion, seperators + "+*"); while (st.hasMoreTokens()) { @@ -368,6 +366,7 @@ return strings; } + @Override public String toString() { return versionString; }
--- a/netx/net/sourceforge/jnlp/XmlParser.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/XmlParser.java Thu Apr 16 19:34:18 2015 +0200 @@ -67,7 +67,7 @@ * * @param input the {@link InputStream} containing the XML * @return a {@link Node} representing the root of the parsed XML - * @throws ParseException + * @throws ParseException if parsing fails */ public Node getRootNode(InputStream input) throws ParseException { @@ -101,6 +101,7 @@ // it to the parser. new Thread( new Runnable() { + @Override public void run() { (new XMLElement()).sanitizeInput(isr, pout); try {
--- a/netx/net/sourceforge/jnlp/cache/CacheDirectory.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/CacheDirectory.java Thu Apr 16 19:34:18 2015 +0200 @@ -70,7 +70,7 @@ * @return An ArrayList of DirectoryNode. */ public static ArrayList<DirectoryNode> getLeafData(DirectoryNode root) { - ArrayList<DirectoryNode> temp = new ArrayList<DirectoryNode>(); + ArrayList<DirectoryNode> temp = new ArrayList<>(); for (DirectoryNode f : root.getChildren()) { if (f.isDir()) temp.addAll(getLeafData(f)); @@ -104,13 +104,13 @@ /** * This will recursively remove the parent folders if they are empty. * - * @param fileNode + * @param fileNode node of file which parent is going to be cleaned */ public static void cleanParent(DirectoryNode fileNode) { DirectoryNode parent = fileNode.getParent(); if (parent.getParent() == null) return; // Don't delete the root. - if (parent.getChildren().size() == 0) { + if (parent.getChildren().isEmpty()) { FileUtils.deleteWithErrMesg(parent.getFile()); parent.getParent().removeChild(parent); cleanParent(parent);
--- a/netx/net/sourceforge/jnlp/cache/CacheEntry.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/CacheEntry.java Thu Apr 16 19:34:18 2015 +0200 @@ -120,6 +120,7 @@ /** * Set the length of the original content that was cached. May be different * from the actual cache entry size due to (de)compression. + * @param contentLength length of content */ public void setOriginalContentLength(long contentLength) { setLongKey(KEY_CONTENT_ORIGINAL_LENGTH, contentLength);
--- a/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/CacheLRUWrapper.java Thu Apr 16 19:34:18 2015 +0200 @@ -317,7 +317,7 @@ /** * Return the value of given key. * - * @param key + * @param key key of property * @return value of given key, null otherwise. */ public synchronized String getValue(String key) {
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java Thu Apr 16 19:34:18 2015 +0200 @@ -91,8 +91,8 @@ /** * This is returning File object of cached resource originally from URL * @param location original location of blob - * @param version - * @param policy + * @param version version of resource + * @param policy update policy of resource * @return location in ITW cache on filesystem */ public static File getCachedResourceFile(URL location, Version version, UpdatePolicy policy) { @@ -210,7 +210,7 @@ * * @param source the source {@link URL} * @param version the versions to check for - * @param lastModifed + * @param lastModifed time in milis since epoch of last modfication * @return whether the cache contains the version * @throws IllegalArgumentException if the source is not cacheable */ @@ -265,12 +265,12 @@ if (source == null) return false; - if (source.getProtocol().equals("file")) + if (source.getProtocol().equals("file")){ return false; - - if (source.getProtocol().equals("jar")) + } + if (source.getProtocol().equals("jar")){ return false; - + } return true; } @@ -350,10 +350,11 @@ /** * Returns the parent directory of the cached resource. * @param filePath The path of the cached resource directory. + * @return parent dir of cache */ public static String getCacheParentDirectory(String filePath) { String path = filePath; - String tempPath = ""; + String tempPath; String cacheDir = CacheLRUWrapper.getInstance().getCacheDir().getFullPath(); while(path.startsWith(cacheDir) && !path.equals(cacheDir)){ @@ -416,7 +417,8 @@ * * @param source the remote location * @param version the file version to write to - * @return the stream towrite to resource + * @return the stream to write to resource + * @throws java.io.IOException if IO breaks */ public static OutputStream getOutputStream(URL source, Version version) throws IOException { File localFile = getCacheFile(source, version);
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java Thu Apr 16 19:34:18 2015 +0200 @@ -80,15 +80,17 @@ } /** - * Return the update rate. + * @return the update rate. */ + @Override public int getUpdateRate() { return 150; //ms } /** - * Return the initial delay before obtaining a listener. + * @return the initial delay before obtaining a listener. */ + @Override public int getInitialDelay() { return 300; //ms } @@ -100,7 +102,9 @@ * @param app the downloading application, or null if N/A * @param downloadName name identifying the download to the user * @param resources initial urls to display (not required) + * @return donload service listener attached to this app. instance */ + @Override public DownloadServiceListener getListener(ApplicationInstance app, String downloadName, URL resources[]) { DownloadPanel result = new DownloadPanel(downloadName); @@ -154,11 +158,13 @@ * calling the getDownloadListener method from the shared * download info window. */ + @Override public void disposeListener(final DownloadServiceListener listener) { if (!(listener instanceof DownloadPanel)) return; ActionListener hider = new ActionListener() { + @Override public void actionPerformed(ActionEvent evt) { synchronized(dialogMutex) { dialog.getContentPane().remove((DownloadPanel) listener); @@ -203,15 +209,15 @@ /** used instead of detailsButton button in case of one jar*/ private JLabel delimiter = new JLabel(""); /** all already created progress bars*/ - private List<ProgressPanel> progressPanels = new ArrayList<ProgressPanel>(); + private List<ProgressPanel> progressPanels = new ArrayList<>(); private States state=States.ONE_JAR; private ProgressPanel mainProgressPanel; /** list of URLs being downloaded */ - private List<URL> urls = new ArrayList<URL>(); + private List<URL> urls = new ArrayList<>(); /** list of ProgressPanels */ - private List<ProgressPanel> panels = new ArrayList<ProgressPanel>(); + private List<ProgressPanel> panels = new ArrayList<>(); /** * Create a new download panel for with the specified download @@ -309,6 +315,7 @@ final long readSoFar, final long total, final int overallPercent) { Runnable r = new Runnable() { + @Override public void run() { if (!urls.contains(url)) addProgressPanel(url, version); @@ -351,6 +358,7 @@ /** * Called when a download failed. */ + @Override public void downloadFailed(URL url, String version) { update(url, version, -1, -1, -1); } @@ -358,6 +366,7 @@ /** * Called when a download has progressed. */ + @Override public void progress(URL url, String version, long readSoFar, long total, int overallPercent) { update(url, version, readSoFar, total, overallPercent); } @@ -365,6 +374,7 @@ /** * Called when an archive is patched. */ + @Override public void upgradingArchive(URL url, String version, int patchPercent, int overallPercent) { update(url, version, patchPercent, 100, overallPercent); } @@ -372,6 +382,7 @@ /** * Called when a download is being validated. */ + @Override public void validating(URL url, String version, long entry, long total, int overallPercent) { update(url, version, entry, total, overallPercent); } @@ -382,11 +393,11 @@ * A progress bar with the URL next to it. */ static class ProgressPanel extends JPanel { - private JPanel bar = new JPanel(); + final private JPanel bar = new JPanel(); private long total; private long readSoFar; - private Dimension size = new Dimension(80, 15); + final private Dimension size = new Dimension(80, 15); ProgressPanel() { bar.setMinimumSize(size); @@ -427,6 +438,7 @@ this.total = total; } + @Override public void paintComponent(Graphics g) { super.paintComponent(g);
--- a/netx/net/sourceforge/jnlp/cache/DownloadIndicator.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/DownloadIndicator.java Thu Apr 16 19:34:18 2015 +0200 @@ -44,6 +44,7 @@ * @param app JNLP application downloading the files, or null if not applicable * @param downloadName name identifying the download to the user * @param resources initial urls to display, empty if none known at start + * @return dedicated listener */ public DownloadServiceListener getListener(ApplicationInstance app, String downloadName,
--- a/netx/net/sourceforge/jnlp/cache/NativeLibraryStorage.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/NativeLibraryStorage.java Thu Apr 16 19:34:18 2015 +0200 @@ -10,7 +10,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; -import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.FileUtils; import net.sourceforge.jnlp.util.logging.OutputController; @@ -20,8 +19,8 @@ * Be sure to call cleanupTemporayFolder when finished with the object. */ public class NativeLibraryStorage { - private ResourceTracker tracker; - private List<File> nativeSearchDirectories = new ArrayList<File>(); + private final ResourceTracker tracker; + private final List<File> nativeSearchDirectories = new ArrayList<>(); /* Temporary directory to store native jar entries, added to our search path */ private File jarEntryDirectory = null; @@ -52,6 +51,7 @@ /** * Adds the {@link File} to the search path of this {@link NativeLibraryStorage} * when trying to find a native library + * @param directory directory to be added */ public void addSearchDirectory(File directory) { nativeSearchDirectories.add(directory); @@ -64,7 +64,8 @@ /** * Looks in the search directories for 'fileName', * returning a path to the found file if it exists. - * Returns null otherwise. + * @param fileName name of library to be found + * @return path to library if found, null otherwise. */ public File findLibrary(String fileName) { for (File dir : getSearchDirectories()) { @@ -81,6 +82,7 @@ * Search for and enable any native code contained in a JAR by copying the * native files into the filesystem. Called in the security context of the * classloader. + * @param jarLocation location of jar to be searched */ public void addSearchJar(URL jarLocation) { OutputController.getLogger().log("Activate native: " + jarLocation); @@ -89,40 +91,39 @@ return; try { - JarFile jarFile = new JarFile(localFile, false); - Enumeration<JarEntry> entries = jarFile.entries(); - - while (entries.hasMoreElements()) { - JarEntry e = entries.nextElement(); - - if (e.isDirectory()) { - continue; + try (JarFile jarFile = new JarFile(localFile, false)) { + Enumeration<JarEntry> entries = jarFile.entries(); + + while (entries.hasMoreElements()) { + JarEntry e = entries.nextElement(); + + if (e.isDirectory()) { + continue; + } + + String name = new File(e.getName()).getName(); + boolean isLibrary = false; + + for (String suffix : NATIVE_LIBRARY_EXTENSIONS) { + if (name.endsWith(suffix)) { + isLibrary = true; + break; + } + } + if (!isLibrary) { + continue; + } + + ensureNativeStoreDirectory(); + + File outFile = new File(jarEntryDirectory, name); + if (!outFile.isFile()) { + FileUtils.createRestrictedFile(outFile, true); + } + CacheUtil.streamCopy(jarFile.getInputStream(e), + new FileOutputStream(outFile)); } - - String name = new File(e.getName()).getName(); - boolean isLibrary = false; - - for (String suffix : NATIVE_LIBRARY_EXTENSIONS) { - if (name.endsWith(suffix)) { - isLibrary = true; - break; - } - } - if (!isLibrary) { - continue; - } - - ensureNativeStoreDirectory(); - - File outFile = new File(jarEntryDirectory, name); - if (!outFile.isFile()) { - FileUtils.createRestrictedFile(outFile, true); - } - CacheUtil.streamCopy(jarFile.getInputStream(e), - new FileOutputStream(outFile)); } - - jarFile.close(); } catch (IOException ex) { OutputController.getLogger().log(ex); }
--- a/netx/net/sourceforge/jnlp/cache/Resource.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/Resource.java Thu Apr 16 19:34:18 2015 +0200 @@ -161,7 +161,7 @@ /** * Set the url to use for downloading the resource - * @param downloadLocation + * @param downloadLocation url to be donloaded */ public void setDownloadLocation(URL downloadLocation) { this.downloadLocation = downloadLocation; @@ -183,7 +183,7 @@ } /** - * Returns the local file currently being downloaded + * @return the local file currently being downloaded */ public File getLocalFile() { return localFile; @@ -191,20 +191,21 @@ /** * Sets the local file to be downloaded + * @param localFile location of stored resource */ public void setLocalFile(File localFile) { this.localFile = localFile; } /** - * Returns the requested version + * @return the requested version */ public Version getRequestVersion() { return requestVersion; } /** - * Returns the version downloaded from server + * @return the version downloaded from server */ public Version getDownloadVersion() { return downloadVersion; @@ -212,13 +213,14 @@ /** * Sets the version downloaded from server + * @param downloadVersion version of downloaded resource */ public void setDownloadVersion(Version downloadVersion) { this.downloadVersion = downloadVersion; } /** - * Returns the amount in bytes transferred + * @return the amount in bytes transferred */ public long getTransferred() { return transferred; @@ -226,6 +228,7 @@ /** * Sets the amount transferred + * @param transferred set the whole transfered amount to this value */ public void setTransferred(long transferred) { this.transferred = transferred; @@ -233,6 +236,7 @@ /** * Increments the amount transferred (in bytes) + * @param incTrans transfered amount in last transfer */ public void incrementTransferred(long incTrans) { transferred += incTrans; @@ -248,13 +252,14 @@ /** * Sets the size of the resource + * @param size desired size of resource */ public void setSize(long size) { this.size = size; } /** - * Returns the status of the resource + * @return the status of the resource */ public Set<Status> getCopyOfStatus() { return EnumSet.copyOf(status); @@ -284,7 +289,7 @@ } /** - * Returns the update policy for this resource + * @return the update policy for this resource */ public UpdatePolicy getUpdatePolicy() { return this.updatePolicy; @@ -378,6 +383,8 @@ /** * Removes the tracker to the list of trackers monitoring this * resource. + * + * @param tracker tracker to be removed */ public void removeTracker(ResourceTracker tracker) { synchronized (trackers) {
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Thu Apr 16 19:34:18 2015 +0200 @@ -136,6 +136,7 @@ * * @param location the location of the resource * @param version the resource version + * @param options options to control download * @param updatePolicy whether to check for updates if already in cache */ public void addResource(URL location, Version version, DownloadOptions options, UpdatePolicy updatePolicy) { @@ -384,17 +385,17 @@ * @throws IllegalResourceDescriptorException if the resource is not being tracked */ public boolean waitForResources(URL urls[], long timeout) throws InterruptedException { - Resource resources[] = new Resource[urls.length]; + Resource lresources[] = new Resource[urls.length]; - synchronized (resources) { + synchronized (lresources) { // keep the lock so getResource doesn't have to aquire it each time for (int i = 0; i < urls.length; i++) { - resources[i] = getResource(urls[i]); + lresources[i] = getResource(urls[i]); } } - if (resources.length > 0) - return wait(resources, timeout); + if (lresources.length > 0) + return wait(lresources, timeout); return true; } @@ -504,6 +505,7 @@ * <p> * Calls to this method should be synchronized on lock. * </p> + * @param resource resource to be download */ protected void startDownloadThread(Resource resource) { CachedDaemonThreadPoolProvider.DAEMON_THREAD_POOL.execute(new ResourceDownloader(resource, lock));
--- a/netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java Thu Apr 16 19:34:18 2015 +0200 @@ -38,14 +38,9 @@ package net.sourceforge.jnlp.cache; import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; import java.net.URL; -import java.net.URLDecoder; -import java.net.URLEncoder; import java.util.LinkedList; import java.util.List; -import java.io.UnsupportedEncodingException; import net.sourceforge.jnlp.DownloadOptions; @@ -66,8 +61,8 @@ * @return a list of URLs that the resources might be downloadable from */ public List<URL> getUrls() { - List<URL> urls = new LinkedList<URL>(); - URL url = null; + List<URL> urls = new LinkedList<>(); + URL url; if (downloadOptions.useExplicitPack() && downloadOptions.useExplicitVersion()) { url = getUrl(resource, true, true); @@ -129,7 +124,7 @@ sb.append(parts[i]); // Append __V<number> before last '.' if (i == parts.length -2) { - sb.append("__V" + resource.getRequestVersion()); + sb.append("__V").append(resource.getRequestVersion()); } sb.append('.'); } @@ -152,6 +147,7 @@ /** * Returns the URL for this resource, including the resource's version number in the query string + * @return url with version cared about */ protected URL getVersionedUrl() { URL resourceUrl = resource.getLocation();
--- a/netx/net/sourceforge/jnlp/cache/UpdatePolicy.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/cache/UpdatePolicy.java Thu Apr 16 19:34:18 2015 +0200 @@ -60,17 +60,15 @@ } /** - * Returns whether the resource should be checked for being + * @return whether the resource should be checked for being * up-to-date. + * @param entry entry which shoul;d be cared */ public boolean shouldUpdate(CacheEntry entry) { long updated = entry.getLastUpdated(); long current = System.currentTimeMillis(); - if (current - updated >= timeDiff) - return true; - else - return false; + return current - updated >= timeDiff; } }
--- a/netx/net/sourceforge/jnlp/config/BasicValueValidators.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/config/BasicValueValidators.java Thu Apr 16 19:34:18 2015 +0200 @@ -334,6 +334,7 @@ * one), within the given range. The values are inclusive. * @param low the lowest valid value * @param high the highest valid value + * @return value validator for given range */ public static ValueValidator getRangedIntegerValidator(int low, int high) { return new RangedIntegerValidator(low, high); @@ -343,6 +344,7 @@ * Returns a {@link ValueValidator} that checks if an object is a string from * one of the provided Strings. * @param validValues an array of Strings which are considered valid + * @return validator for given strings */ public static ValueValidator getStringValidator(String[] validValues) { return new StringValueValidator(validValues); @@ -355,13 +357,14 @@ * @param singleValues an array of Strings which are considered valid only by themselves * @param comboValues an array of Strings which are considered valid in any combination * with themselves + * @return validator forgiven strings */ public static ValueValidator getMultipleStringValidator(String[] singleValues, String[] comboValues) { return new MultipleStringValueValidator(singleValues, comboValues); } /** - * Returns a {@link ValueValidator} that checks if an object is a string + * @return a {@link ValueValidator} that checks if an object is a string * from the possible single or combination ManifestAttributeCheck values */ public static ValueValidator getManifestAttributeCheckValidator() {
--- a/netx/net/sourceforge/jnlp/config/Defaults.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/config/Defaults.java Thu Apr 16 19:34:18 2015 +0200 @@ -55,6 +55,7 @@ /** * Get the default settings for deployment + * @return the default settings for deployment */ public static Map<String, Setting<String>> getDefaults() { SecurityManager sm = System.getSecurityManager();
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java Thu Apr 16 19:34:18 2015 +0200 @@ -337,6 +337,7 @@ /** * Copies the current configuration into the target + * @param target properties where to copy actual ones */ public void copyTo(Properties target) { Set<String> names = getAllPropertyNames();
--- a/netx/net/sourceforge/jnlp/config/DirectoryValidator.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/config/DirectoryValidator.java Thu Apr 16 19:34:18 2015 +0200 @@ -28,7 +28,7 @@ /** * Wraps results so we can make some statistics or convert to message - * @param results + * @param results results to be checked */ public DirectoryCheckResults(List<DirectoryCheckResult> results) { this.results = results; @@ -136,6 +136,7 @@ /** * count passes of this result (0-3, both inclusive). + * @return how many times it passed */ public int getPasses() { int subdirs = 0; @@ -150,6 +151,7 @@ /** * count failures of this result (0-3, both inclusive). + * @return how many failures appeared */ public int getFailures() { int max = 3; @@ -200,7 +202,7 @@ /** * Creates DirectoryValidator to ensure given directories * - * @param dirsToCheck + * @param dirsToCheck dirs to check */ public DirectoryValidator(List<File> dirsToCheck) { this.dirsToCheck = dirsToCheck; @@ -220,7 +222,7 @@ * </ul> */ public DirectoryValidator() { - dirsToCheck = new ArrayList<File>(6); + dirsToCheck = new ArrayList<>(6); DeploymentConfiguration dc = JNLPRuntime.getConfiguration(); String[] keys = new String[]{ DeploymentConfiguration.KEY_USER_CACHE_DIR, @@ -257,13 +259,14 @@ * (both gui and headless) should not stop to work, but continue to run with * hope that corrupted dirs will not be necessary * </p> + * @return result of directory checks */ public DirectoryCheckResults ensureDirs() { return ensureDirs(dirsToCheck); } static DirectoryCheckResults ensureDirs(List<File> dirs) { - List<DirectoryCheckResult> result = new ArrayList<DirectoryCheckResult>(dirs.size()); + List<DirectoryCheckResult> result = new ArrayList<>(dirs.size()); for (File f : dirs) { if (f.exists()) { DirectoryCheckResult r = testDir(f, true, true);
--- a/netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/config/InfrastructureFileDescriptor.java Thu Apr 16 19:34:18 2015 +0200 @@ -86,8 +86,9 @@ /** * overload version for control panel, which is saving to internal copy. - * @param value - * @param config + * @param value new path of file + * @param config config where t write this value (note, usually JNLPRuntime.getConfiguration() + * so you don't need it, but our config gui tool is using two sets to allow undo. */ public void setValue(String value, DeploymentConfiguration config) { String key = getPropertiesKey(); @@ -100,8 +101,9 @@ /** * overload version for control panel, which is saving to internal copy. - * @param config - * @return + * @param config config from where to readthis value (note, usually JNLPRuntime.getConfiguration() + * so you don't need it, but our config gui tool is using two sets to allow undo. + * @return configured property or default */ public String getFullPath(DeploymentConfiguration config) { String key = getPropertiesKey(); @@ -156,7 +158,7 @@ * For documentation purposes, the descriptor may be created as VARIABLE/custom/path. * * This is whole part, which is considered as setup-able. - * @return + * @return directory acronym for nice docs */ public String getDirViaAcronym() { return clean(getSystemPathStubAcronym() + File.separator + pathStub);
--- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java Thu Apr 16 19:34:18 2015 +0200 @@ -88,6 +88,7 @@ * Creates a new instance of the CachePane. * * @param parent The parent dialog that uses this pane. + * @param config configuration tobe worked on */ public CachePane(JDialog parent, DeploymentConfiguration config) { super(new BorderLayout()); @@ -127,7 +128,7 @@ cacheTable.setFillsViewportHeight(true); JScrollPane scrollPane = new JScrollPane(cacheTable); - TableRowSorter<TableModel> tableSorter = new TableRowSorter<TableModel>(model); + TableRowSorter<TableModel> tableSorter = new TableRowSorter<>(model); final Comparator<Comparable<?>> comparator = new Comparator<Comparable<?>>() { // General purpose Comparator @Override @SuppressWarnings("unchecked") @@ -187,7 +188,7 @@ JPanel leftPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); - List<JButton> buttons = new ArrayList<JButton>(); + List<JButton> buttons = new ArrayList<>(); this.deleteButton = new JButton(Translator.R("CVCPButDelete")); deleteButton.addActionListener(new ActionListener() { @@ -418,7 +419,7 @@ private ArrayList<Object[]> generateData(DirectoryNode root) { root = new DirectoryNode("Root", location, null); CacheDirectory.getDirStructure(root); - ArrayList<Object[]> data = new ArrayList<Object[]>(); + ArrayList<Object[]> data = new ArrayList<>(); for (DirectoryNode identifier : root.getChildren()) { for (DirectoryNode type : identifier.getChildren()) {
--- a/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java Thu Apr 16 19:34:18 2015 +0200 @@ -76,6 +76,7 @@ /** * Creates a new instance + * @param optionParser used to parse applications arguments */ public CommandLine(OptionParser optionParser) { this.optionParser = optionParser; @@ -491,6 +492,7 @@ /** * The starting point of the program * @param args the command line arguments to this program + * @throws java.lang.Exception when it goes wrong */ public static void main(String[] args) throws Exception { try {
--- a/netx/net/sourceforge/jnlp/event/ApplicationEvent.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/event/ApplicationEvent.java Thu Apr 16 19:34:18 2015 +0200 @@ -29,7 +29,7 @@ public class ApplicationEvent extends EventObject { /** the application instance */ - transient private ApplicationInstance application; + final transient private ApplicationInstance application; /** * Creates a launch event for the specified application @@ -44,7 +44,7 @@ } /** - * Returns the application instance. + * @return the application instance. */ public ApplicationInstance getApplication() { return application;
--- a/netx/net/sourceforge/jnlp/event/ApplicationListener.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/event/ApplicationListener.java Thu Apr 16 19:34:18 2015 +0200 @@ -29,6 +29,7 @@ /** * Invoked when the application is destroyed. + * @param applicationEvent information about destruction */ public void applicationDestroyed(ApplicationEvent applicationEvent);
--- a/netx/net/sourceforge/jnlp/event/DownloadEvent.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/event/DownloadEvent.java Thu Apr 16 19:34:18 2015 +0200 @@ -31,10 +31,10 @@ public class DownloadEvent extends EventObject { /** the tracker */ - transient private ResourceTracker tracker; + final transient private ResourceTracker tracker; /** the resource */ - transient private Resource resource; + final transient private Resource resource; /** * Creates a launch event for the specified application @@ -51,14 +51,14 @@ } /** - * Returns the tracker that owns the resource. + * @return the tracker that owns the resource. */ public ResourceTracker getTracker() { return tracker; } /** - * Returns the location of the resource being downloaded. + * @return the location of the resource being downloaded. */ public URL getResourceLocation() { return resource.getLocation();
--- a/netx/net/sourceforge/jnlp/event/DownloadListener.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/event/DownloadListener.java Thu Apr 16 19:34:18 2015 +0200 @@ -32,16 +32,19 @@ /** * Called when a resource is checked for being up-to-date. + * @param downloadEvent information about started update */ public void updateStarted(DownloadEvent downloadEvent); /** * Called when a download starts. + * @param downloadEvent information about started download */ public void downloadStarted(DownloadEvent downloadEvent); /** * Called when a download completed or there was an error. + * @param downloadEvent information about finished download */ public void downloadCompleted(DownloadEvent downloadEvent);
--- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java Thu Apr 16 19:34:18 2015 +0200 @@ -55,7 +55,7 @@ private Container cont; /** weak references to the audio clips */ - private WeakList<AppletAudioClip> weakClips = new WeakList<AppletAudioClip>(); + private final WeakList<AppletAudioClip> weakClips = new WeakList<>(); /** whether the applet has been started / displayed */ private boolean appletStarted = false; @@ -66,6 +66,9 @@ /** * Create a new applet environment for the applet specified by * the JNLP file. + * @param file jnlp file base to construct environment + * @param appletInstance applet for this environment + * @param cont container to place this applet to */ public AppletEnvironment(JNLPFile file, final AppletInstance appletInstance, Container cont) { this.file = file; @@ -78,6 +81,8 @@ /** * Create a new applet environment for the applet specified by * the JNLP file, in a new frame. + * @param file jnlp file base to construct environment + * @param appletInstance applet for this environment */ public AppletEnvironment(JNLPFile file, final AppletInstance appletInstance) { this(file, appletInstance, null); @@ -126,7 +131,7 @@ } /** - * Returns the frame that contains the applet. Disposing this + * @return the frame that contains the applet. Disposing this * frame will destroy the applet. */ public Container getAppletFrame() { @@ -135,8 +140,8 @@ } /** - * container must be SplashContoler - * + * container must be SplashContoler. + * @return container */ public SplashController getSplashController() { if (cont instanceof SplashController) { @@ -198,10 +203,8 @@ cont.repaint(); } }); - } catch (InterruptedException ie) { - - } catch (InvocationTargetException ite) { - + } catch (InterruptedException | InvocationTargetException ie) { + OutputController.getLogger().log(ie); } } catch (Exception ex) { OutputController.getLogger().log(ex); @@ -229,6 +232,7 @@ /** * Set the applet of this environment; can only be called once. + * @param applet source of this environment */ public void setApplet(Applet applet) { if (this.applet != null) { @@ -250,7 +254,8 @@ } /** - * Returns an audio clip. + * @param location source of clip + * @return an audio clip. */ @Override public AudioClip getAudioClip(URL location) { @@ -265,7 +270,8 @@ } /** - * Return an image loaded from the specified location. + * @return an image loaded from the specified location. + * @param location location of image */ @Override public Image getImage(URL location) { @@ -279,6 +285,7 @@ /** * Not implemented yet. + * @param uRL url of document */ @Override public void showDocument(java.net.URL uRL) { @@ -288,6 +295,8 @@ /** * Not implemented yet. + * @param uRL source of document + * @param str who know what */ @Override public void showDocument(java.net.URL uRL, java.lang.String str) { @@ -297,6 +306,7 @@ /** * Not implemented yet. + * @param str id of applet */ @Override public void showStatus(java.lang.String str) {
--- a/netx/net/sourceforge/jnlp/runtime/AppletInstance.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/AppletInstance.java Thu Apr 16 19:34:18 2015 +0200 @@ -39,10 +39,14 @@ private Applet applet; /** the applet environment */ - private AppletEnvironment environment; + final private AppletEnvironment environment; /** * Create a New Task based on the Specified URL + * @param file pluginbrifge to build instance on + * @param group thread group of this instance + * @param loader classlaoder for this instance + * @param applet applet of this instance */ public AppletInstance(JNLPFile file, ThreadGroup group, ClassLoader loader, Applet applet) { super(file, group, loader); @@ -54,6 +58,7 @@ /** * Set the applet of this launched application; can only be called once. + * @param applet to be set */ public void setApplet(Applet applet) { if (this.applet != null) { @@ -64,7 +69,12 @@ } /** - * + * Create a New Task based on the Specified URL + * @param file pluginbrifge to build instance on + * @param group thread group of this instance + * @param loader classlaoder for this instance + * @param applet applet of this instance + * @param cont Container where to place applet */ public AppletInstance(JNLPFile file, ThreadGroup group, ClassLoader loader, Applet applet, Container cont) { super(file, group, loader); @@ -75,6 +85,7 @@ /** * Sets whether the applet is resizable or not. Applets default * to being not resizable. + * @param resizable boolean to allwo resizing */ public void setResizable(boolean resizable) { Container c = environment.getAppletFrame(); @@ -83,7 +94,7 @@ } /** - * Returns whether the applet is resizable. + * @return whether the applet is resizable. */ public boolean isResizable() { Container c = environment.getAppletFrame(); @@ -94,21 +105,22 @@ } /** - * Returns the application title. + * @return the application title. */ + @Override public String getTitle() { return getJNLPFile().getApplet().getName(); } /** - * Returns the applet environment. + * @return the applet environment. */ public AppletEnvironment getAppletEnvironment() { return environment; } /** - * Returns the applet. + * @return the applet. */ public Applet getApplet() { return applet; @@ -117,6 +129,7 @@ /** * Stop the application and destroy its resources. */ + @Override public void destroy() { if (appletStopped) return;
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java Thu Apr 16 19:34:18 2015 +0200 @@ -386,7 +386,7 @@ } /** - * Returns whether or not this application is signed. + * @return whether or not this application is signed. */ public boolean isSigned() { return isSigned;
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/Boot.java Thu Apr 16 19:34:18 2015 +0200 @@ -93,6 +93,7 @@ /** * Launch the JNLP file specified by the command-line arguments. + * @param argsIn launching arguments */ public static void main(String[] argsIn) throws UnevenParameterException { optionParser = new OptionParser(argsIn, OptionsDefinitions.getJavaWsOptions()); @@ -227,9 +228,10 @@ /** * The privileged part (jdk1.3 compatibility). */ + @Override public Void run() { - Map<String, List<String>> extra = new HashMap<String, List<String>>(); + Map<String, List<String>> extra = new HashMap<>(); if (optionParser.hasOption(OptionsDefinitions.OPTIONS.HTML)) { boolean run = new HtmlBoot(optionParser).run(extra);
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Thu Apr 16 19:34:18 2015 +0200 @@ -229,6 +229,8 @@ * Create a new JNLPClassLoader from the specified file. * * @param file the JNLP file + * @param policy update policy of loader + * @throws net.sourceforge.jnlp.LaunchException if app can not be loaded */ protected JNLPClassLoader(JNLPFile file, UpdatePolicy policy) throws LaunchException { this(file, policy, null, false); @@ -393,6 +395,9 @@ * * @param file the file to load classes for * @param policy the update policy to use when downloading resources + * @param enableCodeBase true if codebase can be searched (ok for applets,false for apps) + * @return existing classloader. creates new if none reliable exists + * @throws net.sourceforge.jnlp.LaunchException when launch is doomed */ public static JNLPClassLoader getInstance(JNLPFile file, UpdatePolicy policy, boolean enableCodeBase) throws LaunchException { return getInstance(file, policy, null, enableCodeBase); @@ -404,6 +409,9 @@ * @param file the file to load classes for * @param policy the update policy to use when downloading resources * @param mainName Overrides the main class name of the application + * @param enableCodeBase ue if codebase can be searched (ok for applets,false for apps) + * @return existing classloader. creates new if none reliable exists + * @throws net.sourceforge.jnlp.LaunchException when launch is doomed */ public static JNLPClassLoader getInstance(JNLPFile file, UpdatePolicy policy, String mainName, boolean enableCodeBase) throws LaunchException { JNLPClassLoader loader; @@ -447,9 +455,16 @@ * location. * * @param location the file's location + * @param uniqueKey key to manage applets/applications in shared vm * @param version the file's version + * @param settings settings of parser * @param policy the update policy to use when downloading resources * @param mainName Overrides the main class name of the application + * @param enableCodeBase whether to enable codebase search or not + * @return classlaoder of this appp + * @throws java.io.IOException when IO fails + * @throws net.sourceforge.jnlp.ParseException when parsing fails + * @throws net.sourceforge.jnlp.LaunchException when launch is doomed */ public static JNLPClassLoader getInstance(URL location, String uniqueKey, Version version, ParserSettings settings, UpdatePolicy policy, String mainName, boolean enableCodeBase) throws IOException, ParseException, LaunchException { @@ -794,6 +809,7 @@ * * @param jars Jars that are checked to see if they contain the main class * @param name attribute to be found + * @return value of attribute if found */ public String checkForAttributeInJars(List<JARDesc> jars, Attributes.Name name) { if (jars.isEmpty()) { @@ -905,6 +921,7 @@ * Gets the name of the main method if specified in the manifest * * @param location The JAR location + * @param attribute name of the attribute to find * @return the attribute value, null if there isn't one of if there was an error */ public String getManifestAttribute(URL location, Attributes.Name attribute) { @@ -933,7 +950,7 @@ } /** - * Returns true if this loader has the main jar + * @return true if this loader has the main jar */ public boolean hasMainJar() { return this.foundMainJar; @@ -1085,6 +1102,7 @@ /** * Sets the JNLP app this group is for; can only be called once. + * @param app application to be ser to this group */ public void setApplication(ApplicationInstance app) { if (this.app != null) { @@ -1096,14 +1114,14 @@ } /** - * Returns the JNLP app for this classloader + * @return the JNLP app for this classloader */ public ApplicationInstance getApplication() { return app; } /** - * Returns the JNLP file the classloader was created from. + * @return the JNLP file the classloader was created from. */ public JNLPFile getJNLPFile() { return file; @@ -1188,6 +1206,7 @@ * Adds to the specified list of JARS any other JARs that need * to be loaded at the same time as the JARs specified (ie, are * in the same part). + * @param jars jar archives to be added */ protected void fillInPartJars(List<JARDesc> jars) { for (JARDesc desc : jars) { @@ -1367,6 +1386,8 @@ /** * Try to find the library path from another peer classloader. + * @param lib library to be found + * @return location of library */ protected String findLibraryExt(String lib) { for (JNLPClassLoader loader : loaders) { @@ -1402,6 +1423,8 @@ /** * Find the loaded class in this loader or any of its extension loaders. + * @param name name of class + * @return the class found by name */ protected Class<?> findLoadedClassAll(String name) { for (JNLPClassLoader loader : loaders) { @@ -1863,6 +1886,7 @@ // this part compatibility with previous classloader /** + * @return title if available. Substitutions if not. * @deprecated */ @Deprecated @@ -1880,6 +1904,7 @@ } /** + * @return location if jnlp * @deprecated */ @Deprecated
--- a/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPProxySelector.java Thu Apr 16 19:34:18 2015 +0200 @@ -176,6 +176,7 @@ /** * {@inheritDoc} + * @return list of proxies on URI */ @Override public List<Proxy> select(URI uri) { @@ -187,7 +188,7 @@ return proxies; } - List<Proxy> proxies = new ArrayList<Proxy>(); + List<Proxy> proxies = new ArrayList<>(); switch (proxyType) { case PROXY_TYPE_MANUAL: @@ -219,26 +220,23 @@ try { String scheme = uri.getScheme(); /* scheme can be http/https/ftp/socket */ - - if (scheme.equals("http") || scheme.equals("https") || scheme.equals("ftp")) { - URL url = uri.toURL(); - if (bypassLocal && isLocalHost(url.getHost())) { - return true; - } - - if (bypassList.contains(url.getHost())) { + switch (scheme) { + case "http": + case "https": + case "ftp": + URL url = uri.toURL(); + if (bypassLocal && isLocalHost(url.getHost())) { + return true; + } if (bypassList.contains(url.getHost())) { return true; - } - } else if (scheme.equals("socket")) { - String host = uri.getHost(); - - if (bypassLocal && isLocalHost(host)) { + } break; + case "socket": + String host = uri.getHost(); + if (bypassLocal && isLocalHost(host)) { + return true; + } if (bypassList.contains(host)) { return true; - } - - if (bypassList.contains(host)) { - return true; - } + } break; } } catch (MalformedURLException e) { return false; @@ -248,8 +246,9 @@ } /** - * Returns true if the host is the hostname or the IP address of the + * @return true if the host is the hostname or the IP address of the * localhost + * @param host host to verify */ private boolean isLocalHost(String host) { @@ -284,7 +283,7 @@ * Returns a list of proxies by using the information in the deployment * configuration * - * @param uri + * @param uri uri to read * @return a List of Proxy objects */ private List<Proxy> getFromConfiguration(URI uri) { @@ -298,6 +297,17 @@ /** * Returns a list of proxies by using the arguments * + * @param uri name and code says it all + * @param sameProxy name and code says it all + * @param sameProxyIncludesSocket name and code says it all + * @param proxyHttpsHost name and code says it all + * @param proxyHttpsPort name and code says it all + * @param proxyHttpHost name and code says it all + * @param proxyHttpPort name and code says it all + * @param proxyFtpHost name and code says it all + * @param proxyFtpPort name and code says it all + * @param proxySocks4Host name and code says it all + * @param proxySocks4Port name and code says it all * @return a List of Proxy objects */ protected static List<Proxy> getFromArguments(URI uri, @@ -307,7 +317,7 @@ String proxyFtpHost, int proxyFtpPort, String proxySocks4Host, int proxySocks4Port) { - List<Proxy> proxies = new ArrayList<Proxy>(); + List<Proxy> proxies = new ArrayList<>(); String scheme = uri.getScheme(); @@ -342,7 +352,7 @@ socksProxyAdded = true; } - if (proxies.size() == 0) { + if (proxies.isEmpty()) { proxies.add(Proxy.NO_PROXY); } @@ -354,6 +364,7 @@ * http://en.wikipedia.org/wiki/Proxy_auto-config#The_PAC_file for more * information. * + * @param uri uri to PAC * @return a List of valid Proxy objects */ protected List<Proxy> getFromPAC(URI uri) { @@ -361,7 +372,7 @@ return Arrays.asList(new Proxy[] { Proxy.NO_PROXY }); } - List<Proxy> proxies = new ArrayList<Proxy>(); + List<Proxy> proxies = new ArrayList<>(); try { String proxiesString = pacEvaluator.getProxies(uri.toURL()); @@ -391,7 +402,7 @@ * case of malformed input, an empty list may be returned */ public static List<Proxy> getProxiesFromPacResult(String pacString) { - List<Proxy> proxies = new ArrayList<Proxy>(); + List<Proxy> proxies = new ArrayList<>(); String[] tokens = pacString.split(";"); for (String token: tokens) {
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Thu Apr 16 19:34:18 2015 +0200 @@ -184,6 +184,7 @@ * Returns whether the JNLP runtime environment has been * initialized. Once initialized, some properties such as the * base directory cannot be changed. Before + * @return whether this runtime was already initialilsed */ public static boolean isInitialized() { return initialized; @@ -312,7 +313,7 @@ try { Class<?> trustManagerClass; - Constructor<?> tmCtor = null; + Constructor<?> tmCtor; if (System.getProperty("java.version").startsWith("1.6")) { // Java 6 try { @@ -483,7 +484,7 @@ } /** - * Returns true if a webstart application has been initialized, and false + * @return true if a webstart application has been initialized, and false * for a plugin applet. */ public static boolean isWebstartApplication() { @@ -491,7 +492,7 @@ } /** - * Returns whether the JNLP client will use any AWT/Swing + * @return whether the JNLP client will use any AWT/Swing * components. */ public static boolean isHeadless() { @@ -499,7 +500,7 @@ } /** - * Returns whether we are verifying code signing. + * @return whether we are verifying code signing. */ public static boolean isVerifying() { return verify; @@ -511,6 +512,7 @@ * AWT are disabled such that the client can be used in * headless mode ({@code java.awt.headless=true}). * + * @param enabled true if application do not wont/need gui or X at all * @throws IllegalStateException if the runtime was previously initialized */ public static void setHeadless(boolean enabled) { @@ -529,9 +531,11 @@ /** - * Sets whether we will verify code signing. - * @throws IllegalStateException if the runtime was previously initialized - */ + * Sets whether we will verify code signing. + * + * @param enabled true if app should verify signatures + * @throws IllegalStateException if the runtime was previously initialized + */ public static void setVerify(boolean enabled) { checkInitialized(); verify = enabled; @@ -539,6 +543,7 @@ /** * Returns whether the secure runtime environment is enabled. + * @return true if security manager is created */ public static boolean isSecurityEnabled() { return securityEnabled; @@ -580,6 +585,7 @@ * Set a class that can exit the JVM; if not set then any class * can exit the JVM. * + * @param exitClass a class that can exit the JVM * @throws IllegalStateException if caller is not the exit class */ public static void setExitClass(Class<?> exitClass) { @@ -597,7 +603,7 @@ } /** - * Return the current Application, or null if none can be + * @return the current Application, or null if none can be * determined. */ public static ApplicationInstance getApplication() { @@ -605,7 +611,7 @@ } /** - * Return whether debug statements for the JNLP client code + * @return whether debug statements for the JNLP client code * should be printed. */ public static boolean isDebug() { @@ -620,6 +626,7 @@ * Sets whether debug statements for the JNLP client code * should be printed to the standard output. * + * @param enabled set to true if you need full debug output * @throws IllegalStateException if caller is not the exit class */ public static void setDebug(boolean enabled) { @@ -631,6 +638,7 @@ /** * Sets the default update policy. * + * @param policy global update policy of environment * @throws IllegalStateException if caller is not the exit class */ public static void setDefaultUpdatePolicy(UpdatePolicy policy) { @@ -639,7 +647,7 @@ } /** - * Returns the default update policy. + * @return the default update policy. */ public static UpdatePolicy getDefaultUpdatePolicy() { return updatePolicy; @@ -647,6 +655,7 @@ /** * Sets the default launch handler. + * @param handler default handler */ public static void setDefaultLaunchHandler(LaunchHandler handler) { checkExitClass(); @@ -655,6 +664,7 @@ /** * Returns the default launch handler. + * @return default handler */ public static LaunchHandler getDefaultLaunchHandler() { return handler; @@ -663,6 +673,7 @@ /** * Sets the default download indicator. * + * @param indicator where to show progress * @throws IllegalStateException if caller is not the exit class */ public static void setDefaultDownloadIndicator(DownloadIndicator indicator) { @@ -671,7 +682,7 @@ } /** - * Returns the default download indicator. + * @return the default download indicator. */ public static DownloadIndicator getDefaultDownloadIndicator() { return indicator; @@ -682,7 +693,7 @@ } /** - * Returns {@code true} if the current runtime will fork + * @return {@code true} if the current runtime will fork */ public static boolean getForksAllowed() { return forksAllowed; @@ -767,11 +778,8 @@ if (!netxRunningFile.exists()) { FileUtils.createParentDir(netxRunningFile); FileUtils.createRestrictedFile(netxRunningFile, true); - FileOutputStream fos = new FileOutputStream(netxRunningFile); - try { + try (FileOutputStream fos = new FileOutputStream(netxRunningFile)) { fos.write(message.getBytes()); - } finally { - fos.close(); } } @@ -796,6 +804,7 @@ } Runtime.getRuntime().addShutdownHook(new Thread("JNLPRuntimeShutdownHookThread") { + @Override public void run() { markNetxStopped(); CacheUtil.cleanCache();
--- a/netx/net/sourceforge/jnlp/runtime/ManageJnlpResources.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/ManageJnlpResources.java Thu Apr 16 19:34:18 2015 +0200 @@ -54,13 +54,14 @@ * @param ref Path of the launch or extension JNLP File containing the * resource. If null, main JNLP's file location will be used instead. * @param part The name of the part. + * @param version version of jar * @return jars found. */ public static JARDesc[] findJars(final JNLPClassLoader rootClassLoader, final URL ref, final String part, final Version version) { JNLPClassLoader foundLoader = LocateJnlpClassLoader.getLoaderByJnlpFile(rootClassLoader, ref); if (foundLoader != null) { - List<JARDesc> foundJars = new ArrayList<JARDesc>(); + List<JARDesc> foundJars = new ArrayList<>(); ResourcesDesc resources = foundLoader.getJNLPFile().getResources(); for (JARDesc eachJar : resources.getJARs(part)) { @@ -94,6 +95,7 @@ * @param ref Path of the launch or extension JNLP File containing the * resource. If null, main JNLP's file location will be used instead. * @param part The name of the path. + * @param version version of jar to be downlaoded */ public static void downloadJars(final JNLPClassLoader classLoader, final URL ref, final String part, final Version version) { JNLPClassLoader foundLoader = LocateJnlpClassLoader.getLoaderByJnlpFile(classLoader, ref);
--- a/netx/net/sourceforge/jnlp/runtime/Translator.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/Translator.java Thu Apr 16 19:34:18 2015 +0200 @@ -73,6 +73,8 @@ } /** + * @param message key to be found in properties + * @param params params to be expanded to message * @return the localized string for the message */ public static String R(String message, Object... params) { @@ -81,9 +83,9 @@ /** - * Returns the localized resource string using the specified arguments. - * - * @param args the formatting arguments to the resource string + * @return the localized resource string using the specified arguments. + * @param key key to be found in properties + * @param args params to be expanded to message */ protected String getMessage(String key, Object... args) { return MessageFormat.format(getMessage(key), args);
--- a/netx/net/sourceforge/jnlp/security/AppVerifier.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/AppVerifier.java Thu Apr 16 19:34:18 2015 +0200 @@ -78,13 +78,17 @@ * @param certs Any possible signer and their respective information regarding this app. * @param signedJars A map of all the jars of this app and the number of * signed entries each one has. + * @return true if jar is fully signed */ public boolean isFullySigned(Map<CertPath, CertInformation> certs, Map<String, Integer> signedJars); /** * Prompt the user with requests for trusting the certificates used by this app - * @throws LaunchException + * @param securityDelegate parental security + * @param jcv jar verifier + * @param file jnlp fiel to provide information + * @throws LaunchException if it fails to verify */ public void checkTrustWithUser(SecurityDelegate securityDelegate, JarCertVerifier jcv, JNLPFile file) throws LaunchException;
--- a/netx/net/sourceforge/jnlp/security/CertVerifier.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/CertVerifier.java Thu Apr 16 19:34:18 2015 +0200 @@ -48,40 +48,45 @@ public interface CertVerifier { /** - * Return if the publisher is already trusted + * @return if the publisher is already trusted */ public boolean getAlreadyTrustPublisher(); /** - * Return if the root is in CA certs + * @return if the root is in CA certs */ public boolean getRootInCacerts(); /** - * Return if there are signing issues with the certificate being verified + * @return if there are signing issues with the certificate being verified + * @param certPath to be validated */ public boolean hasSigningIssues(CertPath certPath); /** - * Get the details regarding issue with this certificate + * @return the details regarding issue with this certificate + * @param certPath certificate */ public List<String> getDetails(CertPath certPath); /** - * Return a valid certificate path to this certificate being verified - * @return The CertPath + * @return a valid certificate path to this certificate being verified + * @param certPath to be read */ public CertPath getCertPath(CertPath certPath); /** - * Returns the application's publisher's certificate. + * @return the application's publisher's certificate. + * @param certPath to be read for publisher */ public abstract Certificate getPublisher(CertPath certPath); /** - * Returns the application's root's certificate. This + * @return the application's root's certificate. This * may return the same certificate as getPublisher(CertPath certPath) in * the event that the application is self signed. + * @param certPath certificate + * */ public abstract Certificate getRoot(CertPath certPath); }
--- a/netx/net/sourceforge/jnlp/security/CertificateUtils.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/CertificateUtils.java Thu Apr 16 19:34:18 2015 +0200 @@ -70,6 +70,11 @@ /** * Adds the X509Certficate in the file to the KeyStore. Note that it does * not update the copy of the KeyStore on disk. + * @param file file with certificate + * @param ks keystore to save to + * @throws java.security.cert.CertificateException if certificate is wrong + * @throws java.io.IOException if IO fails + * @throws java.security.KeyStoreException if keystore fails */ public static final void addToKeyStore(File file, KeyStore ks) throws CertificateException, IOException, KeyStoreException { @@ -92,16 +97,17 @@ /** * Adds an X509Certificate to the KeyStore. Note that it does not update the * copy of the KeyStore on disk. + * @param cert certificate to import + * @param ks keystore to save to + * @throws java.security.KeyStoreException if keystore fails */ public static final void addToKeyStore(X509Certificate cert, KeyStore ks) throws KeyStoreException { OutputController.getLogger().log("Importing " + cert.getSubjectX500Principal().getName()); - String alias = null; - // does this certificate already exist? - alias = ks.getCertificateAlias(cert); + String alias = ks.getCertificateAlias(cert); if (alias != null) { return; } @@ -133,10 +139,8 @@ public static void addPKCS12ToKeyStore(Certificate[] certChain, Key key, KeyStore ks) throws KeyStoreException { - String alias = null; - // does this certificate already exist? - alias = ks.getCertificateAlias(certChain[0]); + String alias = ks.getCertificateAlias(certChain[0]); if (alias != null) { return; } @@ -157,22 +161,19 @@ * @return true if the certificate is present in one of the keystores, false otherwise */ public static final boolean inKeyStores(X509Certificate c, KeyStore[] keyStores) { - for (int i = 0; i < keyStores.length; i++) { + for (KeyStore keyStore : keyStores) { try { // Check against all certs - Enumeration<String> aliases = keyStores[i].aliases(); + Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { - // Verify against this entry String alias = aliases.nextElement(); - - if (c.equals(keyStores[i].getCertificate(alias))) { - OutputController.getLogger().log(Translator.R("LCertFoundIn", c.getSubjectX500Principal().getName(), KeyStores.getPathToKeystore(keyStores[i].hashCode()))); + if (c.equals(keyStore.getCertificate(alias))) { + OutputController.getLogger().log(Translator.R("LCertFoundIn", c.getSubjectX500Principal().getName(), KeyStores.getPathToKeystore(keyStore.hashCode()))); return true; } // else continue } - - } catch (KeyStoreException e) { + }catch (KeyStoreException e) { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e); // continue } @@ -183,6 +184,10 @@ /** * Writes the certificate in base64 encoded from to the print stream. * See http://tools.ietf.org/html/rfc4945#section-6.1 for more information + * @param cert sertifcate to export + * @param out stream to print it to + * @throws java.io.IOException if io fails + * @throws java.security.cert.CertificateException if certificate fails */ public static void dump(Certificate cert, PrintStream out) throws IOException, CertificateException {
--- a/netx/net/sourceforge/jnlp/security/KeyStores.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/KeyStores.java Thu Apr 16 19:34:18 2015 +0200 @@ -79,7 +79,7 @@ CLIENT_CERTS, } - public static final Map<Integer,String> keystoresPaths=new HashMap<Integer, String>(); + public static final Map<Integer,String> keystoresPaths=new HashMap<>(); private static final String KEYSTORE_TYPE = "JKS"; @@ -93,7 +93,7 @@ * @return a KeyStore containing certificates from the appropriate */ public static final KeyStore getKeyStore(Level level, Type type) { - boolean create = false; + boolean create; if (level == Level.USER) { create = true; } else { @@ -109,6 +109,7 @@ * @param level whether the KeyStore desired is a user-level or system-level * KeyStore * @param type the type of KeyStore desired + * @param create true if keystore can be created * @return a KeyStore containing certificates from the appropriate */ public static final KeyStore getKeyStore(Level level, Type type, boolean create) { @@ -145,11 +146,9 @@ * @return an array of KeyStore containing trusted Certificates */ public static final KeyStore[] getCertKeyStores() { - List<KeyStore> result = new ArrayList<KeyStore>(10); - KeyStore ks = null; - + List<KeyStore> result = new ArrayList<>(10); /* System-level JSSE certificates */ - ks = getKeyStore(Level.SYSTEM, Type.JSSE_CERTS); + KeyStore ks = getKeyStore(Level.SYSTEM, Type.JSSE_CERTS); if (ks != null) { result.add(ks); } @@ -178,11 +177,9 @@ * @return an array of KeyStore containing trusted CA certificates */ public static final KeyStore[] getCAKeyStores() { - List<KeyStore> result = new ArrayList<KeyStore>(10); - KeyStore ks = null; - + List<KeyStore> result = new ArrayList<>(10); /* System-level JSSE CA certificates */ - ks = getKeyStore(Level.SYSTEM, Type.JSSE_CA_CERTS); + KeyStore ks = getKeyStore(Level.SYSTEM, Type.JSSE_CA_CERTS); if (ks != null) { result.add(ks); } @@ -212,10 +209,9 @@ * authentication certificates */ public static KeyStore[] getClientKeyStores() { - List<KeyStore> result = new ArrayList<KeyStore>(); - KeyStore ks = null; + List<KeyStore> result = new ArrayList<>(); - ks = getKeyStore(Level.SYSTEM, Type.CLIENT_CERTS); + KeyStore ks = getKeyStore(Level.SYSTEM, Type.CLIENT_CERTS); if (ks != null) { result.add(ks); }
--- a/netx/net/sourceforge/jnlp/security/SecurityDialog.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/SecurityDialog.java Thu Apr 16 19:34:18 2015 +0200 @@ -55,7 +55,6 @@ import net.sourceforge.jnlp.security.dialogs.AppletWarningPane; import net.sourceforge.jnlp.security.dialogs.CertWarningPane; import net.sourceforge.jnlp.security.dialogs.CertsInfoPane; -import net.sourceforge.jnlp.security.dialogs.apptrustwarningpanel.MatchingALACAttributePanel; import net.sourceforge.jnlp.security.dialogs.MissingALACAttributePanel; import net.sourceforge.jnlp.security.dialogs.MissingPermissionsAttributePanel; import net.sourceforge.jnlp.security.dialogs.MoreInfoPane; @@ -63,7 +62,6 @@ import net.sourceforge.jnlp.security.dialogs.SecurityDialogPanel; import net.sourceforge.jnlp.security.dialogs.SingleCertInfoPane; import net.sourceforge.jnlp.security.dialogs.apptrustwarningpanel.AppTrustWarningDialog; -import net.sourceforge.jnlp.security.dialogs.apptrustwarningpanel.AppTrustWarningPanel; import net.sourceforge.jnlp.util.ImageResources; import net.sourceforge.jnlp.util.ScreenFinder; import net.sourceforge.jnlp.util.logging.OutputController; @@ -362,7 +360,7 @@ super.dispose(); } - private final List<ActionListener> listeners = new CopyOnWriteArrayList<ActionListener>(); + private final List<ActionListener> listeners = new CopyOnWriteArrayList<>(); /** * Notify all the listeners that the user has made a decision using this @@ -378,6 +376,7 @@ * Adds an {@link ActionListener} which will be notified if the user makes a * choice using this SecurityDialog. The listener should use {@link #getValue()} * to actually get the user's response. + * @param listener another action listener to be listen to */ public void addActionListener(ActionListener listener) { listeners.add(listener);
--- a/netx/net/sourceforge/jnlp/security/SecurityDialogs.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/SecurityDialogs.java Thu Apr 16 19:34:18 2015 +0200 @@ -155,6 +155,9 @@ /** * unlike showAccessWarningDialogB this is returning raw int code + * @param accessType type of dialogue + * @param file file for which thsi dialogue is built for + * @return return from dialogue */ public static int showAccessWarningDialogI(AccessType accessType, JNLPFile file) { Object o = showAccessWarningDialog(accessType, file, null); @@ -197,6 +200,10 @@ /** * unlike showAccessWarningDialogB this is returning raw int code + * @param accessType type of dialogue + * @param file file for which thsi dialogue is built for + * @param extras aditional parameters to dialogue + * @return return from dialogue */ public static Object showAccessWarningDialog(final AccessType accessType, final JNLPFile file, final Object[] extras) { @@ -399,7 +406,7 @@ // result 0 = Yes, 1 = No, 2 = Cancel if (selectedValue instanceof Integer) { // If the selected value can be cast to Integer, use that value - return ((Integer) selectedValue).intValue(); + return ((Integer) selectedValue); } else { // Otherwise default to "cancel" return 2; @@ -508,7 +515,7 @@ boolean isInteger = ref instanceof Integer; if (isInteger) { Integer i = (Integer) ref; - return i.intValue() == 0; + return i == 0; } return false; }
--- a/netx/net/sourceforge/jnlp/security/SecurityUtil.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/SecurityUtil.java Thu Apr 16 19:34:18 2015 +0200 @@ -68,6 +68,8 @@ * * This is a simple (and hence 'wrong') version. See * http://www.ietf.org/rfc/rfc2253.txt for all the gory details. + * @param principal string, CN to be extracted from + * @return extracted CN */ public static String getCN(String principal) { @@ -167,6 +169,7 @@ * If it does not exist, it tries to create an empty keystore. * @return true if the trusted.certs file exists or a new trusted.certs * was created successfully, otherwise false. + * @throws java.lang.Exception if check goes wrong */ public static boolean checkTrustedCertsFile() throws Exception { @@ -195,8 +198,9 @@ } /** - * Returns the keystore associated with the user's trusted.certs file, + * @return the keystore associated with the user's trusted.certs file, * or null otherwise. + * @throws java.lang.Exception if getting fails */ public static KeyStore getUserKeyStore() throws Exception { @@ -223,8 +227,9 @@ } /** - * Returns the keystore associated with the JDK cacerts file, - * or null otherwise. + * @return the keystore associated with the JDK cacerts file, + * or null otherwise. + * @throws java.lang.Exception if get fails */ public static KeyStore getCacertsKeyStore() throws Exception { @@ -250,8 +255,9 @@ } /** - * Returns the keystore associated with the system certs file, + * @return the keystore associated with the system certs file, * or null otherwise. + * @throws java.lang.Exception if get goes wrong */ public static KeyStore getSystemCertStore() throws Exception {
--- a/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/security/VariableX509TrustManager.java Thu Apr 16 19:34:18 2015 +0200 @@ -80,8 +80,8 @@ /** TrustManagers containing trusted client certificates */ private X509TrustManager[] clientTrustManagers = null; - private ArrayList<Certificate> temporarilyTrusted = new ArrayList<Certificate>(); - private ArrayList<Certificate> temporarilyUntrusted = new ArrayList<Certificate>(); + private ArrayList<Certificate> temporarilyTrusted = new ArrayList<>(); + private ArrayList<Certificate> temporarilyUntrusted = new ArrayList<>(); private static VariableX509TrustManager instance = null; @@ -105,9 +105,9 @@ // tm factory initialized, now get the managers so we can assign the X509 one TrustManager[] trustManagers = tmFactory.getTrustManagers(); - for (int i = 0; i < trustManagers.length; i++) { - if (trustManagers[i] instanceof X509TrustManager) { - certTrustManagers[j] = (X509TrustManager) trustManagers[i]; + for (TrustManager trustManager : trustManagers) { + if (trustManager instanceof X509TrustManager) { + certTrustManagers[j] = (X509TrustManager) trustManager; } } } @@ -130,9 +130,9 @@ // tm factory initialized, now get the managers so we can extract the X509 one TrustManager[] trustManagers = tmFactory.getTrustManagers(); - for (int i = 0; i < trustManagers.length; i++) { - if (trustManagers[i] instanceof X509TrustManager) { - caTrustManagers[j] = (X509TrustManager) trustManagers[i]; + for (TrustManager trustManager : trustManagers) { + if (trustManager instanceof X509TrustManager) { + caTrustManagers[j] = (X509TrustManager) trustManager; } } } @@ -154,9 +154,9 @@ // tm factory initialized, now get the managers so we can extract the X509 one TrustManager[] trustManagers = tmFactory.getTrustManagers(); - for (int i = 0; i < trustManagers.length; i++) { - if (trustManagers[i] instanceof X509TrustManager) { - clientTrustManagers[j] = (X509TrustManager) trustManagers[i]; + for (TrustManager trustManager : trustManagers) { + if (trustManager instanceof X509TrustManager) { + clientTrustManagers[j] = (X509TrustManager) trustManager; } } } @@ -167,6 +167,10 @@ /** * Check if client is trusted (no support for custom here, only system/user) + * @param chain certificate chain + * @param authType type of authentification + * @param hostName hostnem + * @throws java.security.cert.CertificateException if certificate is wrong */ public void checkTrustClient(X509Certificate[] chain, String authType, String hostName) @@ -174,12 +178,12 @@ boolean trusted = false; ValidatorException savedException = null; - for (int i = 0; i < clientTrustManagers.length; i++) { + for (X509TrustManager clientTrustManager : clientTrustManagers) { try { - clientTrustManagers[i].checkClientTrusted(chain, authType); + clientTrustManager.checkClientTrusted(chain, authType); trusted = true; break; - } catch (ValidatorException caex) { + }catch (ValidatorException caex) { savedException = caex; } } @@ -202,6 +206,7 @@ * @param hostName The expected hostName that the server should have * @param socket The SSLSocket in use (may be null) * @param engine The SSLEngine in use (may be null) + * @throws java.security.cert.CertificateException if certificate is wrong */ public synchronized void checkTrustServer(X509Certificate[] chain, String authType, String hostName, @@ -276,35 +281,27 @@ // first try CA TrustManagers boolean trusted = false; ValidatorException savedException = null; - for (int i = 0; i < caTrustManagers.length; i++) { + for (X509TrustManager caTrustManager : caTrustManagers) { try { if (socket == null && engine == null) { - caTrustManagers[i].checkServerTrusted(chain, authType); + caTrustManager.checkServerTrusted(chain, authType); } else { - try { Class<?> x509ETMClass = Class.forName("javax.net.ssl.X509ExtendedTrustManager"); if (engine == null) { Method mcheckServerTrusted = x509ETMClass.getDeclaredMethod("checkServerTrusted", X509Certificate[].class, String.class, Socket.class); - mcheckServerTrusted.invoke(caTrustManagers[i], chain, authType, socket); + mcheckServerTrusted.invoke(caTrustManager, chain, authType, socket); } else { Method mcheckServerTrusted = x509ETMClass.getDeclaredMethod("checkServerTrusted", X509Certificate[].class, String.class, SSLEngine.class); - mcheckServerTrusted.invoke(caTrustManagers[i], chain, authType, engine); + mcheckServerTrusted.invoke(caTrustManager, chain, authType, engine); } - } catch (NoSuchMethodException nsme) { + }catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | ClassNotFoundException nsme) { throw new ValidatorException(nsme.getMessage()); - } catch (InvocationTargetException ite) { - throw new ValidatorException(ite.getMessage()); - } catch (IllegalAccessException iae) { - throw new ValidatorException(iae.getMessage()); - } catch (ClassNotFoundException cnfe) { - throw new ValidatorException(cnfe.getMessage()); } } - trusted = true; break; - } catch (ValidatorException caex) { + }catch (ValidatorException caex) { savedException = caex; } } @@ -313,13 +310,12 @@ return; } - // then try certificate TrustManagers - for (int i = 0; i < certTrustManagers.length; i++) { + for (X509TrustManager certTrustManager : certTrustManagers) { try { - certTrustManagers[i].checkServerTrusted(chain, authType); + certTrustManager.checkServerTrusted(chain, authType); trusted = true; break; - } catch (ValidatorException caex) { + }catch (ValidatorException caex) { savedException = caex; } } @@ -344,17 +340,17 @@ private boolean isExplicitlyTrusted(X509Certificate[] chain, String authType) { boolean explicitlyTrusted = false; - for (int i = 0; i < certTrustManagers.length; i++) { + for (X509TrustManager certTrustManager : certTrustManagers) { try { - certTrustManagers[i].checkServerTrusted(chain, authType); + certTrustManager.checkServerTrusted(chain, authType); explicitlyTrusted = true; break; - } catch (ValidatorException uex) { + }catch (ValidatorException uex) { if (temporarilyTrusted.contains(chain[0])) { explicitlyTrusted = true; break; } - } catch (CertificateException ce) { + }catch (CertificateException ce) { // not explicitly trusted } } @@ -363,10 +359,10 @@ } protected X509Certificate[] getAcceptedIssuers() { - List<X509Certificate> issuers = new ArrayList<X509Certificate>(); + List<X509Certificate> issuers = new ArrayList<>(); - for (int i = 0; i < caTrustManagers.length; i++) { - issuers.addAll(Arrays.asList(caTrustManagers[i].getAcceptedIssuers())); + for (X509TrustManager caTrustManager : caTrustManagers) { + issuers.addAll(Arrays.asList(caTrustManager.getAcceptedIssuers())); } return issuers.toArray(new X509Certificate[issuers.size()]); @@ -390,10 +386,7 @@ * not to trust it */ private boolean isTemporarilyUntrusted(Certificate c) { - if (temporarilyUntrusted.contains(c)) { - return true; - } - return false; + return temporarilyUntrusted.contains(c); } /**
--- a/netx/net/sourceforge/jnlp/services/ServiceUtil.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/services/ServiceUtil.java Thu Apr 16 19:34:18 2015 +0200 @@ -55,7 +55,7 @@ public class ServiceUtil { /** - * Returns the BasicService reference, or null if the service is + * @return the BasicService reference, or null if the service is * unavailable. */ public static BasicService getBasicService() { @@ -63,7 +63,7 @@ } /** - * Returns the ClipboardService reference, or null if the service is + * @return the ClipboardService reference, or null if the service is * unavailable. */ public static ClipboardService getClipboardService() { @@ -71,7 +71,7 @@ } /** - * Returns the DownloadService reference, or null if the service is + * @return the DownloadService reference, or null if the service is * unavailable. */ public static DownloadService getDownloadService() { @@ -79,7 +79,7 @@ } /** - * Returns the ExtensionInstallerService reference, or null if the service is + * @return the ExtensionInstallerService reference, or null if the service is * unavailable. */ public static ExtensionInstallerService getExtensionInstallerService() { @@ -87,7 +87,7 @@ } /** - * Returns the FileOpenService reference, or null if the service is + * @return the FileOpenService reference, or null if the service is * unavailable. */ public static FileOpenService getFileOpenService() { @@ -95,7 +95,7 @@ } /** - * Returns the FileSaveService reference, or null if the service is + * @return the FileSaveService reference, or null if the service is * unavailable. */ public static FileSaveService getFileSaveService() { @@ -103,7 +103,7 @@ } /** - * Returns the PersistenceService reference, or null if the service is + * @return the PersistenceService reference, or null if the service is * unavailable. */ public static PersistenceService getPersistenceService() { @@ -111,7 +111,7 @@ } /** - * Returns the PrintService reference, or null if the service is + * @return the PrintService reference, or null if the service is * unavailable. */ public static PrintService getPrintService() { @@ -119,7 +119,7 @@ } /** - * Returns the SingleInstanceService reference, or null if the service is + * @return the SingleInstanceService reference, or null if the service is * unavailable. */ public static SingleInstanceService getSingleInstanceService() { @@ -176,8 +176,8 @@ if (JNLPRuntime.isDebug()) { OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "call privileged method: " + method.getName()); if (args != null) { - for (int i = 0; i < args.length; i++) { - OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, " arg: " + args[i]); + for (Object arg : args) { + OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, " arg: " + arg); } } } @@ -306,27 +306,23 @@ StackTraceElement[] stack = Thread.currentThread().getStackTrace(); - for (int i = 0; i < stack.length; i++) { - + for (StackTraceElement stack1 : stack) { Class<?> c = null; - try { - c = Class.forName(stack[i].getClassName()); + c = Class.forName(stack1.getClassName()); } catch (Exception e1) { OutputController.getLogger().log(e1); try { - c = Class.forName(stack[i].getClassName(), false, - app.getClassLoader()); - } catch (Exception e2) { + c = Class.forName(stack1.getClassName(), false, app.getClassLoader()); + }catch (Exception e2) { OutputController.getLogger().log(e2); } } - // Everything up to the desired class/method must be trusted if (c == null || // class not found (c.getProtectionDomain().getCodeSource() != null && // class is not in bootclasspath c.getProtectionDomain().getCodeSource().getCodeSigners() == null) // class is trusted - ) { + ) { return false; } }
--- a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java Thu Apr 16 19:34:18 2015 +0200 @@ -78,22 +78,22 @@ } /** All of the jar files that were verified for signing */ - private List<String> verifiedJars = new ArrayList<String>(); + private final List<String> verifiedJars = new ArrayList<>(); /** All of the jar files that were not verified */ - private List<String> unverifiedJars = new ArrayList<String>(); + private final List<String> unverifiedJars = new ArrayList<>(); /** The certificates used for jar verification linked to their respective information */ - private Map<CertPath, CertInformation> certs = new HashMap<CertPath, CertInformation>(); + private final Map<CertPath, CertInformation> certs = new HashMap<>(); /** Temporary cert path hack to be used to keep track of which one a UI dialog is using */ private CertPath currentlyUsed; /** Absolute location to jars and the number of entries which are possibly signable */ - private Map<String, Integer> jarSignableEntries = new HashMap<String, Integer>(); + private final Map<String, Integer> jarSignableEntries = new HashMap<>(); /** The application verifier to use by this instance */ - private AppVerifier appVerifier; + private final AppVerifier appVerifier; /** * Create a new jar certificate verifier utility that uses the provided verifier for its strategy pattern. @@ -106,7 +106,7 @@ } /** - * Return true if there are no signable entries in the jar. + * @return true if there are no signable entries in the jar. * This will return false if any of verified jars have content more than just META-INF/. */ public boolean isTriviallySigned() { @@ -114,6 +114,7 @@ && certs.size() <= 0; } + @Override public boolean getAlreadyTrustPublisher() { boolean allPublishersTrusted = appVerifier.hasAlreadyTrustedPublisher( certs, jarSignableEntries); @@ -122,6 +123,7 @@ return allPublishersTrusted; } + @Override public boolean getRootInCacerts() { boolean allRootCAsTrusted = appVerifier.hasRootInCacerts(certs, jarSignableEntries); @@ -129,14 +131,17 @@ return allRootCAsTrusted; } + @Override public CertPath getCertPath(CertPath cPath) { // Parameter ignored. return currentlyUsed; } + @Override public boolean hasSigningIssues(CertPath certPath) { return certs.get(certPath).hasSigningIssues(); } + @Override public List<String> getDetails(CertPath certPath) { if (certPath != null) { currentlyUsed = certPath; @@ -150,12 +155,13 @@ * @return List of CertPath vars representing each of the signers present on any jar. */ public List<CertPath> getCertsList() { - return new ArrayList<CertPath>(certs.keySet()); + return new ArrayList<>(certs.keySet()); } /** * Find the information the specified cert path has with respect to this application. * + * @param cPath certificate to provide info * @return All the information the path has with this app. */ public CertInformation getCertInformation(CertPath cPath) { @@ -184,7 +190,7 @@ public static boolean isJarSigned(JARDesc jar, AppVerifier verifier, ResourceTracker tracker) throws Exception { JarCertVerifier certVerifier = new JarCertVerifier(verifier); - List<JARDesc> singleJarList = new ArrayList<JARDesc>(); + List<JARDesc> singleJarList = new ArrayList<>(); singleJarList.add(jar); certVerifier.add(singleJarList, tracker); return certVerifier.allJarsSigned(); @@ -266,10 +272,7 @@ * Will be thrown if there are any problems with the jar. */ private VerifyResult verifyJar(String jarName) throws Exception { - JarFile jarFile = null; - - try { - jarFile = new JarFile(jarName, true); + try (JarFile jarFile = new JarFile(jarName, true)) { Vector<JarEntry> entriesVec = new Vector<JarEntry>(); byte[] buffer = new byte[8192]; @@ -296,10 +299,6 @@ } catch (Exception e) { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e); throw e; - } finally { // close the resource - if (jarFile != null) { - jarFile.close(); - } } } @@ -319,7 +318,7 @@ VerifyResult verifyJarEntryCerts(String jarName, boolean jarHasManifest, Vector<JarEntry> entries) throws Exception { // Contains number of entries the cert with this CertPath has signed. - Map<CertPath, Integer> jarSignCount = new HashMap<CertPath, Integer>(); + Map<CertPath, Integer> jarSignCount = new HashMap<>(); int numSignableEntriesInJar = 0; // Record current time just before checking the jar begins. @@ -339,9 +338,8 @@ } if (shouldHaveSignature && isSigned) { - for (int i = 0; i < signers.length; i++) { - CertPath certPath = signers[i].getSignerCertPath(); - + for (CodeSigner signer : signers) { + CertPath certPath = signer.getSignerCertPath(); if (!jarSignCount.containsKey(certPath)) jarSignCount.put(certPath, 1); else @@ -464,6 +462,7 @@ currentlyUsed = cPath; } + @Override public Certificate getPublisher(CertPath cPath) { if (cPath != null) { currentlyUsed = cPath; @@ -481,6 +480,7 @@ } } + @Override public Certificate getRoot(CertPath cPath) { if (cPath != null) { currentlyUsed = cPath; @@ -574,7 +574,7 @@ NetscapeCertTypeExtension extn = new NetscapeCertTypeExtension( encoded); - Boolean val = (Boolean) extn + Boolean val = extn .get(NetscapeCertTypeExtension.OBJECT_SIGNING); if (!val) { if (bad != null) { @@ -595,7 +595,7 @@ * @return True if all jars are signed, false if there are one or more unsigned jars */ public boolean allJarsSigned() { - return this.unverifiedJars.size() == 0; + return this.unverifiedJars.isEmpty(); } public void checkTrustWithUser(SecurityDelegate securityDelegate, JNLPFile file) throws LaunchException { @@ -609,6 +609,7 @@ /** * Get the total number of entries in the provided map. * + * @param map map of all jars * @return The number of entries. */ public static int getTotalJarEntries(Map<String, Integer> map) {
--- a/netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/tools/KeyStoreUtil.java Thu Apr 16 19:34:18 2015 +0200 @@ -47,6 +47,8 @@ /** * Returns true if KeyStore has a password. This is true except for * MSCAPI KeyStores + * @param storetype type of store + * @return true if it was windows one */ public static boolean isWindowsKeyStore(String storetype) { return storetype.equalsIgnoreCase("Windows-MY") @@ -55,6 +57,8 @@ /** * Returns standard-looking names for storetype + * @param storetype type of store + * @return better name fro keystore */ public static String niceStoreTypeName(String storetype) { if (storetype.equalsIgnoreCase("Windows-MY")) {
--- a/netx/net/sourceforge/jnlp/util/ClasspathMatcher.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/ClasspathMatcher.java Thu Apr 16 19:34:18 2015 +0200 @@ -33,8 +33,8 @@ /** * space separated list of ClasspathMatcher source strings * - * @param s - * @return + * @param s string to be read + * @return returns compiled matcher */ public static ClasspathMatchers compile(String s) { return compile(s, false); @@ -45,7 +45,7 @@ return new ClasspathMatchers(new ArrayList<ClasspathMatcher>(0), includePath); } String[] splitted = s.trim().split("\\s+"); - ArrayList<ClasspathMatcher> matchers = new ArrayList<ClasspathMatcher>(splitted.length); + ArrayList<ClasspathMatcher> matchers = new ArrayList<>(splitted.length); for (String string : splitted) { matchers.add(ClasspathMatcher.compile(string.trim())); } @@ -231,22 +231,14 @@ //the most easy part - dot in url int indexofFirstDot = source.indexOf("."); if (indexofFirstDot >= 0) { - if (indexOfProtocolMark < indexofFirstDot) { - return true; - } else { - return false; - } + return indexOfProtocolMark < indexofFirstDot; } //more nasty part - path specified String degradedProtocol = source.replace(PROTOCOL_DELIMITER, "%%%"); int indexofFirstPath = degradedProtocol.indexOf(PATH_DELIMITER); if (indexofFirstPath >= 0) { - if (indexOfProtocolMark < indexofFirstPath) { - return true; - } else { - return false; - } + return indexOfProtocolMark < indexofFirstPath; } //no path? no dot? it must be it! return true;
--- a/netx/net/sourceforge/jnlp/util/FileUtils.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/FileUtils.java Thu Apr 16 19:34:18 2015 +0200 @@ -133,7 +133,8 @@ * readable or writable by anyone other than the owner. The parent * directories are not created; they must exist before this is called. * - * @throws IOException + * @param directory directory to be created + * @throws IOException if IO fails */ public static void createRestrictedDirectory(File directory) throws IOException { createRestrictedFile(directory, true, true); @@ -144,7 +145,9 @@ * writable by anyone other than the owner. If writeableByOnwer is false, * even the owner can not write to it. * - * @throws IOException + * @param file path to file + * @param writableByOwner true if can be writable by owner + * @throws IOException if IO fails */ public static void createRestrictedFile(File file, boolean writableByOwner) throws IOException { createRestrictedFile(file, false, writableByOwner); @@ -154,7 +157,7 @@ * Tries to create the ancestor directories of file f. Throws * an IOException if it can't be created (but not if it was * already there). - * @param f + * @param f file to provide parent directory * @param eMsg - the message to use for the exception. null * if the file name is to be used. * @throws IOException if the directory can't be created and doesn't exist. @@ -171,7 +174,7 @@ * Tries to create the ancestor directories of file f. Throws * an IOException if it can't be created (but not if it was * already there). - * @param f + * @param f file which parent will be created * @throws IOException if the directory can't be created and doesn't exist. */ public static void createParentDir(File f) throws IOException { @@ -213,9 +216,7 @@ */ private static void createRestrictedFile(File file, boolean isDir, boolean writableByOwner) throws IOException { - File tempFile = null; - - tempFile = new File(file.getCanonicalPath() + ".temp"); + File tempFile = new File(file.getCanonicalPath() + ".temp"); if (isDir) { if (!tempFile.mkdir()) { @@ -312,7 +313,7 @@ if (file == null || file.getParentFile() == null || !file.getParentFile().exists()) { return null; } - final List<File> policyDirectory = new ArrayList<File>(); + final List<File> policyDirectory = new ArrayList<>(); policyDirectory.add(file.getParentFile()); final DirectoryValidator validator = new DirectoryValidator(policyDirectory); final DirectoryCheckResults result = validator.ensureDirs(); @@ -490,8 +491,8 @@ if (file.isDirectory()) { File[] children = file.listFiles(); - for (int i = 0; i < children.length; i++) { - recursiveDelete(children[i], base); + for (File children1 : children) { + recursiveDelete(children1, base); } } if (!file.delete()) { @@ -544,7 +545,7 @@ * * @param content which will be saved as it is saved in this String * @param f file to be saved. No warnings provided - * @throws IOException + * @throws IOException if save fails */ public static void saveFile(String content, File f) throws IOException { saveFile(content, f, "utf-8"); @@ -556,13 +557,13 @@ * @param content which will be saved as it is saved in this String * @param f file to be saved. No warnings provided * @param encoding of output byte representation - * @throws IOException + * @throws IOException if save fails */ public static void saveFile(String content, File f, String encoding) throws IOException { - Writer output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), encoding)); - output.write(content); - output.flush(); - output.close(); + try (Writer output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), encoding))) { + output.write(content); + output.flush(); + } } /**
--- a/netx/net/sourceforge/jnlp/util/HttpUtils.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/HttpUtils.java Thu Apr 16 19:34:18 2015 +0200 @@ -46,6 +46,7 @@ /** * Ensure a HttpURLConnection is fully read, required for correct behavior. * Captured IOException is consumed and printed + * @param c the connection to be closed silently */ public static void consumeAndCloseConnectionSilently(HttpURLConnection c) { try { @@ -58,20 +59,15 @@ /** * Ensure a HttpURLConnection is fully read, required for correct behavior * - * @throws IOException + * @param c connection to be closed + * @throws IOException if connection fade */ public static void consumeAndCloseConnection(HttpURLConnection c) throws IOException { - InputStream in = null; - try { - in = c.getInputStream(); + try (InputStream in = c.getInputStream()) { byte[] throwAwayBuffer = new byte[256]; while (in.read(throwAwayBuffer) > 0) { /* ignore contents */ } - } finally { - if (in != null) { - in.close(); - } } } }
--- a/netx/net/sourceforge/jnlp/util/ImageResources.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/ImageResources.java Thu Apr 16 19:34:18 2015 +0200 @@ -54,7 +54,7 @@ private static final String APPLICATION_ICON_PATH = "net/sourceforge/jnlp/resources/netx-icon.png"; - private final Map<String, Image> cache = new HashMap<String, Image>(); + private final Map<String, Image> cache = new HashMap<>(); private ImageResources() {} @@ -88,10 +88,10 @@ } /** - * Returns an appropriate image, or null if there are errors loading the image. + * @return an appropriate image, or null if there are errors loading the image. */ public List<Image> getApplicationImages() { - List<Image> images = new ArrayList<Image>(); + List<Image> images = new ArrayList<>(); Image appImage = getApplicationImage(); if (appImage != null) { images.add(appImage);
--- a/netx/net/sourceforge/jnlp/util/PropertiesFile.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/PropertiesFile.java Thu Apr 16 19:34:18 2015 +0200 @@ -67,9 +67,10 @@ } /** - * Returns the value of the specified key, or null if the key + * @return the value of the specified key, or null if the key * does not exist. */ + @Override public String getProperty(String key) { if (lastStore == 0) load(); @@ -78,9 +79,10 @@ } /** - * Returns the value of the specified key, or the default value + * @return the value of the specified key, or the default value * if the key does not exist. */ + @Override public String getProperty(String key, String defaultValue) { if (lastStore == 0) load(); @@ -93,6 +95,7 @@ * * @return the previous value */ + @Override public Object setProperty(String key, String value) { if (lastStore == 0) load(); @@ -101,7 +104,7 @@ } /** - * Returns the file backing this properties object. + * @return the file backing this properties object. */ public File getStoreFile() { return lockedFile.getFile();
--- a/netx/net/sourceforge/jnlp/util/StreamUtils.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/StreamUtils.java Thu Apr 16 19:34:18 2015 +0200 @@ -65,6 +65,9 @@ /** * Copy an input stream's contents into an output stream. + * @param input input stream + * @param output stream where to copy input + * @throws java.io.IOException if IO fails */ public static void copyStream(InputStream input, OutputStream output) throws IOException {
--- a/netx/net/sourceforge/jnlp/util/UrlUtils.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/UrlUtils.java Thu Apr 16 19:34:18 2015 +0200 @@ -161,8 +161,8 @@ * You can use sanitizeLastSlash and see also unittests * Both unix and windows salshes are supported * - * @param src - * @return + * @param src src to be stripped + * @return src without file */ public static URL removeFileName(final URL src) { URL nsrc = normalizeUrlAndStripParams(src); @@ -184,8 +184,8 @@ /** * Small utility function creating li list from collection of urls - * @param remoteUrls - * @return + * @param remoteUrls list of urls + * @return String containing html item list of those urls */ public static String setOfUrlsToHtmlList(Iterable<URL> remoteUrls) { StringBuilder sb = new StringBuilder(); @@ -207,9 +207,9 @@ * * * When input is like - * @param in - * @return - * @throws MalformedURLException + * @param in url t be sanitized + * @return url without trailing slash (if any) + * @throws MalformedURLException if original url was wrong */ public static URL sanitizeLastSlash(URL in) throws MalformedURLException { if (in == null) { @@ -235,9 +235,9 @@ * So protcol://som.url/some/path/ is same as protcol://som.url/some/path. * Even protcol://som.url/some/path\ is same as protcol://som.url/some/path/ * - * @param u1 - * @param u2 - * @return + * @param u1 first url to comapre + * @param u2 second + * @return true if urls are equals no matter of trailing slash */ public static boolean equalsIgnoreLastSlash(URL u1, URL u2) { try {
--- a/netx/net/sourceforge/jnlp/util/WeakList.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/WeakList.java Thu Apr 16 19:34:18 2015 +0200 @@ -29,11 +29,12 @@ * * @author <a href="mailto:jmaxwell@users.sourceforge.net">Jon A. Maxwell (JAM)</a> - initial author * @version $Revision: 1.3 $ + * @param <E> generic typeto be used in this list */ public class WeakList<E> extends AbstractList<E> { /* list of weak references */ - private ArrayList<WeakReference<E>> refs = new ArrayList<WeakReference<E>>(); + private final ArrayList<WeakReference<E>> refs = new ArrayList<>(); /** * Create a weak random-access list. @@ -52,17 +53,20 @@ } /** - * Returns the object at the specified index, or null if the + * @param index of field to get + * @return the object at the specified index, or null if the * object has been collected. */ + @Override public E get(int index) { return deref(refs.get(index)); } /** - * Returns the size of the list, including already collected + * @return the size of the list, including already collected * objects. */ + @Override public int size() { return refs.size(); } @@ -71,34 +75,44 @@ * Sets the object at the specified position and returns the * previous object at that position or null if it was already * collected. + * @param index position where to place element + * @param element data which to put on position + * @return previous object on that position */ + @Override public E set(int index, E element) { - return deref(refs.set(index, new WeakReference<E>(element))); + return deref(refs.set(index, new WeakReference<>(element))); } /** * Inserts the object at the specified position in the list. * Automatically creates a weak reference to the object. + * @param index position where to insert element + * @param element data which to put on position */ + @Override public void add(int index, E element) { - refs.add(index, new WeakReference<E>(element)); + refs.add(index, new WeakReference<>(element)); } /** * Removes the object at the specified position and returns it * or returns null if it was already collected. + * @param index of element to be removed + * @return previous object on that position */ + @Override public E remove(int index) { return deref(refs.remove(index)); } /** - * Returns a list of hard references to the objects. The + * @return a list of hard references to the objects. The * returned list does not include the collected elements, so its * indices do not necessarily correlate with those of this list. */ public List<E> hardList() { - List<E> result = new ArrayList<E>(); + List<E> result = new ArrayList<>(); for (int i = 0; i < size(); i++) { E tmp = get(i);
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java Thu Apr 16 19:34:18 2015 +0200 @@ -62,7 +62,7 @@ * Mate/gnome 2/xfce - no meter of exec or icon put icon to defined/"others" Category * - name is as expected Name's value * - if removed, xfce kept icon until login/logout - * kde 4 - unknown Cathegory is sorted to Lost & Found -thats bad + * kde 4 - unknown Cathegory is sorted to Lost & Found -thats bad * - if icon is not found, nothing shows * - name is GENERIC NAME and then little name * Gnome 3 shell - exec must be valid program! @@ -104,6 +104,10 @@ /** * Returns the contents of the {@link XDesktopEntry} through the * {@link Reader} interface. + * @param menu whether to create this icon to menu + * @param info result of user's interference + * @param isSigned whether the app is signed + * @return reader with desktop shortcut specification */ public Reader getContentsAsReader(boolean menu, AccessWarningPaneComplexReturn.ShortcutResult info, boolean isSigned) { @@ -254,7 +258,7 @@ } /** - * Get the size of the icon (in pixels) for the desktop shortcut + * @return the size of the icon (in pixels) for the desktop shortcut */ public int getIconSize() { return iconSize; @@ -278,6 +282,9 @@ /** * Create a desktop shortcut for this desktop entry + * @param menu how to create in menu + * @param desktop how to create on desktop + * @param isSigned if it is signed */ public void createDesktopShortcuts(AccessWarningPaneComplexReturn.ShortcutResult menu, AccessWarningPaneComplexReturn.ShortcutResult desktop, boolean isSigned) { boolean isDesktop = false;
--- a/netx/net/sourceforge/nanoxml/XMLElement.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/nanoxml/XMLElement.java Thu Apr 16 19:34:18 2015 +0200 @@ -353,7 +353,7 @@ } /** - * Returns the number of child elements of the element. + * @return the number of child elements of the element. * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>{@code result >= 0}</li> @@ -364,7 +364,7 @@ } /** - * Enumerates the attribute names. + * @return Enumeration of the attribute names. * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>{@code result != null}</li> @@ -375,7 +375,7 @@ } /** - * Enumerates the child elements. + * @return Enumeration the child elements. * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>{@code result != null}</li> @@ -386,7 +386,7 @@ } /** - * Returns the PCDATA content of the object. If there is no such content, + * @return the PCDATA content of the object. If there is no such content, * {@code null} is returned. */ public String getContent() { @@ -394,7 +394,7 @@ } /** - * Returns the line nr in the source data on which the element is found. + * @return the line nr in the source data on which the element is found. * This method returns {@code 0} there is no associated source data. * * <dl><dt><b>Postconditions:</b></dt><dd> @@ -406,7 +406,7 @@ } /** - * Returns an attribute of the element. + * @return an attribute of the element. * <p> * If the attribute doesn't exist, {@code null} is returned. * @@ -517,6 +517,7 @@ * <p> * You should override this method when subclassing XMLElement. * </p> + * @return next element in tree based on global settings */ protected XMLElement createAnotherElement() { return new XMLElement(this.entities, @@ -567,6 +568,7 @@ * <ul><li>The next character read from the reader won't be an identifier * character.</li> * </ul></dd></dl> + * @throws java.io.IOException if something goes wrong */ protected void scanIdentifier(StringBuffer result) throws IOException { @@ -586,6 +588,7 @@ * This method scans an identifier from the current reader. * * @return the next character following the whitespace. + * @throws java.io.IOException if something goes wrong */ protected char scanWhitespace() throws IOException { @@ -608,11 +611,13 @@ * <p> * The scanned whitespace is appended to {@code result}. * + * @param result where to append scanned text * @return the next character following the whitespace. * * <dl><dt><b>Preconditions:</b></dt><dd> * <ul><li>{@code result != null}</li> * </ul></dd></dl> + * @throws java.io.IOException if something goes wrong */ protected char scanWhitespace(StringBuffer result) throws IOException { @@ -641,6 +646,8 @@ * <ul><li>{@code string != null}</li> * <li>the next char read is the string delimiter</li> * </ul></dd></dl> + * @param string where to append the result + * @throws java.io.IOException if something goes wrong */ protected void scanString(StringBuffer string) throws IOException { @@ -671,6 +678,8 @@ * <dl><dt><b>Preconditions:</b></dt><dd> * <ul><li>{@code data != null}</li> * </ul></dd></dl> + * @param data where to append data + * @throws java.io.IOException if something goes wrong */ protected void scanPCData(StringBuffer data) throws IOException { @@ -700,6 +709,9 @@ * <ul><li>{@code buf != null}</li> * <li>The first < has already been read.</li> * </ul></dd></dl> + * @param buf buffer where to append data + * @return whether the CDATA were ok + * @throws java.io.IOException if something goes wrong */ protected boolean checkCDATA(StringBuffer buf) throws IOException { @@ -754,6 +766,7 @@ * <dl><dt><b>Preconditions:</b></dt><dd> * <ul><li>The first <!-- has already been read.</li> * </ul></dd></dl> + * @throws java.io.IOException if something goes wrong */ protected void skipComment() throws IOException { @@ -795,6 +808,7 @@ * <ul><li>The first <! has already been read.</li> * <li>{@code bracketLevel >= 0}</li> * </ul></dd></dl> + * @throws java.io.IOException if something goes wrong */ protected void skipSpecialTag(int bracketLevel) throws IOException { @@ -852,6 +866,8 @@ * <dl><dt><b>Preconditions:</b></dt><dd> * <ul><li>{@code literal != null}</li> * </ul></dd></dl> + * @return true if literal was ok + * @throws java.io.IOException if something goes wrong */ protected boolean checkLiteral(String literal) throws IOException { @@ -866,6 +882,8 @@ /** * Reads a character from a reader. + * @return the read char + * @throws java.io.IOException if something goes wrong */ protected char readChar() throws IOException { @@ -895,13 +913,14 @@ * <ul><li>The first < has already been read.</li> * <li>{@code elt != null}</li> * </ul></dd></dl> + * @throws java.io.IOException if something goes wrong */ protected void scanElement(XMLElement elt) throws IOException { StringBuffer buf = new StringBuffer(); this.scanIdentifier(buf); - String name = buf.toString(); - elt.setName(name); + String lname = buf.toString(); + elt.setName(lname); char ch = this.scanWhitespace(); while ((ch != '>') && (ch != '/')) { buf.setLength(0); @@ -988,8 +1007,8 @@ throw this.expectedInput("/"); } this.unreadChar(this.scanWhitespace()); - if (!this.checkLiteral(name)) { - throw this.expectedInput(name); + if (!this.checkLiteral(lname)) { + throw this.expectedInput(lname); } if (this.scanWhitespace() != '>') { throw this.expectedInput(">"); @@ -1007,6 +1026,7 @@ * <ul><li>The first & has already been read.</li> * <li>{@code buf != null}</li> * </ul></dd></dl> + * @throws java.io.IOException if something goes wrong */ protected void resolveEntity(StringBuffer buf) throws IOException { @@ -1063,6 +1083,7 @@ * <dl><dt><b>Preconditions:</b></dt><dd> * <ul><li>{@code name != null}</li> * </ul></dd></dl> + * @return exception to be thrown */ protected XMLParseException invalidValueSet(String name) { String msg = "Invalid value set (entity name = \"" + name + "\")"; @@ -1080,6 +1101,7 @@ * <ul><li>{@code name != null}</li> * <li>{@code value != null}</li> * </ul></dd></dl> + * @return exception to be used */ protected XMLParseException invalidValue(String name, String value) { @@ -1091,6 +1113,7 @@ /** * Creates a parse exception for when the end of the data input has been * reached. + * @return exception to be used */ protected XMLParseException unexpectedEndOfData() { String msg = "Unexpected end of data reached"; @@ -1106,6 +1129,7 @@ * <ul><li>{@code context != null}</li> * <li>{@code context.length() > 0}</li> * </ul></dd></dl> + * @return exception to be used */ protected XMLParseException syntaxError(String context) { String msg = "Syntax error while parsing " + context; @@ -1123,6 +1147,7 @@ * <ul><li>{@code charSet != null}</li> * <li>{@code charSet.length() > 0}</li> * </ul></dd></dl> + * @return exception to be used */ protected XMLParseException expectedInput(String charSet) { String msg = "Expected: " + charSet; @@ -1140,6 +1165,7 @@ * <ul><li>{@code charSet != null}</li> * <li>{@code charSet.length() > 0}</li> * </ul></dd></dl> + * @return exception to be used */ protected XMLParseException expectedInput(String charSet, char ch) { String msg = "Expected: '" + charSet + "'" + " but got: '" + ch + "'"; @@ -1150,6 +1176,7 @@ * Creates a parse exception for when an entity could not be resolved. * * @param name The name of the entity. + * @return exception to be used * * <dl><dt><b>Preconditions:</b></dt><dd> * <ul><li>{@code name != null}</li> @@ -1165,8 +1192,8 @@ * Reads an xml file and removes the comments, leaving only relevant * xml code. * - * @param isr The reader of the {@link InputStream} containing the xml. - * @param pout The {@link PipedOutputStream} that will be receiving the + * @param isr The reader of the {@link java.io.InputStream} containing the xml. + * @param pout The {@link java.io.PipedOutputStream} that will be receiving the * filtered xml file. */ public void sanitizeInput(Reader isr, OutputStream pout) {
--- a/netx/net/sourceforge/nanoxml/XMLParseException.java Wed Apr 15 10:43:53 2015 +0200 +++ b/netx/net/sourceforge/nanoxml/XMLParseException.java Thu Apr 16 19:34:18 2015 +0200 @@ -57,7 +57,7 @@ * <ul><li>{@code lineNr > 0 || lineNr == NO_LINE} * </ul></dd></dl> */ - private int lineNr; + private final int lineNr; /** * Creates an exception. @@ -112,6 +112,7 @@ * Where the error occurred, or {@code NO_LINE} if the line number is * unknown. * + * @return line in source where exception occurred * @see net.sourceforge.nanoxml.XMLParseException#NO_LINE */ public int getLineNr() {
--- a/plugin/icedteanp/java/netscape/javascript/JSException.java Wed Apr 15 10:43:53 2015 +0200 +++ b/plugin/icedteanp/java/netscape/javascript/JSException.java Thu Apr 16 19:34:18 2015 +0200 @@ -98,6 +98,8 @@ * Constructs a JSException with a wrapped JavaScript exception object. * This constructor needs to be public so that Java users can throw * exceptions to JS cleanly. + * @param wrappedExceptionType type of exception + * @param wrappedException actual exception */ public JSException(int wrappedExceptionType, Object wrappedException) { super(); @@ -109,6 +111,10 @@ * Constructs a JSException with a detail message and all the * other info that usually comes with a JavaScript error. * @param s the detail message + * @param filename source file where exception raised + * @param lineno line where exception raised + * @param source source text of exception + * @param tokenIndex index on line where exception raised * * @deprecated Not for public use in future versions. */ @@ -126,6 +132,7 @@ /** * Instance method getWrappedExceptionType returns the int mapping of the * type of the wrappedException Object. + * @return type of exception */ public int getWrappedExceptionType() { return wrappedExceptionType; @@ -133,6 +140,7 @@ /** * Instance method getWrappedException. + * @return actual exception */ public Object getWrappedException() { return wrappedException;
--- a/plugin/icedteanp/java/netscape/javascript/JSObject.java Wed Apr 15 10:43:53 2015 +0200 +++ b/plugin/icedteanp/java/netscape/javascript/JSObject.java Thu Apr 16 19:34:18 2015 +0200 @@ -111,6 +111,7 @@ /** * it is illegal to construct a JSObject manually + * @param jsobj_addr integer to become jsobject */ public JSObject(int jsobj_addr) { this((long) jsobj_addr); @@ -118,6 +119,7 @@ /** * it is illegal to construct a JSObject manually + * @param jsobj_addr string to become jsobject */ public JSObject(String jsobj_addr) { this(Long.parseLong(jsobj_addr)); @@ -158,6 +160,8 @@ /** * Retrieves a named member of a JavaScript object. * Equivalent to "this.<i>name</i>" in JavaScript. + * @param name name of the memebr to be searched in + * @return object which is member of name */ public Object getMember(String name) { PluginDebug.debug("JSObject.getMember ", name); @@ -170,6 +174,8 @@ /** * Retrieves an indexed member of a JavaScript object. * Equivalent to "this[<i>index</i>]" in JavaScript. + * @param index as in array-like touch in javascript array + * @return object on index position */ // public Object getMember(int index) { return getSlot(index); } public Object getSlot(int index) { @@ -181,6 +187,8 @@ /** * Sets a named member of a JavaScript object. * Equivalent to "this.<i>name</i> = <i>value</i>" in JavaScript. + * @param name name of the member + * @param value value to best to the named member */ public void setMember(String name, Object value) { PluginDebug.debug("JSObject.setMember ", name, " ", value); @@ -191,6 +199,8 @@ /** * Sets an indexed member of a JavaScript object. * Equivalent to "this[<i>index</i>] = <i>value</i>" in JavaScript. + * @param index as in array-like touch in javascript array + * @param value value to be set on the index palce */ // public void setMember(int index, Object value) { // setSlot(index, value); @@ -203,6 +213,7 @@ /** * Removes a named member of a JavaScript object. + * @param name name of member of given name */ public void removeMember(String name) { PluginDebug.debug("JSObject.removeMember ", name); @@ -213,6 +224,9 @@ /** * Calls a JavaScript method. * Equivalent to "this.<i>methodName</i>(<i>args</i>[0], <i>args</i>[1], ...)" in JavaScript. + * @param methodName - name of the method to be called + * @param args parameters for method + * @return result of method call */ public Object call(String methodName, Object args[]) { if (args == null) @@ -230,6 +244,8 @@ * Evaluates a JavaScript expression. The expression is a string * of JavaScript source code which will be evaluated in the context * given by "this". + * @param s expression to be evaluated + * @return result of evaluation */ public Object eval(String s) { PluginDebug.debug("JSObject.eval ", s); @@ -238,7 +254,9 @@ /** * Converts a JSObject to a String. + * @return string representation of this object */ + @Override public String toString() { PluginDebug.debug("JSObject.toString"); return PluginAppletViewer.javascriptToString(internal); @@ -250,12 +268,13 @@ /** * get a JSObject for the window containing the given applet + * @param applet applet which will be searched for window + * @return the JSObject representing window of applet */ public static JSObject getWindow(Applet applet) { PluginDebug.debug("JSObject.getWindow"); // FIXME: handle long case as well. - long internal = 0; - internal = ((PluginAppletViewer) + long internal = ((PluginAppletViewer) applet.getAppletContext()).getWindow(); PluginDebug.debug("GOT IT: ", internal); return new JSObject(internal); @@ -265,6 +284,7 @@ * Finalization decrements the reference count on the corresponding * JavaScript object. */ + @Override protected void finalize() { // Proceed if this is a valid object (0L == default long == invalid)
--- a/plugin/icedteanp/java/netscape/security/PrivilegeManager.java Wed Apr 15 10:43:53 2015 +0200 +++ b/plugin/icedteanp/java/netscape/security/PrivilegeManager.java Thu Apr 16 19:34:18 2015 +0200 @@ -58,7 +58,7 @@ /** * Stub for enablePrivilege. Not used by IcedTea-Web, kept for compatibility * - * @param privilege + * @param privilege privilege to eb enabled */ public static void enablePrivilege(String privilege) { PluginDebug.debug("netscape.security.enablePrivilege stub called"); @@ -67,7 +67,7 @@ /** * Stub for disablePrivilege. Not used by IcedTea-Web, kept for compatibility * - * @param privilege + * @param privilege privilege to be disabled */ public static void disablePrivilege(String privilege) { PluginDebug.debug("netscape.security.disablePrivilege stub called");
--- a/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java Wed Apr 15 10:43:53 2015 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java Thu Apr 16 19:34:18 2015 +0200 @@ -1286,7 +1286,7 @@ } /** - * Returns a "closed" AccessControlContext i.e. no permissions to get out of sandbox. + * @return a "closed" AccessControlContext i.e. no permissions to get out of sandbox. */ public AccessControlContext getClosedAccessControlContext() { // Deny everything
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Wed Apr 15 10:43:53 2015 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Thu Apr 16 19:34:18 2015 +0200 @@ -148,8 +148,8 @@ private int identifier; // Instance identifier -> PluginAppletViewer object. - private static ConcurrentMap<Integer, PluginAppletViewer> applets = - new ConcurrentHashMap<Integer, PluginAppletViewer>(); + private static final ConcurrentMap<Integer, PluginAppletViewer> applets = + new ConcurrentHashMap<>(); private static final ReentrantLock appletsLock = new ReentrantLock(); // CONDITION PREDICATE: !applets.containsKey(identifier) private static final Condition appletAdded = appletsLock.newCondition(); @@ -158,8 +158,8 @@ private static PluginCallRequestFactory requestFactory; - private static ConcurrentMap<Integer, PAV_INIT_STATUS> status = - new ConcurrentHashMap<Integer, PAV_INIT_STATUS>(); + private static final ConcurrentMap<Integer, PAV_INIT_STATUS> status = + new ConcurrentHashMap<>(); private static final ReentrantLock statusLock = new ReentrantLock(); // CONDITION PREDICATE: !status.get(identifier).equals(PAV_INIT_STATUS.INIT_COMPLETE) private static final Condition initComplete = statusLock.newCondition(); @@ -220,9 +220,12 @@ } appletsLock.lock(); - applets.put(identifier, appletFrame); - appletAdded.signalAll(); - appletsLock.unlock(); + try { + applets.put(identifier, appletFrame); + appletAdded.signalAll(); + } finally { + appletsLock.unlock(); + } PluginDebug.debug(panel, " framed"); return appletFrame; @@ -362,8 +365,11 @@ AppletPanel src = (AppletPanel) evt.getSource(); panelLock.lock(); - panelLive.signalAll(); - panelLock.unlock(); + try { + panelLive.signalAll(); + } finally { + panelLock.unlock(); + } switch (evt.getID()) { case AppletPanel.APPLET_RESIZE: { if (src != null) { @@ -523,6 +529,9 @@ /** * Handle an incoming message from the plugin. + * @param identifier id of plugin + * @param reference reference id of message + * @param message text itself */ public static void handleMessage(int identifier, int reference, String message) { @@ -600,12 +609,14 @@ } } - // Else set to given status statusLock.lock(); - status.put(identifier, newStatus); - initComplete.signalAll(); - statusLock.unlock(); + try { + status.put(identifier, newStatus); + initComplete.signalAll(); + } finally { + statusLock.unlock(); + } return prev; } @@ -783,7 +794,7 @@ * Methods for java.applet.AppletContext */ - private static Map<URL, AudioClip> audioClips = new HashMap<URL, AudioClip>(); + final private static Map<URL, AudioClip> audioClips = new HashMap<>(); /** * Get an audio clip. @@ -800,7 +811,7 @@ } } - private static Map<URL, AppletImageRef> imageRefs = new HashMap<URL, AppletImageRef>(); + final private static Map<URL, AppletImageRef> imageRefs = new HashMap<>(); /** * Get an image. @@ -867,7 +878,7 @@ imageRefs.clear(); } - private static Vector<NetxPanel> appletPanels = new Vector<NetxPanel>(); + final private static Vector<NetxPanel> appletPanels = new Vector<>(); /** * Get an applet by name. @@ -1371,7 +1382,7 @@ /** * System parameters. */ - static Map<String, String> systemParam = new HashMap<String, String>(); + private final static Map<String, String> systemParam = new HashMap<>(); static { systemParam.put("codebase", "codebase"); @@ -1538,6 +1549,7 @@ /** * How many applets are running? + * @return number of applets run in this JVM */ public static int countApplets() {
--- a/plugin/icedteanp/java/sun/applet/PluginMain.java Wed Apr 15 10:43:53 2015 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginMain.java Thu Apr 16 19:34:18 2015 +0200 @@ -73,7 +73,6 @@ import java.net.ProxySelector; import java.net.URL; import java.net.URLStreamHandler; -import java.security.Permission; import java.util.Enumeration; import java.util.Map; import java.util.Properties; @@ -119,6 +118,8 @@ /** * The main entry point into AppletViewer. + * @param args regular command-line arguments to be passed from native part + * @throws java.io.IOException if IO issues occur */ public static void main(String args[]) throws IOException {
--- a/plugin/icedteanp/java/sun/applet/PluginProxySelector.java Wed Apr 15 10:43:53 2015 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginProxySelector.java Thu Apr 16 19:34:18 2015 +0200 @@ -63,7 +63,7 @@ public class PluginProxySelector extends JNLPProxySelector { - private TimedHashMap<String, Proxy> proxyCache = new TimedHashMap<>(); + private final TimedHashMap<String, Proxy> proxyCache = new TimedHashMap<>(); public PluginProxySelector(DeploymentConfiguration config) { super(config); @@ -78,7 +78,7 @@ @Override protected List<Proxy> getFromBrowser(URI uri) { - List<Proxy> proxyList = new ArrayList<Proxy>(); + List<Proxy> proxyList = new ArrayList<>(); // check cache first Proxy cachedProxy = checkCache(uri); @@ -133,7 +133,10 @@ return proxyList; } - /** For tests to override */ + /** For tests to override. + * @param uri of proxy + * @return information about proxy + */ protected Object getProxyFromRemoteCallToBrowser(String uri) { return PluginAppletViewer.requestPluginProxyInfo(uri); }