Mercurial > hg > release > icedtea6-1.4.1
changeset 1272:96607b3b6ec8
Fix bug#233 -- cache_archive and cache_archive_ex parameters are now tracked
Fix NPE when applets called getApplet(Ljava/lang/String;) in
PluginAppletViewer
author | Deepak Bhole <dbhole@redhat.com> |
---|---|
date | Wed, 10 Dec 2008 16:02:21 -0500 |
parents | 569f19d48956 |
children | 88c957e14fdd |
files | ChangeLog plugin/icedtea/sun/applet/PluginAppletViewer.java rt/net/sourceforge/jnlp/JARDesc.java rt/net/sourceforge/jnlp/Parser.java rt/net/sourceforge/jnlp/PluginBridge.java rt/net/sourceforge/jnlp/cache/Resource.java rt/net/sourceforge/jnlp/cache/ResourceTracker.java rt/net/sourceforge/jnlp/cache/UpdatePolicy.java rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java |
diffstat | 9 files changed, 150 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Tue Dec 09 22:38:21 2008 +0000 +++ b/ChangeLog Wed Dec 10 16:02:21 2008 -0500 @@ -1,3 +1,22 @@ +2008-12-10 Deepak Bhole <dbhole@redhat.com> + + * plugin/icedtea/sun/applet/PluginAppletViewer.java: Remove spurious + call to getSecuritymanager() that was causing a CCE. + * rt/net/sourceforge/jnlp/JARDesc.java: Track if the jar is cacheable or + not. + * rt/net/sourceforge/jnlp/Parser.java: Provide new cacheable param to + JARDesc constructor. + * rt/net/sourceforge/jnlp/PluginBridge.java: Track cache_archive and + cache_archive_ex parameters in addition to archive. + * rt/net/sourceforge/jnlp/cache/Resource.java: Track per resource update + policy. + * rt/net/sourceforge/jnlp/cache/ResourceTracker.java: Take into account a + new update policy of "forced" update on each instantiation. + * rt/net/sourceforge/jnlp/cache/UpdatePolicy.java: Create new FORCE update + policy. + * rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Provide new + cacheable param to JARDesc constructor. + 2008-12-09 Andrew John Hughes <gnu_andrew@member.fsf.org> * Makefile.am:
--- a/plugin/icedtea/sun/applet/PluginAppletViewer.java Tue Dec 09 22:38:21 2008 +0000 +++ b/plugin/icedtea/sun/applet/PluginAppletViewer.java Wed Dec 10 16:02:21 2008 -0500 @@ -649,7 +649,6 @@ * Get an applet by name. */ public Applet getApplet(String name) { - AppletSecurity security = (AppletSecurity)System.getSecurityManager(); name = name.toLowerCase(); SocketPermission panelSp = new SocketPermission(panel.getCodeBase().getHost(), "connect");
--- a/rt/net/sourceforge/jnlp/JARDesc.java Tue Dec 09 22:38:21 2008 +0000 +++ b/rt/net/sourceforge/jnlp/JARDesc.java Wed Dec 10 16:02:21 2008 -0500 @@ -46,6 +46,9 @@ /** whether the JAR contains native libraries */ private boolean nativeJar; + + /** whether the JAR can be cached */ + private boolean cacheable; /** * Create a JAR descriptor. @@ -57,13 +60,14 @@ * @param main whether the JAR contains the main class * @param nativeJam whether the JAR contains native libraries */ - public JARDesc(URL location, Version version, String part, boolean lazy, boolean main, boolean nativeJar) { + public JARDesc(URL location, Version version, String part, boolean lazy, boolean main, boolean nativeJar, boolean cacheable) { this.location = location; this.version = version; this.part = part; this.lazy = lazy; this.main = main; this.nativeJar = nativeJar; + this.cacheable = cacheable; } /** @@ -124,6 +128,15 @@ public boolean isMain() { return main; } + + /** + * Returns if this jar is cacheable + * + * @return Whether or not this jar is cacheable + */ + public boolean isCacheable() { + return cacheable; + } }
--- a/rt/net/sourceforge/jnlp/Parser.java Tue Dec 09 22:38:21 2008 +0000 +++ b/rt/net/sourceforge/jnlp/Parser.java Wed Dec 10 16:02:21 2008 -0500 @@ -308,7 +308,7 @@ if (strict) throw new ParseException(R("PNativeHasMain")); - return new JARDesc(location, version, part, lazy, main, nativeJar); + return new JARDesc(location, version, part, lazy, main, nativeJar, true); }
--- a/rt/net/sourceforge/jnlp/PluginBridge.java Tue Dec 09 22:38:21 2008 +0000 +++ b/rt/net/sourceforge/jnlp/PluginBridge.java Wed Dec 10 16:02:21 2008 -0500 @@ -36,7 +36,9 @@ Version fileVersion = new Version("1.1"); String name; - String[] jars; + String[] jars = new String[0]; + String[] cache_jars = new String[0]; + String[] cache_ex_jars = new String[0]; Hashtable atts; public PluginBridge(URL codebase, URL documentBase, String jar, String main, @@ -46,7 +48,34 @@ this.codeBase = codebase; this.sourceLocation = documentBase; - if (jar != null) { + // also, see if cache_archive is specified + if (atts.get("cache_archive") != null && ((String) atts.get("cache_archive")).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[] jars = ((String) atts.get("cache_archive")).split(","); + cache_jars = new String[jars.length]; + + for (int i=0; i < jars.length; i++) { + + cache_jars[i] = jars[i].trim(); + + if (versions.length > 0) { + cache_jars[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(","); + } + + if (jar != null && jar.length() > 0) { System.err.println("Jar string: " + jar); this.jars = jar.split(","); System.err.println("jars length: " + jars.length); @@ -103,11 +132,59 @@ //should this be done to sharedResources on init? try { - if (launchType.equals(JARDesc.class) && jars != null) + if (launchType.equals(JARDesc.class)) { for (int i = 0; i < jars.length; i++) result.add(new JARDesc(new URL(codeBase, jars[i]), - null, null, false, true, false)); + null, null, false, true, false, true)); + + boolean cacheable = true; + + if (atts.get("cache_option") != null && + ((String) atts.get("cache_option")).equalsIgnoreCase("no")) + cacheable = false; + + for (int i = 0; i < cache_jars.length; i++) { + + String[] jar_and_ver = cache_jars[i].split(";"); + + String jar = jar_and_ver[0]; + Version version = null; + + if (jar_and_ver.length > 1) { + version = new Version(jar_and_ver[1]); + } + + result.add(new JARDesc(new URL(codeBase, jar), + version, null, false, true, false, cacheable)); + } + + for (int i = 0; i < cache_ex_jars.length; i++) { + String[] jar_info = cache_ex_jars[i].split(";"); + + String jar = jar_info[0].trim(); + Version version = null; + boolean lazy = true; + + if (jar_info.length > 1) { + + // format is name[[;preload];version] + + if (jar_info[1].equals("preload")) { + lazy = false; + } else { + version = new Version(jar_info[1].trim()); + } + + if (jar_info.length > 2) { + lazy = false; + version = new Version(jar_info[2].trim()); + } + } + + result.add(new JARDesc(new URL(codeBase, jar), + version, null, lazy, true, false, false)); + } } } catch (MalformedURLException ex) @@ -132,9 +209,9 @@ for (int i = 0; i < objectArray.length; i++) jarArray[i] = (JARDesc) objectArray[i]; - return jarArray; + return jarArray; } - + public void addResource(Object resource) { // todo: honor the current locale, os, arch values
--- a/rt/net/sourceforge/jnlp/cache/Resource.java Tue Dec 09 22:38:21 2008 +0000 +++ b/rt/net/sourceforge/jnlp/cache/Resource.java Wed Dec 10 16:02:21 2008 -0500 @@ -88,23 +88,26 @@ /** the status of the resource */ int status = UNINITIALIZED; - + + /** Update policy for this resource */ + UpdatePolicy updatePolicy; /** * Create a resource. */ - private Resource(URL location, Version requestVersion) { + private Resource(URL location, UpdatePolicy updatePolicy, Version requestVersion) { this.location = location; this.requestVersion = requestVersion; + this.updatePolicy = updatePolicy; } /** * Return a shared Resource object representing the given * location and version. */ - public static Resource getResource(URL location, Version requestVersion) { + public static Resource getResource(URL location, UpdatePolicy updatePolicy, Version requestVersion) { synchronized (resources) { - Resource resource = new Resource(location, requestVersion); + Resource resource = new Resource(location, updatePolicy, requestVersion); int index = resources.indexOf(resource); if (index >= 0) { // return existing object @@ -152,6 +155,15 @@ } /** + * Returns the update policy for this resource + * + * @return The update policy + */ + public UpdatePolicy getUpdatePolicy() { + return this.updatePolicy; + } + + /** * Returns a human-readable status string. */ private String getStatusString(int flag) {
--- a/rt/net/sourceforge/jnlp/cache/ResourceTracker.java Tue Dec 09 22:38:21 2008 +0000 +++ b/rt/net/sourceforge/jnlp/cache/ResourceTracker.java Wed Dec 10 16:02:21 2008 -0500 @@ -152,7 +152,7 @@ if (location == null) throw new IllegalArgumentException("location==null"); - Resource resource = Resource.getResource(location, version); + Resource resource = Resource.getResource(location, updatePolicy, version); boolean downloaded = false; synchronized (resources) { @@ -215,7 +215,7 @@ return true; } - if (updatePolicy != UpdatePolicy.ALWAYS) { // save loading entry props file + if (updatePolicy != UpdatePolicy.ALWAYS && updatePolicy != UpdatePolicy.FORCE) { // save loading entry props file CacheEntry entry = new CacheEntry(resource.location, resource.downloadVersion); if (entry.isCached() && !updatePolicy.shouldUpdate(entry)) { @@ -232,6 +232,11 @@ return true; } } + + if (updatePolicy == UpdatePolicy.FORCE) { // ALWAYS update + // When we are "always" updating, we update for each instance. Reset resource status. + resource.changeStatus(Integer.MAX_VALUE, 0); + } // may or may not be cached, but check update when connection // is open to possibly save network communication time if it @@ -649,7 +654,7 @@ // connect URLConnection connection = resource.location.openConnection(); // this won't change so should be okay unsynchronized int size = connection.getContentLength(); - boolean current = CacheUtil.isCurrent(resource.location, resource.requestVersion, connection); + boolean current = CacheUtil.isCurrent(resource.location, resource.requestVersion, connection) && resource.getUpdatePolicy() != UpdatePolicy.FORCE; synchronized(resource) { resource.localFile = localFile;
--- a/rt/net/sourceforge/jnlp/cache/UpdatePolicy.java Tue Dec 09 22:38:21 2008 +0000 +++ b/rt/net/sourceforge/jnlp/cache/UpdatePolicy.java Wed Dec 10 16:02:21 2008 -0500 @@ -47,6 +47,7 @@ public static UpdatePolicy ALWAYS = new UpdatePolicy(0); public static UpdatePolicy SESSION = new UpdatePolicy(-1); + public static UpdatePolicy FORCE = new UpdatePolicy(Long.MIN_VALUE); public static UpdatePolicy NEVER = new UpdatePolicy(Long.MAX_VALUE); private long timeDiff = -1;
--- a/rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Dec 09 22:38:21 2008 +0000 +++ b/rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Wed Dec 10 16:02:21 2008 -0500 @@ -302,6 +302,7 @@ List initialJars = new ArrayList(); for (int i=0; i < jars.length; i++) { + available.add(jars[i]); if (jars[i].isEager()) @@ -309,7 +310,7 @@ tracker.addResource(jars[i].getLocation(), jars[i].getVersion(), - JNLPRuntime.getDefaultUpdatePolicy() + jars[i].isCacheable() ? JNLPRuntime.getDefaultUpdatePolicy() : UpdatePolicy.FORCE ); } @@ -495,10 +496,10 @@ // there is currently no mechanism to cache files per // instance.. so only index cached files if (localFile != null) { - JarFile file = new JarFile(localFile.getAbsolutePath()); - JarIndex index = JarIndex.getJarIndex(file, null); - if (index != null) - jarIndexes.add(index); + JarIndex index = JarIndex.getJarIndex(new JarFile(localFile.getAbsolutePath()), null); + + if (index != null) + jarIndexes.add(index); } if (JNLPRuntime.isDebug()) @@ -696,15 +697,14 @@ // 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('.', '/')); + LinkedList<String> jarList = index.get(name.replace('.', '/')); if (jarList != null) { for (String jarName: jarList) { JARDesc desc; try { desc = new JARDesc(new URL(file.getCodeBase(), jarName), - null, null, false, true, false); + null, null, false, true, false, true); } catch (MalformedURLException mfe) { throw new ClassNotFoundException(name); }