aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'netx/net/sourceforge/jnlp/runtime')
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java10
-rw-r--r--netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java6
-rw-r--r--netx/net/sourceforge/jnlp/runtime/Boot.java8
-rw-r--r--netx/net/sourceforge/jnlp/runtime/Boot13.java4
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java100
-rw-r--r--netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java11
6 files changed, 72 insertions, 67 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
index cd37c44..65032fe 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
@@ -57,7 +57,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
private Container cont;
/** weak references to the audio clips */
- private WeakList weakClips = new WeakList();
+ private WeakList<AppletAudioClip> weakClips = new WeakList<AppletAudioClip>();
/** whether the applet has been started / displayed */
private boolean appletStarted = false;
@@ -121,9 +121,9 @@ public class AppletEnvironment implements AppletContext, AppletStub {
public void destroy() {
destroyed = true;
- List clips = weakClips.hardList();
+ List<AppletAudioClip> clips = weakClips.hardList();
for (int i = 0; i < clips.size(); i++) {
- ((AppletAudioClip)clips.get(i)).dispose();
+ clips.get(i).dispose();
}
}
@@ -217,7 +217,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
* Returns an enumeration that contains only the applet
* from the JNLP file.
*/
- public Enumeration getApplets() {
+ public Enumeration<Applet> getApplets() {
checkDestroyed();
return Collections.enumeration( Arrays.asList(new Applet[] { applet }) );
@@ -293,7 +293,7 @@ public class AppletEnvironment implements AppletContext, AppletStub {
/**
* Required for JRE1.4, but not implemented yet.
*/
- public Iterator getStreamKeys() {
+ public Iterator<String> getStreamKeys() {
checkDestroyed();
return null;
diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
index 95ccb1e..b5266f0 100644
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
@@ -77,7 +77,7 @@ public class ApplicationInstance {
private boolean stopped = false;
/** weak list of windows opened by the application */
- private WeakList weakWindows = new WeakList();
+ private WeakList<Window> weakWindows = new WeakList<Window>();
/** list of application listeners */
private EventListenerList listeners = new EventListenerList();
@@ -193,7 +193,7 @@ public class ApplicationInstance {
// Add to hashmap
AccessControlContext acc = new AccessControlContext(new ProtectionDomain[] {pd});
- PrivilegedAction installProps = new PrivilegedAction() {
+ PrivilegedAction<Object> installProps = new PrivilegedAction<Object>() {
public Object run() {
for (int i=0; i < props.length; i++) {
System.setProperty(props[i].getKey(), props[i].getValue());
@@ -236,7 +236,7 @@ public class ApplicationInstance {
try {
// destroy resources
for (int i=0; i < weakWindows.size(); i++) {
- Window w = (Window) weakWindows.get(i);
+ Window w = weakWindows.get(i);
if (w != null)
w.dispose();
}
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot.java b/netx/net/sourceforge/jnlp/runtime/Boot.java
index 7442549..ea76bcb 100644
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java
@@ -58,7 +58,7 @@ import net.sourceforge.jnlp.services.ServiceUtil;
* @author <a href="mailto:[email protected]">Jon A. Maxwell (JAM)</a> - initial author
* @version $Revision: 1.21 $
*/
-public final class Boot implements PrivilegedAction {
+public final class Boot implements PrivilegedAction<Void> {
// todo: decide whether a spawned netx (external launch)
// should inherit the same options as this instance (store argv?)
@@ -199,7 +199,7 @@ public final class Boot implements PrivilegedAction {
/**
* The privileged part (jdk1.3 compatibility).
*/
- public Object run() {
+ public Void run() {
JNLPRuntime.setBaseDir(getBaseDir());
JNLPRuntime.setSecurityEnabled(null == getOption("-nosecurity"));
JNLPRuntime.initialize(true);
@@ -418,7 +418,7 @@ public final class Boot implements PrivilegedAction {
* returned once for each occurrence.
*/
private static String[] getOptions(String option) {
- List result = new ArrayList();
+ List<String> result = new ArrayList<String>();
for (int i=0; i < args.length; i++) {
if (option.equals(args[i])) {
@@ -433,7 +433,7 @@ public final class Boot implements PrivilegedAction {
i++;
}
- return (String[]) result.toArray( new String[result.size()] );
+ return result.toArray( new String[result.size()] );
}
/**
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot13.java b/netx/net/sourceforge/jnlp/runtime/Boot13.java
index 4440c5f..1b5aaa3 100644
--- a/netx/net/sourceforge/jnlp/runtime/Boot13.java
+++ b/netx/net/sourceforge/jnlp/runtime/Boot13.java
@@ -93,8 +93,8 @@ public class Boot13 extends URLClassLoader {
Thread.currentThread().setContextClassLoader(b); // try to prevent getting the non-policy version of classes
- Class c = b.loadClass("net.sourceforge.jnlp.runtime.Boot");
- Method main = c.getDeclaredMethod("main", new Class[] {String[].class} );
+ Class<?> c = b.loadClass("net.sourceforge.jnlp.runtime.Boot");
+ Method main = c.getDeclaredMethod("main", new Class<?>[] {String[].class} );
main.invoke(null, new Object[] { args } );
}
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();
}
diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
index 3934607..a143edb 100644
--- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java
@@ -98,10 +98,11 @@ class JNLPSecurityManager extends AWTSecurityManager {
new SecurityException(JNLPRuntime.getMessage("RShutdown"));
/** weak list of windows created */
- private WeakList weakWindows = new WeakList();
+ private WeakList<Window> weakWindows = new WeakList<Window>();
/** weak list of applications corresponding to window list */
- private WeakList weakApplications = new WeakList();
+ private WeakList<ApplicationInstance> weakApplications =
+ new WeakList<ApplicationInstance>();
/** weak reference to most app who's windows was most recently activated */
private WeakReference activeApplication = null;
@@ -182,14 +183,14 @@ class JNLPSecurityManager extends AWTSecurityManager {
*/
protected ApplicationInstance getApplication(Window window) {
for (int i = weakWindows.size(); i-->0;) {
- Window w = (Window) weakWindows.get(i);
+ Window w = weakWindows.get(i);
if (w == null) {
weakWindows.remove(i);
weakApplications.remove(i);
}
if (w == window)
- return (ApplicationInstance) weakApplications.get(i);
+ return weakApplications.get(i);
}
return null;
@@ -436,7 +437,7 @@ class JNLPSecurityManager extends AWTSecurityManager {
if (JNLPRuntime.isDebug())
System.err.println("SM: app: "+app.getTitle()+" is adding a window: "+window);
- weakWindows.add(window); // for mapping window -> app
+ weakWindows.add(w); // for mapping window -> app
weakApplications.add(app);
app.addWindow(w);