diff options
author | Andrew John Hughes <[email protected]> | 2010-10-21 21:12:21 +0100 |
---|---|---|
committer | Andrew John Hughes <[email protected]> | 2010-10-21 21:12:21 +0100 |
commit | 61aeaaf89164aa93280527c7eb80cf4c1432fbee (patch) | |
tree | 73a8266a319eadc6126f3196f35ccb28ef330bcf /netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | |
parent | 16d8de7b9030235bfc7e3cb8e6a480a08f6a46d8 (diff) |
Fix most warnings arising from NetX code.
2010-10-20 Andrew John Hughes <[email protected]>
* netx/javax/jnlp/ServiceManager.java:
(lookupTable): Add generic types.
* netx/net/sourceforge/jnlp/AppletDesc.java:
(parameters): Likewise.
(AppletDesc(String,String,URL,int,int,Map)): Likewise.
(getParameters()): Likewise.
* netx/net/sourceforge/jnlp/ApplicationDesc.java:
(getArguments()): Remove redundant cast.
(addArgument(String)): Add generic typing.
* netx/net/sourceforge/jnlp/ExtensionDesc.java:
(extToPart): Add generic types.
(eagerExtParts): Likewise.
* netx/net/sourceforge/jnlp/InformationDesc.java:
(info): Likewise.
(getIcons(Object)): Add generic typing.
(getAssociations()): Likewise.
(getRelatedContents()): Likewise.
(getItem(Object)): Likewise.
(getItems(Object)): Likewise.
(addItem(String,Object)): Likewise.
* netx/net/sourceforge/jnlp/JNLPFile.java:
(resources): Likewise.
(InformationDesc.getItems(Object)): Likewise.
(getResources(Class)): Likewise.
* netx/net/sourceforge/jnlp/LaunchException.java:
(getCauses()): Likewise.
* netx/net/sourceforge/jnlp/Launcher.java:
(launchApplication(JNLPFile)): Likewise.
* netx/net/sourceforge/jnlp/NetxPanel.java:
(NetxPanel(URL,Hashtable)): Likewise.
(NetxPanel(URL,Hashtable,boolean)): Likewise.
* netx/net/sourceforge/jnlp/Node.java:
(getChildNodes()): Likewise.
* netx/net/sourceforge/jnlp/Parser.java:
(getResources(Node,boolean)): Likewise.
(getInfo(Node)): Likewise.
(getInformationDesc(Node)): Likewise.
(getApplet(Node)): Likewise.
(getApplication(Node)): Likewise.
(splitString(String)): Likewise.
(getLocales(Node)): Likewise.
(getChildNodes(Node,String)): Likewise.
* netx/net/sourceforge/jnlp/PluginBridge.java:
Fix variable naming and add generic types.
(cacheJars): Changed from cache_jars.
(cacheExJars): Changed from cache_ex-jars.
(atts): Add generic typing.
(PluginBridge(URL,URL,String,String,int,int,Hashtable)): Likewise.
(getInformation(Locale)): Likewise.
(getResources(Locale,String,String)): Likewise.
(getJARs()): Avoid excessive copying; filtering already performed
by getResources in JNLPFile.
* netx/net/sourceforge/jnlp/ResourcesDesc.java:
(resources): Add generic typing.
(getJREs()): Likewise.
(getJARs()): Likewise.
(getJARs(String)): Likewise.
(getExtensions()): Likewise.
(getPackages()): Likewise.
(getPackages(String)): Likewise.
(getProperties()): Likewise.
(getPropertiesMap()): Likewise.
(getResources(Class)): Make generic.
* netx/net/sourceforge/jnlp/Version.java:
(matches(Version)): Add generic types.
(matchesAny(Version)): Likewise.
(matchesSingle(String)): Likewise.
(matches(String,String)): Likewise.
(equal(List,List)): Likewise.
(greater(List,List)): Likewise.
(compare(String,String)): Use Integer.valueOf.
(normalize(List,int)): Add generic types, using
a List of lists rather than an array of lists.
(getVersionStrings()): Add generic types.
(getParts()): Likewise.
* netx/net/sourceforge/jnlp/cache/CacheUtil.java:
(waitForResources(ApplicationInstance,ResourceTracker,
URL,String)): Likewise.
* netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java:
(getListener(ApplicatonInstance,String,URL)): Use setVisible instead
of show().
(disposeListener(DownloadServiceListener)): Use setVisible instead
of hide().
(DownloadPanel.urls): Add generic typing.
(DownloadPanel.panels): Likewise.
(DownloadPanel.update(URL,String,long,long,int)): Fix formatting.
Add generic types.
* netx/net/sourceforge/jnlp/cache/Resource.java:
(resources): Add generic typing.
(trackers): Likewise.
(getResource(URL,Version,UpdatePolicy)): Use generic types.
(getTracker()): Likewise.
(addTracker(ResourceTracker)): Likewise.
(fireDownloadEvent()): Likewise.
* netx/net/sourceforge/jnlp/cache/ResourceTracker.java:
(prefetchTrackers): Add generic typing.
(queue): Likewise.
(active): Likewise.
(resources): Likewise.
(listeners): Likewise.
(fireDownloadEvent(Resource)): Remove unneeded cast.
(getPrefetch()): Use generic typing.
(selectByFlag(List,int,int)): Likewise.
(getResource(URL)): Likewise.
* netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java:
(weakClips): Add generic types.
(destroy()): Use generic typing.
(getApplets()): Likewise.
(getStreamKeys()): Likewise.
* netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java:
(weakWindows): Add generic types.
(installEnvironment()): Likewise.
(destroy()): Remove redundant cast.
* netx/net/sourceforge/jnlp/runtime/Boot.java:
Extend PrivilegedAction<Void>.
(run()): Add generic typing.
(getOptions(String)): Likewise.
* netx/net/sourceforge/jnlp/runtime/Boot13.java:
(main(String[]): Likewise.
* netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java:
Fix formatting.
(urlToLoader): Add generic types.
(resourcePermissions): Likewise.
(available): Likewise.
(jarEntries): Likewise.
(getInstance(JNLPFile,UpdatePolicy)): Remove redundant cast.
(getInstance(URL,String,Version,UpdatePolicy)): Likewise.
(initializeExtensions()): Add generic types.
(initializePermissions()): Likewise.
(initializeResources()): Likewise.
(getPermissions(CodeSource)): Likewise.
(fillInPartJars(List)): Likewise.
(activateJars(List)): Likewise.
(loadClass(String)): Likewise. Suppress warnings due to
sun.misc.JarIndex usage.
(findResources(String)): Mark as overriding. Add generic
types.
(getExtensionName()): Add @Deprecated annotation.
(getExtensionHREF()): Likewise.
* netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java:
(weakWindows): Add generic typing.
(weakApplications): Likewise.
(getApplication(Window)): Remove redundant casts. Add w,
which is window cast to Window.
* netx/net/sourceforge/jnlp/services/ServiceUtil.java:
(invoke(Object,Method,Object[])): Use generic types.
* netx/net/sourceforge/jnlp/services/XPersistenceService.java:
(getNames(URL)): Likewise.
* netx/net/sourceforge/jnlp/tools/JarSigner.java:
(verifyJars(List,ResourceTracker)): Remove redundant cast.
* netx/net/sourceforge/jnlp/util/WeakList.java:
Redesign as a generic type.
(refs): Add generic types.
(deref(WeakReference)): Likewise.
(get(int)): Likewise.
(set(int,Object)): Likewise.
(add(int,E)): Likewise.
(remove()): Likewise.
(hardList()): Likewise.
* netx/net/sourceforge/nanoxml/XMLElement.java:
(attributes): Add generic typing.
(children): Likewise.
(entities): Likewise.
(XMLElement()): Use generic types.
(XMLElement(Hashtable): Likewise.
(resolveEntity(StringBuffer)): Remove redundant cast.
Diffstat (limited to 'netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java')
-rw-r--r-- | netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 100 |
1 files changed, 52 insertions, 48 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java index 9ce6f46..3dc1939 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java @@ -81,7 +81,8 @@ public class JNLPClassLoader extends URLClassLoader { private static String R(String key) { return JNLPRuntime.getMessage(key); } /** map from JNLPFile url to shared classloader */ - private static Map urlToLoader = new HashMap(); // never garbage collected! + private static Map<String,JNLPClassLoader> urlToLoader = + new HashMap<String,JNLPClassLoader>(); // never garbage collected! /** the directory for native code */ private File nativeDir = null; // if set, some native code exists @@ -93,7 +94,7 @@ public class JNLPClassLoader extends URLClassLoader { private AccessControlContext acc = AccessController.getContext(); /** the permissions for the cached jar files */ - private List resourcePermissions; + private List<Permission> resourcePermissions; /** the app */ private ApplicationInstance app = null; // here for faster lookup in security manager @@ -123,27 +124,28 @@ public class JNLPClassLoader extends URLClassLoader { private ArrayList<Permission> runtimePermissions = new ArrayList<Permission>(); /** all jars not yet part of classloader or active */ - private List available = new ArrayList(); + private List<JARDesc> available = new ArrayList<JARDesc>(); - /** all of the jar files that were verified */ - private ArrayList<String> verifiedJars = null; + /** all of the jar files that were verified */ + private ArrayList<String> verifiedJars = null; - /** all of the jar files that were not verified */ - private ArrayList<String> unverifiedJars = null; + /** all of the jar files that were not verified */ + private ArrayList<String> unverifiedJars = null; - /** the jarsigner tool to verify our jars */ - private JarSigner js = null; + /** the jarsigner tool to verify our jars */ + private JarSigner js = null; - private boolean signing = false; + private boolean signing = false; - /** ArrayList containing jar indexes for various jars available to this classloader */ - private ArrayList<JarIndex> jarIndexes = new ArrayList<JarIndex>(); + /** ArrayList containing jar indexes for various jars available to this classloader */ + private ArrayList<JarIndex> jarIndexes = new ArrayList<JarIndex>(); - /** File entries in the jar files available to this classloader */ - private TreeSet jarEntries = new TreeSet(); + /** File entries in the jar files available to this classloader */ + private TreeSet<String> jarEntries = new TreeSet<String>(); - /** Map of specific codesources to securitydesc */ - private HashMap<URL, SecurityDesc> jarLocationSecurityMap = new HashMap<URL, SecurityDesc>(); + /** Map of specific codesources to securitydesc */ + private HashMap<URL, SecurityDesc> jarLocationSecurityMap = + new HashMap<URL, SecurityDesc>(); /** * Create a new JNLPClassLoader from the specified file. @@ -273,7 +275,7 @@ public class JNLPClassLoader extends URLClassLoader { String uniqueKey = file.getUniqueKey(); if (uniqueKey != null) - baseLoader = (JNLPClassLoader) urlToLoader.get(uniqueKey); + baseLoader = urlToLoader.get(uniqueKey); try { @@ -286,7 +288,7 @@ public class JNLPClassLoader extends URLClassLoader { // New loader init may have caused extentions to create a // loader for this unique key. Check. - JNLPClassLoader extLoader = (JNLPClassLoader) urlToLoader.get(uniqueKey); + JNLPClassLoader extLoader = urlToLoader.get(uniqueKey); if (extLoader != null && extLoader != loader) { if (loader.signing && !extLoader.signing) @@ -328,7 +330,7 @@ public class JNLPClassLoader extends URLClassLoader { */ public static JNLPClassLoader getInstance(URL location, String uniqueKey, Version version, UpdatePolicy policy) throws IOException, ParseException, LaunchException { - JNLPClassLoader loader = (JNLPClassLoader) urlToLoader.get(uniqueKey); + JNLPClassLoader loader = urlToLoader.get(uniqueKey); if (loader == null || !location.equals(loader.getJNLPFile().getFileLocation())) loader = getInstance(new JNLPFile(location, uniqueKey, version, false, policy), policy); @@ -342,7 +344,7 @@ public class JNLPClassLoader extends URLClassLoader { void initializeExtensions() { ExtensionDesc[] ext = resources.getExtensions(); - List loaderList = new ArrayList(); + List<JNLPClassLoader> loaderList = new ArrayList<JNLPClassLoader>(); loaderList.add(this); @@ -359,14 +361,14 @@ public class JNLPClassLoader extends URLClassLoader { } //} - loaders = (JNLPClassLoader[]) loaderList.toArray(new JNLPClassLoader[ loaderList.size()]); + loaders = loaderList.toArray(new JNLPClassLoader[loaderList.size()]); } /** * Make permission objects for the classpath. */ void initializePermissions() { - resourcePermissions = new ArrayList(); + resourcePermissions = new ArrayList<Permission>(); JARDesc jars[] = resources.getJARs(); for (int i=0; i < jars.length; i++) { @@ -398,7 +400,7 @@ public class JNLPClassLoader extends URLClassLoader { R("LCInit"), R("LFatalVerification"), "No jars!"); } */ - List initialJars = new ArrayList(); + List<JARDesc> initialJars = new ArrayList<JARDesc>(); for (int i=0; i < jars.length; i++) { @@ -585,7 +587,7 @@ public class JNLPClassLoader extends URLClassLoader { // add in permission to read the cached JAR files for (int i=0; i < resourcePermissions.size(); i++) - result.add((Permission) resourcePermissions.get(i)); + result.add(resourcePermissions.get(i)); // add in the permissions that the user granted. for (int i=0; i < runtimePermissions.size(); i++) @@ -603,12 +605,12 @@ public class JNLPClassLoader extends URLClassLoader { * to be loaded at the same time as the JARs specified (ie, are * in the same part). */ - protected void fillInPartJars(List jars) { + protected void fillInPartJars(List<JARDesc> jars) { for (int i=0; i < jars.size(); i++) { - String part = ((JARDesc) jars.get(i)).getPart(); + String part = jars.get(i).getPart(); for (int a=0; a < available.size(); a++) { - JARDesc jar = (JARDesc) available.get(a); + JARDesc jar = available.get(a); if (part != null && part.equals(jar.getPart())) if (!jars.contains(jar)) @@ -625,15 +627,15 @@ public class JNLPClassLoader extends URLClassLoader { * * @param jars the list of jars to load */ - protected void activateJars(final List jars) { - PrivilegedAction activate = new PrivilegedAction() { + protected void activateJars(final List<JARDesc> jars) { + PrivilegedAction<Void> activate = new PrivilegedAction<Void>() { - public Object run() { + public Void run() { // transfer the Jars waitForJars(jars); for (int i=0; i < jars.size(); i++) { - JARDesc jar = (JARDesc) jars.get(i); + JARDesc jar = jars.get(i); available.remove(jar); @@ -653,10 +655,9 @@ public class JNLPClassLoader extends URLClassLoader { // particularly when using The FileManager applet from Webmin. JarFile jarFile = new JarFile(localFile); - Enumeration e = jarFile.entries(); + Enumeration<JarEntry> e = jarFile.entries(); while (e.hasMoreElements()) { - - JarEntry je = (JarEntry) e.nextElement(); + JarEntry je = e.nextElement(); // another jar in my jar? it is more likely than you think if (je.getName().endsWith(".jar")) { @@ -683,10 +684,10 @@ public class JNLPClassLoader extends URLClassLoader { is.close(); extractedJar.close(); - + // 0 byte file? skip if (fileSize <= 0) { - continue; + continue; } JarSigner signer = new JarSigner(); @@ -739,8 +740,8 @@ public class JNLPClassLoader extends URLClassLoader { // there is currently no mechanism to cache files per // instance.. so only index cached files if (localFile != null) { - JarIndex index = JarIndex.getJarIndex(new JarFile(localFile.getAbsolutePath()), null); - + JarIndex index = JarIndex.getJarIndex(new JarFile(localFile.getAbsolutePath()), + null); if (index != null) jarIndexes.add(index); } @@ -945,9 +946,9 @@ public class JNLPClassLoader extends URLClassLoader { * classloader, or one of the classloaders for the JNLP file's * extensions. */ - public Class loadClass(String name) throws ClassNotFoundException { + public Class<?> loadClass(String name) throws ClassNotFoundException { - Class result = findLoadedClassAll(name); + Class<?> result = findLoadedClassAll(name); // try parent classloader if (result == null) { @@ -975,7 +976,9 @@ public class JNLPClassLoader extends URLClassLoader { // Currently this loads jars directly from the site. We cannot cache it because this // call is initiated from within the applet, which does not have disk read/write permissions for (JarIndex index: jarIndexes) { - LinkedList<String> jarList = index.get(name.replace('.', '/')); + // Non-generic code in sun.misc.JarIndex + @SuppressWarnings("unchecked") + LinkedList<String> jarList = index.get(name.replace('.', '/')); if (jarList != null) { for (String jarName: jarList) { @@ -1090,11 +1093,12 @@ public class JNLPClassLoader extends URLClassLoader { * Finds the resource in this, the parent, or the extension * class loaders. */ - public Enumeration findResources(String name) throws IOException { - Vector resources = new Vector(); + @Override + public Enumeration<URL> findResources(String name) throws IOException { + Vector<URL> resources = new Vector<URL>(); for (int i=0; i < loaders.length; i++) { - Enumeration e; + Enumeration<URL> e; if (loaders[i] == this) e = super.findResources(name); @@ -1151,13 +1155,11 @@ public class JNLPClassLoader extends URLClassLoader { } // add jar - List jars = new ArrayList(); + List<JARDesc> jars = new ArrayList<JARDesc>(); jars.add(available.get(0)); fillInPartJars(jars); - - - activateJars(jars); + activateJars(jars); return this; } @@ -1166,6 +1168,7 @@ public class JNLPClassLoader extends URLClassLoader { /** * @deprecated */ + @Deprecated public String getExtensionName() { String result = file.getInformation().getTitle(); @@ -1182,6 +1185,7 @@ public class JNLPClassLoader extends URLClassLoader { /** * @deprecated */ + @Deprecated public String getExtensionHREF() { return file.getFileLocation().toString(); } |