aboutsummaryrefslogtreecommitdiffstats
path: root/netx
diff options
context:
space:
mode:
Diffstat (limited to 'netx')
-rw-r--r--netx/javax/jnlp/ServiceManager.java3
-rw-r--r--netx/net/sourceforge/jnlp/AppletDesc.java11
-rw-r--r--netx/net/sourceforge/jnlp/ApplicationDesc.java6
-rw-r--r--netx/net/sourceforge/jnlp/ExtensionDesc.java4
-rw-r--r--netx/net/sourceforge/jnlp/InformationDesc.java25
-rw-r--r--netx/net/sourceforge/jnlp/JNLPFile.java12
-rw-r--r--netx/net/sourceforge/jnlp/LaunchException.java4
-rw-r--r--netx/net/sourceforge/jnlp/Launcher.java6
-rw-r--r--netx/net/sourceforge/jnlp/NetxPanel.java5
-rw-r--r--netx/net/sourceforge/jnlp/Node.java4
-rw-r--r--netx/net/sourceforge/jnlp/Parser.java35
-rw-r--r--netx/net/sourceforge/jnlp/PluginBridge.java140
-rw-r--r--netx/net/sourceforge/jnlp/ResourcesDesc.java50
-rw-r--r--netx/net/sourceforge/jnlp/Version.java59
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheUtil.java4
-rw-r--r--netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java14
-rw-r--r--netx/net/sourceforge/jnlp/cache/Resource.java17
-rw-r--r--netx/net/sourceforge/jnlp/cache/ResourceTracker.java25
-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
-rw-r--r--netx/net/sourceforge/jnlp/services/ServiceUtil.java2
-rw-r--r--netx/net/sourceforge/jnlp/services/XPersistenceService.java4
-rw-r--r--netx/net/sourceforge/jnlp/tools/JarSigner.java2
-rw-r--r--netx/net/sourceforge/jnlp/util/WeakList.java28
-rw-r--r--netx/net/sourceforge/nanoxml/XMLElement.java23
29 files changed, 315 insertions, 307 deletions
diff --git a/netx/javax/jnlp/ServiceManager.java b/netx/javax/jnlp/ServiceManager.java
index 3488b3c..7e6fb36 100644
--- a/netx/javax/jnlp/ServiceManager.java
+++ b/netx/javax/jnlp/ServiceManager.java
@@ -10,7 +10,8 @@ public final class ServiceManager {
private static ServiceManagerStub stub = null;
- private static Map lookupTable = new HashMap(); // ensure lookup is idempotent
+ private static Map<String,Object> lookupTable
+ = new HashMap<String,Object>(); // ensure lookup is idempotent
private ServiceManager() {
// says it can't be instantiated
diff --git a/netx/net/sourceforge/jnlp/AppletDesc.java b/netx/net/sourceforge/jnlp/AppletDesc.java
index 1563b87..39133ce 100644
--- a/netx/net/sourceforge/jnlp/AppletDesc.java
+++ b/netx/net/sourceforge/jnlp/AppletDesc.java
@@ -45,7 +45,7 @@ public class AppletDesc {
private int height;
/** the parameters */
- private Map parameters;
+ private Map<String,String> parameters;
/**
@@ -58,13 +58,14 @@ public class AppletDesc {
* @param height the height
* @param parameters the parameters
*/
- public AppletDesc(String name, String mainClass, URL documentBase, int width, int height, Map parameters) {
+ public AppletDesc(String name, String mainClass, URL documentBase, int width, int height,
+ Map<String,String> parameters) {
this.name = name;
this.mainClass = mainClass;
this.documentBase = documentBase;
this.width = width;
this.height = height;
- this.parameters = new HashMap(parameters);
+ this.parameters = new HashMap<String,String>(parameters);
}
/**
@@ -105,8 +106,8 @@ public class AppletDesc {
/**
* Returns the applet parameters
*/
- public Map getParameters() {
- return new HashMap(parameters);
+ public Map<String,String> getParameters() {
+ return new HashMap<String,String>(parameters);
}
/**
diff --git a/netx/net/sourceforge/jnlp/ApplicationDesc.java b/netx/net/sourceforge/jnlp/ApplicationDesc.java
index cb5c458..221eaac 100644
--- a/netx/net/sourceforge/jnlp/ApplicationDesc.java
+++ b/netx/net/sourceforge/jnlp/ApplicationDesc.java
@@ -58,17 +58,17 @@ public class ApplicationDesc {
* Returns the arguments
*/
public String[] getArguments() {
- return (String[]) arguments.clone();
+ return arguments.clone();
}
/**
* Add an argument to the end of the arguments.
*/
public void addArgument(String arg) {
- ArrayList l = new ArrayList(Arrays.asList(arguments));
+ List<String> l = new ArrayList<String>(Arrays.asList(arguments));
l.add(arg);
- arguments = (String[]) l.toArray(arguments);
+ arguments = l.toArray(arguments);
}
}
diff --git a/netx/net/sourceforge/jnlp/ExtensionDesc.java b/netx/net/sourceforge/jnlp/ExtensionDesc.java
index 2202058..f744715 100644
--- a/netx/net/sourceforge/jnlp/ExtensionDesc.java
+++ b/netx/net/sourceforge/jnlp/ExtensionDesc.java
@@ -45,10 +45,10 @@ public class ExtensionDesc {
private JNLPFile file;
/** map from ext-part to local part */
- private Map extToPart = new HashMap();
+ private Map<String,String> extToPart = new HashMap<String,String>();
/** eager ext parts */
- private List eagerExtParts = new ArrayList();
+ private List<String> eagerExtParts = new ArrayList<String>();
/**
diff --git a/netx/net/sourceforge/jnlp/InformationDesc.java b/netx/net/sourceforge/jnlp/InformationDesc.java
index cd039a0..076b6b3 100644
--- a/netx/net/sourceforge/jnlp/InformationDesc.java
+++ b/netx/net/sourceforge/jnlp/InformationDesc.java
@@ -52,7 +52,7 @@ public class InformationDesc {
private Locale locales[];
/** the data as list of key,value pairs */
- private List info;
+ private List<Object> info;
/** the JNLPFile this information is for */
private JNLPFile jnlpFile;
@@ -129,9 +129,9 @@ public class InformationDesc {
* @return an array of zero of more IconDescs of the specified icon type
*/
public IconDesc[] getIcons(Object kind) {
- List icons = getItems("icon-"+kind);
+ List<Object> icons = getItems("icon-"+kind);
- return (IconDesc[]) icons.toArray(new IconDesc[icons.size()]);
+ return icons.toArray(new IconDesc[icons.size()]);
};
/**
@@ -204,9 +204,9 @@ public class InformationDesc {
* Returns the associations specified in the JNLP file
*/
public AssociationDesc[] getAssociations() {
- List associations = getItems("association");
+ List<Object> associations = getItems("association");
- return (AssociationDesc[]) associations.toArray(new AssociationDesc[associations.size()]);
+ return associations.toArray(new AssociationDesc[associations.size()]);
}
/**
@@ -220,17 +220,16 @@ public class InformationDesc {
* Returns the related-contents specified by this JNLP file
*/
public RelatedContentDesc[] getRelatedContents() {
- List relatedContents = getItems("related-content");
+ List<Object> relatedContents = getItems("related-content");
- return (RelatedContentDesc[]) relatedContents.toArray(
- new RelatedContentDesc[relatedContents.size()]);
+ return relatedContents.toArray(new RelatedContentDesc[relatedContents.size()]);
}
/**
* Returns the last item matching the specified key.
*/
protected Object getItem(Object key) {
- List items = getItems(key);
+ List<Object> items = getItems(key);
if (items.size() == 0)
return null;
else
@@ -240,11 +239,11 @@ public class InformationDesc {
/**
* Returns all items matching the specified key.
*/
- protected List getItems(Object key) {
+ protected List<Object> getItems(Object key) {
if (info == null)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
- List result = new ArrayList();
+ List<Object> result = new ArrayList<Object>();
for (int i=0; i < info.size(); i+=2)
if (info.get(i).equals(key))
result.add( info.get(i+1) );
@@ -258,7 +257,7 @@ public class InformationDesc {
*/
protected void addItem(String key, Object value) {
if (info == null)
- info = new ArrayList();
+ info = new ArrayList<Object>();
info.add(key);
info.add(value);
diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java
index a02ca1e..48fa9e2 100644
--- a/netx/net/sourceforge/jnlp/JNLPFile.java
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java
@@ -86,7 +86,7 @@ public class JNLPFile {
protected UpdateDesc update;
/** resources */
- protected List resources;
+ protected List<ResourcesDesc> resources;
/** additional resources not in JNLP file (from command line) */
protected ResourcesDesc sharedResources = new ResourcesDesc(this, null, null, null);
@@ -330,8 +330,8 @@ public class JNLPFile {
*/
public InformationDesc getInformation(final Locale locale) {
return new InformationDesc(this, new Locale[] {locale}) {
- protected List getItems(Object key) {
- List result = new ArrayList();
+ protected List<Object> getItems(Object key) {
+ List<Object> result = new ArrayList<Object>();
for (int i=0; i < info.size(); i++) {
InformationDesc infoDesc = (InformationDesc) info.get(i);
@@ -375,11 +375,11 @@ public class JNLPFile {
*/
public ResourcesDesc getResources(final Locale locale, final String os, final String arch) {
return new ResourcesDesc(this, new Locale[] {locale}, new String[] {os}, new String[] {arch}) {
- public List getResources(Class launchType) {
- List result = new ArrayList();
+ public <T> List<T> getResources(Class<T> launchType) {
+ List<T> result = new ArrayList<T>();
for (int i=0; i < resources.size(); i++) {
- ResourcesDesc rescDesc = (ResourcesDesc) resources.get(i);
+ ResourcesDesc rescDesc = resources.get(i);
if (localMatches(locale, rescDesc.getLocales())
&& stringMatches(os, rescDesc.getOS())
diff --git a/netx/net/sourceforge/jnlp/LaunchException.java b/netx/net/sourceforge/jnlp/LaunchException.java
index 2ddd0ad..2666387 100644
--- a/netx/net/sourceforge/jnlp/LaunchException.java
+++ b/netx/net/sourceforge/jnlp/LaunchException.java
@@ -146,7 +146,7 @@ public class LaunchException extends Exception {
* and will be removed once netx no longer supports 1.3.
*/
public Throwable[] getCauses() {
- ArrayList result = new ArrayList();
+ ArrayList<Throwable> result = new ArrayList<Throwable>();
Reflect r = new Reflect();
Throwable cause = this.cause;
@@ -156,7 +156,7 @@ public class LaunchException extends Exception {
cause = (Throwable) r.invoke(cause, "getCause");
}
- return (Throwable[]) result.toArray(new Throwable[0]);
+ return result.toArray(new Throwable[0]);
}
/**
diff --git a/netx/net/sourceforge/jnlp/Launcher.java b/netx/net/sourceforge/jnlp/Launcher.java
index fbd8a60..6493315 100644
--- a/netx/net/sourceforge/jnlp/Launcher.java
+++ b/netx/net/sourceforge/jnlp/Launcher.java
@@ -455,11 +455,11 @@ public class Launcher {
R("LSFatal"), R("LCClient"), R("LCantDetermineMainClass") ,
R("LCantDetermineMainClassInfo")));
- Class mainClass = app.getClassLoader().loadClass(mainName);
+ Class<?> mainClass = app.getClassLoader().loadClass(mainName);
- Method main = mainClass.getMethod("main", new Class[] {String[].class} );
+ Method main = mainClass.getMethod("main", new Class<?>[] {String[].class} );
String args[] = file.getApplication().getArguments();
-
+
SwingUtilities.invokeAndWait(new Runnable() {
// dummy method to force Event Dispatch Thread creation
public void run(){}
diff --git a/netx/net/sourceforge/jnlp/NetxPanel.java b/netx/net/sourceforge/jnlp/NetxPanel.java
index 7c6cf3c..977451d 100644
--- a/netx/net/sourceforge/jnlp/NetxPanel.java
+++ b/netx/net/sourceforge/jnlp/NetxPanel.java
@@ -45,13 +45,14 @@ public class NetxPanel extends AppletViewerPanel
private AppletInstance appInst = null;
private boolean appletAlive;
- public NetxPanel(URL documentURL, Hashtable atts)
+ public NetxPanel(URL documentURL, Hashtable<String,String> atts)
{
super(documentURL, atts);
}
// overloaded constructor, called when initialized via plugin
- public NetxPanel(URL documentURL, Hashtable atts, boolean exitOnFailure)
+ public NetxPanel(URL documentURL, Hashtable<String,String> atts,
+ boolean exitOnFailure)
{
this(documentURL, atts);
this.exitOnFailure = exitOnFailure;
diff --git a/netx/net/sourceforge/jnlp/Node.java b/netx/net/sourceforge/jnlp/Node.java
index 0868103..a3f0aa2 100644
--- a/netx/net/sourceforge/jnlp/Node.java
+++ b/netx/net/sourceforge/jnlp/Node.java
@@ -47,12 +47,12 @@ class Node {
Node[] getChildNodes() {
if (children == null) {
- List list = new ArrayList();
+ List<Node> list = new ArrayList<Node>();
for (Enumeration e = xml.enumerateChildren(); e.hasMoreElements();)
list.add( new Node((XMLElement)e.nextElement()) );
- children = (Node[]) list.toArray( new Node[list.size()] );
+ children = list.toArray( new Node[list.size()] );
for (int i=0; i < children.length-1; i++)
children[i].next = children[i+1];
diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java
index 9c44f69..758b00d 100644
--- a/netx/net/sourceforge/jnlp/Parser.java
+++ b/netx/net/sourceforge/jnlp/Parser.java
@@ -239,8 +239,10 @@ class Parser {
* @param j2se true if the resources are located under a j2se or java node
* @throws ParseException if the JNLP file is invalid
*/
- public List getResources(Node parent, boolean j2se) throws ParseException {
- List result = new ArrayList();
+ public List<ResourcesDesc> getResources(Node parent, boolean j2se)
+ throws ParseException
+ {
+ List<ResourcesDesc> result = new ArrayList<ResourcesDesc>();
Node resources[] = getChildNodes(parent, "resources");
// ensure that there are at least one information section present
@@ -433,8 +435,10 @@ class Parser {
* @param parent the parent node (jnlp)
* @throws ParseException if the JNLP file is invalid
*/
- public List getInfo(Node parent) throws ParseException {
- List result = new ArrayList();
+ public List<InformationDesc> getInfo(Node parent)
+ throws ParseException
+ {
+ List<InformationDesc> result = new ArrayList<InformationDesc>();
Node info[] = getChildNodes(parent, "information");
// ensure that there are at least one information section present
@@ -455,7 +459,7 @@ class Parser {
* @throws ParseException if the JNLP file is invalid
*/
public InformationDesc getInformationDesc(Node node) throws ParseException {
- List descriptionsUsed = new ArrayList();
+ List<String> descriptionsUsed = new ArrayList<String>();
// locale
Locale locales[] = getLocales(node);
@@ -642,7 +646,7 @@ class Parser {
String name = getRequiredAttribute(node, "name", R("PUnknownApplet"));
String main = getRequiredAttribute(node, "main-class", null);
URL docbase = getURL(node, "documentbase", base);
- Map paramMap = new HashMap();
+ Map<String,String> paramMap = new HashMap<String,String>();
int width = 0;
int height = 0;
@@ -673,7 +677,7 @@ class Parser {
*/
public ApplicationDesc getApplication(Node node) throws ParseException {
String main = getAttribute(node, "main-class", null);
- List argsList = new ArrayList();
+ List<String> argsList = new ArrayList<String>();
// if (main == null)
// only ok if can be found in main jar file (can't check here but make a note)
@@ -687,8 +691,7 @@ class Parser {
argsList.add( getSpanText(args[i]) );
}
- String argStrings[] =
- (String[]) argsList.toArray( new String[argsList.size()] );
+ String argStrings[] = argsList.toArray( new String[argsList.size()] );
return new ApplicationDesc(main, argStrings);
}
@@ -825,9 +828,9 @@ class Parser {
if (source == null)
return new String[0];
- List result = new ArrayList();
+ List<String> result = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(source, " ");
- StringBuffer part = new StringBuffer();
+ StringBuilder part = new StringBuilder();
while (st.hasMoreTokens()) {
part.setLength(0);
@@ -849,7 +852,7 @@ class Parser {
result.add( part.toString() );
}
- return (String[]) result.toArray(new String[result.size()] );
+ return result.toArray(new String[result.size()] );
}
/**
@@ -858,7 +861,7 @@ class Parser {
* @param node the node with a locale attribute
*/
public Locale[] getLocales(Node node) {
- List locales = new ArrayList();
+ List<Locale> locales = new ArrayList<Locale>();
String localeParts[] =
splitString(getAttribute(node, "locale", ""));
@@ -868,7 +871,7 @@ class Parser {
locales.add(l);
}
- return (Locale[]) locales.toArray(new Locale[locales.size()] );
+ return locales.toArray(new Locale[locales.size()] );
}
/**
@@ -936,7 +939,7 @@ class Parser {
* Returns all child nodes with the specified name.
*/
public static Node[] getChildNodes(Node node, String name) {
- List result = new ArrayList();
+ List<Node> result = new ArrayList<Node>();
Node child = node.getFirstChild();
while (child != null) {
@@ -945,7 +948,7 @@ class Parser {
child = child.getNextSibling();
}
- return (Node[]) result.toArray( new Node[result.size()] );
+ return result.toArray( new Node[result.size()] );
}
diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java
index 9c847e5..9312097 100644
--- a/netx/net/sourceforge/jnlp/PluginBridge.java
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java
@@ -40,64 +40,65 @@ public class PluginBridge extends JNLPFile
String name;
String[] jars = new String[0];
- String[] cache_jars = new String[0];
- String[] cache_ex_jars = new String[0];
- Hashtable atts;
+ String[] cacheJars = new String[0];
+ String[] cacheExJars = new String[0];
+ Hashtable<String,String> atts;
public PluginBridge(URL codebase, URL documentBase, String jar, String main,
- int width, int height, Hashtable atts)
+ int width, int height, Hashtable<String,String> atts)
throws Exception
{
specVersion = new Version("1.0");
fileVersion = new Version("1.1");
this.codeBase = codebase;
this.sourceLocation = documentBase;
-
+
if (atts.containsKey("jnlp_href")){
try {
- URL jnlp = new URL(codeBase.toExternalForm() + (String) atts.get("jnlp_href"));
- JNLPFile jnlp_file = new JNLPFile(jnlp);
- Map jnlp_params = jnlp_file.getApplet().getParameters();
-
+ URL jnlp = new URL(codeBase.toExternalForm() + atts.get("jnlp_href"));
+ JNLPFile jnlpFile = new JNLPFile(jnlp);
+ Map<String,String> jnlpParams = jnlpFile.getApplet().getParameters();
+
// Change the parameter name to lowercase to follow conventions.
- Iterator it = jnlp_params.keySet().iterator();
- while(it.hasNext()){
- String key = (String) it.next();
- atts.put(key.toLowerCase(), jnlp_params.get(key));
+ for (Map.Entry<String,String> entry : jnlpParams.entrySet()){
+ atts.put(entry.getKey().toLowerCase(), entry.getValue());
}
} catch (MalformedURLException e) {
// Don't fail because we cannot get the jnlp file. Parameters are optional not required.
// it is the site developer who should ensure that file exist.
- System.err.println("Unable to get JNLP file at: " + codeBase.toExternalForm()
- + (String) atts.get("jnlp_href"));
+ System.err.println("Unable to get JNLP file at: " + codeBase.toExternalForm()
+ + atts.get("jnlp_href"));
}
}
// also, see if cache_archive is specified
- if (atts.get("cache_archive") != null && ((String) atts.get("cache_archive")).length() > 0) {
+ String cacheArchive = atts.get("cache_archive");
+ if (cacheArchive != null && cacheArchive.length() > 0) {
String[] versions = new String[0];
// are there accompanying versions?
- if (atts.get("cache_version") != null) {
- versions = ((String) atts.get("cache_version")).split(",");
+ String cacheVersion = atts.get("cache_version");
+ if (cacheVersion != null) {
+ versions = cacheVersion.split(",");
}
- String[] jars = ((String) atts.get("cache_archive")).split(",");
- cache_jars = new String[jars.length];
+ String[] jars = cacheArchive.split(",");
+ cacheJars = new String[jars.length];
for (int i=0; i < jars.length; i++) {
- cache_jars[i] = jars[i].trim();
+ cacheJars[i] = jars[i].trim();
if (versions.length > 0) {
- cache_jars[i] += ";" + versions[i].trim();
+ cacheJars[i] += ";" + versions[i].trim();
}
}
}
- if (atts.get("cache_archive_ex") != null && ((String) atts.get("cache_archive_ex")).length() > 0) {
- cache_ex_jars = ((String) atts.get("cache_archive_ex")).split(",");
+ String cacheArchiveEx = atts.get("cache_archive_ex");
+ if (cacheArchiveEx != null && cacheArchiveEx.length() > 0) {
+ cacheExJars = cacheArchiveEx.split(",");
}
if (jar != null && jar.length() > 0) {
@@ -109,7 +110,7 @@ public class PluginBridge extends JNLPFile
}
this.atts = atts;
- name = (String) atts.get("name");
+ name = atts.get("name");
if (name == null)
name = "Applet";
else
@@ -140,11 +141,10 @@ public class PluginBridge extends JNLPFile
public InformationDesc getInformation(final Locale locale)
{
return new InformationDesc(this, new Locale[] {locale}) {
- protected List getItems(Object key)
+ protected List<Object> getItems(Object key)
{
// Should we populate this list with applet attribute tags?
- List result = new ArrayList();
- return result;
+ return new ArrayList<Object>();
}
};
}
@@ -153,102 +153,92 @@ public class PluginBridge extends JNLPFile
final String arch)
{
return new ResourcesDesc(this, new Locale[] {locale}, new String[] {os},
- new String[] {arch}) {
- public List getResources(Class launchType)
+ new String[] {arch}) {
+ @Override
+ public <T> List<T> getResources(Class<T> launchType)
{
- List result = new ArrayList();
- result.addAll(sharedResources.getResources(launchType));
-
// Need to add the JAR manually...
//should this be done to sharedResources on init?
- try
+ if (launchType.equals(JARDesc.class))
{
- if (launchType.equals(JARDesc.class))
+ try
{
+ List<JARDesc> jarDescs = new ArrayList<JARDesc>();
+ jarDescs.addAll(sharedResources.getResources(JARDesc.class));
+
for (int i = 0; i < jars.length; i++)
if (jars[i].length() > 0)
- result.add(new JARDesc(new URL(codeBase, jars[i]),
+ jarDescs.add(new JARDesc(new URL(codeBase, jars[i]),
null, null, false, true, false, true));
boolean cacheable = true;
- if (atts.get("cache_option") != null &&
- ((String) atts.get("cache_option")).equalsIgnoreCase("no"))
+ String cacheOption = atts.get("cache_option");
+ if (cacheOption != null && cacheOption.equalsIgnoreCase("no"))
cacheable = false;
- for (int i = 0; i < cache_jars.length; i++) {
+ for (int i = 0; i < cacheJars.length; i++) {
- String[] jar_and_ver = cache_jars[i].split(";");
+ String[] jarAndVer = cacheJars[i].split(";");
- String jar = jar_and_ver[0];
+ String jar = jarAndVer[0];
Version version = null;
if (jar.length() == 0)
continue;
- if (jar_and_ver.length > 1) {
- version = new Version(jar_and_ver[1]);
+ if (jarAndVer.length > 1) {
+ version = new Version(jarAndVer[1]);
}
- result.add(new JARDesc(new URL(codeBase, jar),
+ jarDescs.add(new JARDesc(new URL(codeBase, jar),
version, null, false, true, false, cacheable));
}
- for (int i = 0; i < cache_ex_jars.length; i++) {
+ for (int i = 0; i < cacheExJars.length; i++) {
- if (cache_ex_jars[i].length() == 0)
+ if (cacheExJars[i].length() == 0)
continue;
- String[] jar_info = cache_ex_jars[i].split(";");
+ String[] jarInfo = cacheExJars[i].split(";");
- String jar = jar_info[0].trim();
+ String jar = jarInfo[0].trim();
Version version = null;
boolean lazy = true;
- if (jar_info.length > 1) {
+ if (jarInfo.length > 1) {
// format is name[[;preload];version]
- if (jar_info[1].equals("preload")) {
+ if (jarInfo[1].equals("preload")) {
lazy = false;
} else {
- version = new Version(jar_info[1].trim());
+ version = new Version(jarInfo[1].trim());
}
- if (jar_info.length > 2) {
+ if (jarInfo.length > 2) {
lazy = false;
- version = new Version(jar_info[2].trim());
+ version = new Version(jarInfo[2].trim());
}
}
- result.add(new JARDesc(new URL(codeBase, jar),
+ jarDescs.add(new JARDesc(new URL(codeBase, jar),
version, null, lazy, true, false, false));
}
+ // We know this is a safe list of JarDesc objects
+ @SuppressWarnings("unchecked")
+ List<T> result = (List<T>) jarDescs;
+ return result;
}
+ catch (MalformedURLException ex) { /* Ignored */ }
}
- catch (MalformedURLException ex)
- { }
- return result;
- }
+ return sharedResources.getResources(launchType);
+ }
+ @Override
public JARDesc[] getJARs() {
- List resources = getResources(JARDesc.class);
- ArrayList<JARDesc> jars = new ArrayList<JARDesc>();
-
- //Only get the JARDescs
- for (int i = 0; i < resources.size(); i++) {
- Object resource = resources.get(i);
- if (resource instanceof JARDesc)
- jars.add((JARDesc) resource);
- }
-
- Object[] objectArray = jars.toArray();
- JARDesc[] jarArray = new JARDesc[objectArray.length];
-
- for (int i = 0; i < objectArray.length; i++)
- jarArray[i] = (JARDesc) objectArray[i];
-
- return jarArray;
+ List<JARDesc> jarDescs = getResources(JARDesc.class);
+ return jarDescs.toArray(new JARDesc[jarDescs.size()]);
}
public void addResource(Object resource)
diff --git a/netx/net/sourceforge/jnlp/ResourcesDesc.java b/netx/net/sourceforge/jnlp/ResourcesDesc.java
index 1d7c94c..ca6f1dd 100644
--- a/netx/net/sourceforge/jnlp/ResourcesDesc.java
+++ b/netx/net/sourceforge/jnlp/ResourcesDesc.java
@@ -43,8 +43,8 @@ public class ResourcesDesc {
private JNLPFile jnlpFile;
/** list of jars, packages, properties, and extensions */
- private List resources = new ArrayList(); // mixed list makes easier for lookup code
-
+ private List<Object> resources = new ArrayList<Object>();
+ // mixed list makes easier for lookup code
/**
* Create a representation of one information section of the
@@ -66,8 +66,8 @@ public class ResourcesDesc {
* Returns the JVMs.
*/
public JREDesc[] getJREs() {
- List resources = getResources(JREDesc.class);
- return (JREDesc[]) resources.toArray( new JREDesc[resources.size()] );
+ List<JREDesc> resources = getResources(JREDesc.class);
+ return resources.toArray( new JREDesc[resources.size()] );
}
/**
@@ -92,8 +92,8 @@ public class ResourcesDesc {
* Returns all of the JARs.
*/
public JARDesc[] getJARs() {
- List resources = getResources(JARDesc.class);
- return (JARDesc[]) resources.toArray( new JARDesc[resources.size()] );
+ List<JARDesc> resources = getResources(JARDesc.class);
+ return resources.toArray( new JARDesc[resources.size()] );
}
/**
@@ -102,32 +102,32 @@ public class ResourcesDesc {
* @param partName the part name, null and "" equivalent
*/
public JARDesc[] getJARs(String partName) {
- List resources = getResources(JARDesc.class);
+ List<JARDesc> resources = getResources(JARDesc.class);
for (int i = resources.size(); i-- > 0;) {
- JARDesc jar = (JARDesc) resources.get(i);
+ JARDesc jar = resources.get(i);
if (!(""+jar.getPart()).equals(""+partName))
resources.remove(i);
}
- return (JARDesc[]) resources.toArray( new JARDesc[resources.size()] );
+ return resources.toArray( new JARDesc[resources.size()] );
}
/**
* Returns the Extensions.
*/
public ExtensionDesc[] getExtensions() {
- List resources = getResources(ExtensionDesc.class);
- return (ExtensionDesc[]) resources.toArray( new ExtensionDesc[resources.size()] );
+ List<ExtensionDesc> resources = getResources(ExtensionDesc.class);
+ return resources.toArray( new ExtensionDesc[resources.size()] );
}
/**
* Returns the Packages.
*/
public PackageDesc[] getPackages() {
- List resources = getResources(PackageDesc.class);
- return (PackageDesc[]) resources.toArray( new PackageDesc[resources.size()] );
+ List<PackageDesc> resources = getResources(PackageDesc.class);
+ return resources.toArray( new PackageDesc[resources.size()] );
}
/**
@@ -137,34 +137,34 @@ public class ResourcesDesc {
* @return the PackageDesc objects matching the class name
*/
public PackageDesc[] getPackages(String className) {
- List resources = getResources(PackageDesc.class);
+ List<PackageDesc> resources = getResources(PackageDesc.class);
for (int i = resources.size(); i-- > 0;) {
- PackageDesc pk = (PackageDesc) resources.get(i);
+ PackageDesc pk = resources.get(i);
if (!pk.matches(className))
resources.remove(i);
}
- return (PackageDesc[]) resources.toArray( new PackageDesc[resources.size()] );
+ return resources.toArray( new PackageDesc[resources.size()] );
}
/**
* Returns the Properties as a list.
*/
public PropertyDesc[] getProperties() {
- List resources = getResources(PropertyDesc.class);
- return (PropertyDesc[]) resources.toArray( new PropertyDesc[resources.size()] );
+ List<PropertyDesc> resources = getResources(PropertyDesc.class);
+ return resources.toArray( new PropertyDesc[resources.size()] );
}
/**
* Returns the properties as a map.
*/
- public Map getPropertiesMap() {
- Properties properties = new Properties();
- List resources = getResources(PropertyDesc.class);
+ public Map<String,String> getPropertiesMap() {
+ Map<String,String> properties = new HashMap<String,String>();
+ List<PropertyDesc> resources = getResources(PropertyDesc.class);
for (int i=0; i < resources.size(); i++) {
- PropertyDesc prop = (PropertyDesc) resources.get(i);
+ PropertyDesc prop = resources.get(i);
properties.put( prop.getKey(), prop.getValue() );
}
@@ -205,12 +205,12 @@ public class ResourcesDesc {
/**
* Returns all resources of the specified type.
*/
- public List getResources(Class type) {
- List result = new ArrayList();
+ public <T> List<T> getResources(Class<T> type) {
+ List<T> result = new ArrayList<T>();
for (int i=0; i < resources.size(); i++)
if ( type.isAssignableFrom(resources.get(i).getClass()) )
- result.add(resources.get(i));
+ result.add(type.cast(resources.get(i)));
return result;
}
diff --git a/netx/net/sourceforge/jnlp/Version.java b/netx/net/sourceforge/jnlp/Version.java
index 40178e8..1a48a86 100644
--- a/netx/net/sourceforge/jnlp/Version.java
+++ b/netx/net/sourceforge/jnlp/Version.java
@@ -94,10 +94,10 @@ public class Version {
* @param version a Version object
*/
public boolean matches(Version version) {
- List versionStrings = version.getVersionStrings();
+ List<String> versionStrings = version.getVersionStrings();
for (int i=0; i < versionStrings.size(); i++) {
- if (!this.matchesSingle( (String)versionStrings.get(i) ))
+ if (!this.matchesSingle(versionStrings.get(i) ))
return false;
}
@@ -122,10 +122,10 @@ public class Version {
* @param version a Version object
*/
public boolean matchesAny(Version version) {
- List versionStrings = version.getVersionStrings();
+ List<String> versionStrings = version.getVersionStrings();
for (int i=0; i < versionStrings.size(); i++) {
- if (this.matchesSingle( (String)versionStrings.get(i) ))
+ if (this.matchesSingle( versionStrings.get(i) ))
return true;
}
@@ -139,9 +139,9 @@ public class Version {
* @param version a non-compound version of the form "1.2.3[+*]"
*/
private boolean matchesSingle(String version) {
- List versionStrings = this.getVersionStrings();
+ List<String> versionStrings = this.getVersionStrings();
for (int i=0; i < versionStrings.size(); i++) {
- if ( matches(version, (String)versionStrings.get(i)) )
+ if ( matches(version, versionStrings.get(i)) )
return true;
}
return false;
@@ -156,14 +156,17 @@ public class Version {
* @param version a non-compound version optionally with "+" or "*"
*/
private boolean matches(String subversion, String version) {
- List subparts = getParts(subversion);
- List parts = getParts(version);
+ List<String> subparts = getParts(subversion);
+ List<String> parts = getParts(version);
int maxLength = Math.max(subversion.length(), version.length());
if (version.endsWith("*")) // star means rest of parts irrelevant: truncate them
maxLength = parts.size();
- normalize(new List[] {subparts, parts}, maxLength);
+ List<List<String>> versions = new ArrayList<List<String>>();
+ versions.add(subparts);
+ versions.add(parts);
+ normalize(versions, maxLength);
if (equal(subparts, parts))
return true;
@@ -181,9 +184,9 @@ public class Version {
* @param parts1 normalized version parts
* @param parts2 normalized version parts
*/
- protected boolean equal(List parts1, List parts2) {
+ protected boolean equal(List<String> parts1, List<String> parts2) {
for (int i=0; i < parts1.size(); i++) {
- if ( 0 != compare((String)parts1.get(i), (String)parts2.get(i)) )
+ if ( 0 != compare(parts1.get(i), parts2.get(i)) )
return false;
}
@@ -197,16 +200,16 @@ public class Version {
* @param parts1 normalized version parts
* @param parts2 normalized version parts
*/
- protected boolean greater(List parts1, List parts2) {
+ protected boolean greater(List<String> parts1, List<String> parts2) {
//if (true) return false;
for (int i=0; i < parts1.size(); i++) {
// if part1 > part2 then it's a later version, so return true
- if (compare((String)parts1.get(i), (String)parts2.get(i)) > 0)
+ if (compare(parts1.get(i), parts2.get(i)) > 0)
return true;
// if part1 < part2 then it's a ealier version, so return false
- if (compare((String)parts1.get(i), (String)parts2.get(i)) < 0)
+ if (compare(parts1.get(i), parts2.get(i)) < 0)
return false;
// if equal go to next part
@@ -229,8 +232,8 @@ public class Version {
* @return comparison of the two parts
*/
protected int compare(String part1, String part2) {
- Integer number1 = new Integer(0);
- Integer number2 = new Integer(0);
+ Integer number1 = Integer.valueOf(0);
+ Integer number2 = Integer.valueOf(0);
// compare as integers
try {
@@ -261,30 +264,30 @@ public class Version {
* @param versions list array of parts of a version string
* @param maxLength truncate lists to this maximum length
*/
- protected void normalize(List versions[], int maxLength) {
+ protected void normalize(List<List<String>> versions, int maxLength) {
int length = 0;
- for (int i=0; i < versions.length; i++)
- length = Math.max(length, versions[i].size());
+ for (List<String> vers : versions)
+ length = Math.max(length, vers.size());
if (length > maxLength)
length = maxLength;
- for (int i=0; i < versions.length; i++) {
+ for (List<String> vers : versions) {
// remove excess elements
- while (versions[i].size() > length)
- versions[i].remove( versions[i].size()-1 );
+ while (vers.size() > length)
+ vers.remove( vers.size()-1 );
// add in empty pad elements
- while (versions[i].size() < length)
- versions[i].add( emptyString );
+ while (vers.size() < length)
+ vers.add( emptyString );
}
}
/**
* Return the individual version strings that make up a Version.
*/
- protected List getVersionStrings() {
- ArrayList strings = new ArrayList();
+ protected List<String> getVersionStrings() {
+ ArrayList<String> strings = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(versionString, " ");
while (st.hasMoreTokens())
@@ -298,8 +301,8 @@ public class Version {
*
* @param oneVersion a single version id string (not compound)
*/
- protected List getParts(String oneVersion) {
- ArrayList strings = new ArrayList();
+ protected List<String> getParts(String oneVersion) {
+ ArrayList<String> strings = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(oneVersion, seperators+"+*");
while (st.hasMoreTokens()) {
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
index 9623edb..451e04a 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
@@ -400,12 +400,12 @@ public class CacheUtil {
return;
// only resources not starting out downloaded are displayed
- List urlList = new ArrayList();
+ List<URL> urlList = new ArrayList<URL>();
for (int i=0; i < resources.length; i++) {
if (!tracker.checkResource(resources[i]))
urlList.add(resources[i]);
}
- URL undownloaded[] = (URL[]) urlList.toArray( new URL[urlList.size()] );
+ URL undownloaded[] = urlList.toArray( new URL[urlList.size()] );
listener = indicator.getListener(app, title, undownloaded);
diff --git a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
index bd1cbd9..407d6f4 100644
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
+++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
@@ -118,7 +118,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
screen.height-frame.getHeight());
}
- frame.show();
+ frame.setVisible(true);
return result;
}
@@ -135,7 +135,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
ActionListener hider = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (frame.getContentPane().getComponentCount() == 1)
- frame.hide();
+ frame.setVisible(false);
frame.getContentPane().remove((DownloadPanel) listener);
frame.pack();
@@ -161,10 +161,10 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
private JLabel header = new JLabel();
/** list of URLs being downloaded */
- private List urls = new ArrayList();
+ private List<URL> urls = new ArrayList<URL>();
/** list of ProgressPanels */
- private List panels = new ArrayList();
+ private List<ProgressPanel> panels = new ArrayList<ProgressPanel>();
/**
@@ -199,7 +199,9 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
/**
* Update the download progress of a url.
*/
- protected void update(final URL url, final String version, final long readSoFar, final long total, final int overallPercent) {
+ protected void update(final URL url, final String version,
+ final long readSoFar, final long total,
+ final int overallPercent) {
Runnable r = new Runnable() {
public void run() {
if (!urls.contains(url))
@@ -207,7 +209,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
setOverallPercent(overallPercent);
- ProgressPanel panel = (ProgressPanel) panels.get(urls.indexOf(url));
+ ProgressPanel panel = panels.get(urls.indexOf(url));
panel.setProgress(readSoFar, total);
panel.repaint();
}
diff --git a/netx/net/sourceforge/jnlp/cache/Resource.java b/netx/net/sourceforge/jnlp/cache/Resource.java
index 172220f..08a31fb 100644
--- a/netx/net/sourceforge/jnlp/cache/Resource.java
+++ b/netx/net/sourceforge/jnlp/cache/Resource.java
@@ -60,10 +60,10 @@ public class Resource {
public static final int STARTED = 128; // enqueued or being worked on
/** list of weak references of resources currently in use */
- private static WeakList resources = new WeakList();
+ private static WeakList<Resource> resources = new WeakList<Resource>();
/** weak list of trackers monitoring this resource */
- private WeakList trackers = new WeakList();
+ private WeakList<ResourceTracker> trackers = new WeakList<ResourceTracker>();
/** the remote location of the resource */
URL location;
@@ -111,7 +111,7 @@ public class Resource {
int index = resources.indexOf(resource);
if (index >= 0) { // return existing object
- Resource result = (Resource) resources.get(index);
+ Resource result = resources.get(index);
if (result != null)
return result;
}
@@ -136,9 +136,9 @@ public class Resource {
*/
ResourceTracker getTracker() {
synchronized (trackers) {
- List t = trackers.hardList();
+ List<ResourceTracker> t = trackers.hardList();
if (t.size() > 0)
- return (ResourceTracker) t.get(0);
+ return t.get(0);
return null;
}
@@ -225,7 +225,8 @@ public class Resource {
*/
public void addTracker(ResourceTracker tracker) {
synchronized (trackers) {
- List t = trackers.hardList(); // prevent GC between contains and add
+ // prevent GC between contains and add
+ List<ResourceTracker> t = trackers.hardList();
if (!t.contains(tracker))
trackers.add(tracker);
@@ -238,14 +239,14 @@ public class Resource {
* download event.
*/
protected void fireDownloadEvent() {
- List send;
+ List<ResourceTracker> send;
synchronized (trackers) {
send = trackers.hardList();
}
for (int i=0; i < send.size(); i++) {
- ResourceTracker rt = (ResourceTracker) send.get(i);
+ ResourceTracker rt = send.get(i);
rt.fireDownloadEvent(this);
}
}
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
index d65c840..df923f2 100644
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
@@ -113,19 +113,21 @@ public class ResourceTracker {
private static int threads = 0;
/** weak list of resource trackers with resources to prefetch */
- private static WeakList prefetchTrackers = new WeakList();
+ private static WeakList<ResourceTracker> prefetchTrackers =
+ new WeakList<ResourceTracker>();
/** resources requested to be downloaded */
- private static ArrayList queue = new ArrayList();
+ private static ArrayList<Resource> queue = new ArrayList<Resource>();
/** resource trackers threads are working for (used for load balancing across multi-tracker downloads) */
- private static ArrayList active = new ArrayList(); //
+ private static ArrayList<ResourceTracker> active =
+ new ArrayList<ResourceTracker>(); //
/** the resources known about by this resource tracker */
- private List resources = new ArrayList();
+ private List<Resource> resources = new ArrayList<Resource>();
/** download listeners for this tracker */
- private List listeners = new ArrayList();
+ private List<DownloadListener> listeners = new ArrayList<DownloadListener>();
/** whether to download parts before requested */
private boolean prefetch;
@@ -293,7 +295,7 @@ public class ResourceTracker {
protected void fireDownloadEvent(Resource resource) {
DownloadListener l[] = null;
synchronized (listeners) {
- l = (DownloadListener[]) listeners.toArray(new DownloadListener[0]);
+ l = listeners.toArray(new DownloadListener[0]);
}
int status;
@@ -865,7 +867,7 @@ public class ResourceTracker {
// first find one to initialize
synchronized (prefetchTrackers) {
for (int i=0; i < prefetchTrackers.size() && result == null; i++) {
- ResourceTracker tracker = (ResourceTracker) prefetchTrackers.get(i);
+ ResourceTracker tracker = prefetchTrackers.get(i);
if (tracker == null)
continue;
@@ -907,12 +909,13 @@ public class ResourceTracker {
* Calls to this method should be synchronized on lock and
* source list.<p>
*/
- private static Resource selectByFlag(List source, int flag, int notflag) {
+ private static Resource selectByFlag(List<Resource> source, int flag,
+ int notflag) {
Resource result = null;
int score = Integer.MAX_VALUE;
for (int i=0; i < source.size(); i++) {
- Resource resource = (Resource) source.get(i);
+ Resource resource = source.get(i);
boolean selectable = false;
synchronized (resource) {
@@ -924,7 +927,7 @@ public class ResourceTracker {
int activeCount = 0;
for (int j=0; j < active.size(); j++)
- if ((ResourceTracker)active.get(j) == resource.getTracker())
+ if (active.get(j) == resource.getTracker())
activeCount++;
// try to spread out the downloads so that a slow host
@@ -947,7 +950,7 @@ public class ResourceTracker {
private Resource getResource(URL location) {
synchronized (resources) {
for (int i=0; i < resources.size(); i++) {
- Resource resource = (Resource) resources.get(i);
+ Resource resource = resources.get(i);
if (CacheUtil.urlEquals(resource.location, location))
return resource;
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);
diff --git a/netx/net/sourceforge/jnlp/services/ServiceUtil.java b/netx/net/sourceforge/jnlp/services/ServiceUtil.java
index b6f7682..a384f27 100644
--- a/netx/net/sourceforge/jnlp/services/ServiceUtil.java
+++ b/netx/net/sourceforge/jnlp/services/ServiceUtil.java
@@ -182,7 +182,7 @@ public class ServiceUtil {
System.err.println(" arg: "+args[i]);
}
- PrivilegedExceptionAction invoker = new PrivilegedExceptionAction() {
+ PrivilegedExceptionAction<Object> invoker = new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
return method.invoke(receiver, args);
}
diff --git a/netx/net/sourceforge/jnlp/services/XPersistenceService.java b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
index db45163..d8f47ab 100644
--- a/netx/net/sourceforge/jnlp/services/XPersistenceService.java
+++ b/netx/net/sourceforge/jnlp/services/XPersistenceService.java
@@ -138,7 +138,7 @@ class XPersistenceService implements PersistenceService {
if (!file.isDirectory())
return new String[0];
- List result = new ArrayList();
+ List<String> result = new ArrayList<String>();
// check whether this is right: only add files and not directories.
File entries[] = file.listFiles();
@@ -146,7 +146,7 @@ class XPersistenceService implements PersistenceService {
if (entries[i].isFile())
result.add(entries[i].getName());
- return (String[]) result.toArray(new String[result.size()]);
+ return result.toArray(new String[result.size()]);
}
/**
diff --git a/netx/net/sourceforge/jnlp/tools/JarSigner.java b/netx/net/sourceforge/jnlp/tools/JarSigner.java
index 05ba28f..88c6dc8 100644
--- a/netx/net/sourceforge/jnlp/tools/JarSigner.java
+++ b/netx/net/sourceforge/jnlp/tools/JarSigner.java
@@ -204,7 +204,7 @@ public class JarSigner implements CertVerifier {
certs = new ArrayList<CertPath>();
for (int i = 0; i < jars.size(); i++) {
- JARDesc jar = (JARDesc) jars.get(i);
+ JARDesc jar = jars.get(i);
verifiedJars = new ArrayList<String>();
unverifiedJars = new ArrayList<String>();
diff --git a/netx/net/sourceforge/jnlp/util/WeakList.java b/netx/net/sourceforge/jnlp/util/WeakList.java
index b8b205e..85204b1 100644
--- a/netx/net/sourceforge/jnlp/util/WeakList.java
+++ b/netx/net/sourceforge/jnlp/util/WeakList.java
@@ -32,10 +32,10 @@ import java.util.*;
* @author <a href="mailto:[email protected]">Jon A. Maxwell (JAM)</a> - initial author
* @version $Revision: 1.3 $
*/
-public class WeakList extends AbstractList {
+public class WeakList<E> extends AbstractList<E> {
/* list of weak references */
- private ArrayList refs = new ArrayList();
+ private ArrayList<WeakReference<E>> refs = new ArrayList<WeakReference<E>>();
/**
@@ -47,9 +47,9 @@ public class WeakList extends AbstractList {
/**
* Extract the hard reference out of a weak reference.
*/
- private Object deref(Object o) {
- if (o != null && o instanceof WeakReference)
- return ((WeakReference)o).get();
+ private E deref(WeakReference<E> o) {
+ if (o != null)
+ return o.get();
else
return null;
}
@@ -58,7 +58,7 @@ public class WeakList extends AbstractList {
* Returns the object at the specified index, or null if the
* object has been collected.
*/
- public Object get(int index) {
+ public E get(int index) {
return deref(refs.get(index));
}
@@ -75,23 +75,23 @@ public class WeakList extends AbstractList {
* previous object at that position or null if it was already
* collected.
*/
- public Object set(int index, Object element) {
- return deref(refs.set(index, new WeakReference(element)));
+ public E set(int index, E element) {
+ return deref(refs.set(index, new WeakReference<E>(element)));
}
/**
* Inserts the object at the specified position in the list.
* Automatically creates a weak reference to the object.
*/
- public void add(int index, Object element) {
- refs.add(index, new WeakReference(element));
+ public void add(int index, E element) {
+ refs.add(index, new WeakReference<E>(element));
}
/**
* Removes the object at the specified position and returns it
* or returns null if it was already collected.
*/
- public Object remove(int index) {
+ public E remove(int index) {
return deref(refs.remove(index));
}
@@ -100,11 +100,11 @@ public class WeakList extends AbstractList {
* returned list does not include the collected elements, so its
* indices do not necessarily correlate with those of this list.
*/
- public List hardList() {
- List result = new ArrayList();
+ public List<E> hardList() {
+ List<E> result = new ArrayList<E>();
for (int i=0; i < size(); i++) {
- Object tmp = get(i);
+ E tmp = get(i);
if (tmp != null)
result.add(tmp);
diff --git a/netx/net/sourceforge/nanoxml/XMLElement.java b/netx/net/sourceforge/nanoxml/XMLElement.java
index 520136e..b712f93 100644
--- a/netx/net/sourceforge/nanoxml/XMLElement.java
+++ b/netx/net/sourceforge/nanoxml/XMLElement.java
@@ -106,7 +106,7 @@ public class XMLElement
* <li>The keys and the values are strings.
* </ul></dd></dl>
*/
- private Hashtable attributes;
+ private Hashtable<String,Object> attributes;
/**
@@ -119,7 +119,7 @@ public class XMLElement
* or a subclass of <code>XMLElement</code>.
* </ul></dd></dl>
*/
- private Vector children;
+ private Vector<XMLElement> children;
/**
@@ -162,7 +162,7 @@ public class XMLElement
* <li>The values are char arrays
* </ul></dd></dl>
*/
- private Hashtable entities;
+ private Hashtable<String,char[]> entities;
/**
@@ -242,7 +242,7 @@ public class XMLElement
*/
public XMLElement()
{
- this(new Hashtable(), false, true, true);
+ this(new Hashtable<String,char[]>(), false, true, true);
}
@@ -284,7 +284,7 @@ public class XMLElement
* </ul></dd></dl><dl>
*
*/
- protected XMLElement(Hashtable entities,
+ protected XMLElement(Hashtable<String,char[]> entities,
boolean skipLeadingWhitespace,
boolean fillBasicConversionTable,
boolean ignoreCase)
@@ -293,17 +293,16 @@ public class XMLElement
this.ignoreCase = ignoreCase;
this.name = null;
this.contents = "";
- this.attributes = new Hashtable();
- this.children = new Vector();
+ this.attributes = new Hashtable<String,Object>();
+ this.children = new Vector<XMLElement>();
this.entities = entities;
this.lineNr = 0;
- Enumeration e = this.entities.keys();
+ Enumeration<String> e = this.entities.keys();
while (e.hasMoreElements()) {
- Object key = e.nextElement();
+ String key = e.nextElement();
Object value = this.entities.get(key);
if (value instanceof String) {
- value = ((String) value).toCharArray();
- this.entities.put(key, value);
+ entities.put(key, ((String) value).toCharArray());
}
}
if (fillBasicConversionTable) {
@@ -1096,7 +1095,7 @@ public class XMLElement
}
buf.append(ch);
} else {
- char[] value = (char[]) this.entities.get(key);
+ char[] value = entities.get(key);
if (value == null) {
throw this.unknownEntity(key);
}