/hg/icedtea-web: 2 new changesets
adomurad at icedtea.classpath.org
adomurad at icedtea.classpath.org
Tue Dec 4 07:56:20 PST 2012
changeset 741a105054af in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=741a105054af
author: Adam Domurad <adomurad at redhat.com>
date: Tue Dec 04 10:43:59 2012 -0500
Remove redundant HTML-tag scanner from ITW. Do not reconstruct tags.
changeset 21756f8bedfc in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=21756f8bedfc
author: Adam Domurad <adomurad at redhat.com>
date: Tue Dec 04 10:54:14 2012 -0500
PluginAppletViewer refactoring
diffstat:
ChangeLog | 44 +
Makefile.am | 4 +-
netx/net/sourceforge/jnlp/NetxPanel.java | 57 +-
netx/net/sourceforge/jnlp/PluginBridge.java | 64 +-
netx/net/sourceforge/jnlp/PluginParameterException.java | 43 +
netx/net/sourceforge/jnlp/PluginParameters.java | 238 ++
netx/net/sourceforge/jnlp/resources/Messages.properties | 1 +
netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties | 1 +
plugin/icedteanp/IcedTeaNPPlugin.cc | 237 +--
plugin/icedteanp/IcedTeaNPPlugin.h | 4 +-
plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java | 228 ++
plugin/icedteanp/java/sun/applet/PluginAppletViewer.java | 822 +--------
plugin/icedteanp/java/sun/applet/PluginParameterParser.java | 90 +
tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc | 2 +-
tests/cpp-unit-tests/PluginParametersTest.cc | 93 +
tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java | 53 +-
tests/netx/unit/net/sourceforge/jnlp/PluginParametersTest.java | 114 +
tests/netx/unit/sun/applet/PluginParameterParserTest.java | 73 +
18 files changed, 1153 insertions(+), 1015 deletions(-)
diffs (truncated from 2691 to 500 lines):
diff -r aff6fb36a9ab -r 21756f8bedfc ChangeLog
--- a/ChangeLog Mon Dec 03 18:08:38 2012 +0100
+++ b/ChangeLog Tue Dec 04 10:54:14 2012 -0500
@@ -1,3 +1,47 @@
+2012-12-04 Adam Domurad <adomurad at redhat.com>
+
+ PluginAppletViewer refactoring.
+ * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+ (handleInitializationMessage): New, extracts initialization logic
+ from PluginAppletViewer.handleMessage.
+ * plugin/icedteanp/java/sun/applet/PluginAppletPanelFactory.java: Moved
+ into own file.
+
+2012-12-04 Adam Domurad <adomurad at redhat.com>
+
+ Remove the applet/embed/object tag parser from ITW. Send the applet
+ parameters directly from the C++.
+ * Makefile.am: Allow unit-testing for classes in plugin.jar.
+ * netx/net/sourceforge/jnlp/NetxPanel.java: Use PluginParameters for
+ attribute lookup
+ * netx/net/sourceforge/jnlp/PluginBridge.java: Use PluginParameters
+ for attribute lookup
+ * netx/net/sourceforge/jnlp/resources/Messages.properties: Add message
+ for missing code/object attributes.
+ * netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties: Same.
+ * plugin/icedteanp/IcedTeaNPPlugin.cc: Send escaped parameter
+ name/values instead of applet tag. Remove some dead code.
+ * plugin/icedteanp/IcedTeaNPPlugin.h: Rename applet_tag ->
+ parameters_string.
+ * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: Extract
+ parsing code into its own class.
+ * tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc: Use CHECK_EQUALS
+ instead of CHECK.
+ * tests/netx/unit/net/sourceforge/jnlp/PluginBridgeTest.java: Update
+ unit tests due to constructor changes.
+ * netx/net/sourceforge/jnlp/PluginParameterException.java: New, thrown
+ when code/object attributes are missing.
+ * netx/net/sourceforge/jnlp/PluginParameters.java: New, Hashtable
+ wrapper that handles plugin attribute/parameter lookups.
+ * plugin/icedteanp/java/sun/applet/PluginParameterParser.java: New,
+ creates PluginParameters from escaped name/values.
+ * tests/cpp-unit-tests/PluginParametersTest.cc: New, C++ Unit tests for
+ plugin parameter related functions
+ * tests/netx/unit/net/sourceforge/jnlp/PluginParametersTest.java: New,
+ unit tests for PluginParameters class.
+ * tests/netx/unit/sun/applet/PluginParameterParserTest.java: New, unit
+ tests for PluginParameterParser class.
+
2012-11-03 Jiri Vanek <jvanek at redhat.com>
Fixed logging bottleneck
diff -r aff6fb36a9ab -r 21756f8bedfc Makefile.am
--- a/Makefile.am Mon Dec 03 18:08:38 2012 +0100
+++ b/Makefile.am Tue Dec 04 10:54:14 2012 -0500
@@ -969,7 +969,7 @@
mkdir -p $(NETX_UNIT_TEST_DIR) && \
$(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \
-d $(NETX_UNIT_TEST_DIR) \
- -classpath $(JUNIT_JAR):$(NETX_DIR)/lib/classes.jar:$(TEST_EXTENSIONS_DIR) \
+ -classpath $(JUNIT_JAR):$(DESTDIR)$(datadir)/$(PACKAGE_NAME)/plugin.jar:$(NETX_DIR)/lib/classes.jar:$(TEST_EXTENSIONS_DIR) \
@netx-unit-tests-source-files.txt && \
mkdir -p stamps && \
touch $@
@@ -999,7 +999,7 @@
done ; \
cd $(NETX_UNIT_TEST_DIR) ; \
class_names=`cat $(UNIT_CLASS_NAMES)` ; \
- CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(TEST_EXTENSIONS_DIR):. \
+ CLASSPATH=$(NETX_DIR)/lib/classes.jar:$(DESTDIR)$(datadir)/$(PACKAGE_NAME)/plugin.jar:$(JUNIT_JAR):$(JUNIT_RUNNER_JAR):$(TEST_EXTENSIONS_DIR):. \
$(BOOT_DIR)/bin/java -Xbootclasspath:$(RUNTIME) CommandLine $$class_names
if WITH_XSLTPROC
$(XSLTPROC) --stringparam logs logs_unit.html $(TESTS_SRCDIR)/$(REPORT_STYLES_DIRNAME)/jreport.xsl $(NETX_UNIT_TEST_DIR)/tests-output.xml > $(TESTS_DIR)/index_unit.html
diff -r aff6fb36a9ab -r 21756f8bedfc netx/net/sourceforge/jnlp/NetxPanel.java
--- a/netx/net/sourceforge/jnlp/NetxPanel.java Mon Dec 03 18:08:38 2012 +0100
+++ b/netx/net/sourceforge/jnlp/NetxPanel.java Tue Dec 04 10:54:14 2012 -0500
@@ -27,7 +27,6 @@
import java.net.URL;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -45,12 +44,12 @@
* @author Francis Kung <fkung at redhat.com>
*/
public class NetxPanel extends AppletViewerPanel implements SplashController {
+ private final PluginParameters parameters;
private PluginBridge bridge = null;
private boolean exitOnFailure = true;
private AppletInstance appInst = null;
private SplashController splashController;
private boolean appletAlive;
- private final String uKey;
// We use this so that we can create exactly one thread group
// for all panels with the same uKey.
@@ -68,51 +67,24 @@
private static final ConcurrentMap<String, Boolean> appContextCreated =
new ConcurrentHashMap<String, Boolean>();
- public NetxPanel(URL documentURL, Hashtable<String, String> atts) {
- super(documentURL, atts);
+ public NetxPanel(URL documentURL, PluginParameters params) {
+ super(documentURL, params.getUnderlyingHashtable());
- /* According to http://download.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/applet-compatibility.html,
- * classloaders are shared iff these properties match:
- * codebase, cache_archive, java_archive, archive
- *
- * To achieve this, we create the uniquekey based on those 4 values,
- * always in the same order. The initial "<NAME>=" parts ensure a
- * bad tag cannot trick the loader into getting shared with another.
- */
+ this.parameters = params;
- // Firefox sometimes skips the codebase if it is default -- ".",
- // so set it that way if absent
- String codebaseAttr = atts.get("codebase") != null ?
- atts.get("codebase") : ".";
-
- String cache_archiveAttr = atts.get("cache_archive") != null ?
- atts.get("cache_archive") : "";
-
- String java_archiveAttr = atts.get("java_archive") != null ?
- atts.get("java_archive") : "";
-
- String archiveAttr = atts.get("archive") != null ?
- atts.get("archive") : "";
-
- this.uKey = "codebase=" + codebaseAttr +
- "cache_archive=" + cache_archiveAttr +
- "java_archive=" + java_archiveAttr +
- "archive=" + archiveAttr;
-
- // when this was being done (incorrectly) in Launcher, the call was
- // new AppThreadGroup(mainGroup, file.getTitle());
+ String uniqueKey = params.getUniqueKey();
synchronized(TGMapMutex) {
- if (!uKeyToTG.containsKey(this.uKey)) {
+ if (!uKeyToTG.containsKey(uniqueKey)) {
ThreadGroup tg = new ThreadGroup(Launcher.mainGroup, this.documentURL.toString());
- uKeyToTG.put(this.uKey, tg);
+ uKeyToTG.put(uniqueKey, tg);
}
}
}
// overloaded constructor, called when initialized via plugin
- public NetxPanel(URL documentURL, Hashtable<String, String> atts,
+ public NetxPanel(URL documentURL, PluginParameters params,
boolean exitOnFailure) {
- this(documentURL, atts);
+ this(documentURL, params);
this.exitOnFailure = exitOnFailure;
this.appletAlive = true;
}
@@ -129,6 +101,7 @@
//Overriding to use Netx classloader. You might need to relax visibility
//in sun.applet.AppletPanel for runLoader().
+ @Override
protected void runLoader() {
try {
@@ -138,7 +111,7 @@
getCode(),
getWidth(),
getHeight(),
- atts, uKey);
+ parameters);
doInit = true;
dispatchAppletEvent(APPLET_LOADING, null);
@@ -188,6 +161,7 @@
* the applet
*/
// Reminder: Relax visibility in sun.applet.AppletPanel
+ @Override
protected synchronized void createAppletThread() {
// initialize JNLPRuntime in the main threadgroup
synchronized (JNLPRuntime.initMutex) {
@@ -208,8 +182,7 @@
}
public void updateSizeInAtts(int height, int width) {
- this.atts.put("height", Integer.toString(height));
- this.atts.put("width", Integer.toString(width));
+ parameters.updateSize(width, height);
}
public ClassLoader getAppletClassLoader() {
@@ -222,7 +195,7 @@
public ThreadGroup getThreadGroup() {
synchronized(TGMapMutex) {
- return uKeyToTG.get(uKey);
+ return uKeyToTG.get(parameters.getUniqueKey());
}
}
@@ -232,7 +205,7 @@
}
// only create a new context if one hasn't already been created for the
// applets with this unique key.
- if (null == appContextCreated.putIfAbsent(uKey, Boolean.TRUE)) {
+ if (null == appContextCreated.putIfAbsent(parameters.getUniqueKey(), Boolean.TRUE)) {
SunToolkit.createNewAppContext();
}
}
diff -r aff6fb36a9ab -r 21756f8bedfc netx/net/sourceforge/jnlp/PluginBridge.java
--- a/netx/net/sourceforge/jnlp/PluginBridge.java Mon Dec 03 18:08:38 2012 +0100
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java Tue Dec 04 10:54:14 2012 -0500
@@ -45,26 +45,23 @@
*/
public class PluginBridge extends JNLPFile {
- private String name;
+ private PluginParameters params;
private Set<String> jars = new HashSet<String>();
//Folders can be added to the code-base through the archive tag
private List<String> codeBaseFolders = new ArrayList<String>();
private String[] cacheJars = new String[0];
private String[] cacheExJars = new String[0];
- private Map<String, String> atts;
private boolean usePack;
private boolean useVersion;
- private boolean codeBaseLookup;
private boolean useJNLPHref;
/**
* Creates a new PluginBridge using a default JNLPCreator.
*/
public PluginBridge(URL codebase, URL documentBase, String jar, String main,
- int width, int height, Map<String, String> atts,
- String uKey)
+ int width, int height, PluginParameters params)
throws Exception {
- this(codebase, documentBase, jar, main, width, height, atts, uKey, new JNLPCreator());
+ this(codebase, documentBase, jar, main, width, height, params, new JNLPCreator());
}
/**
@@ -86,25 +83,24 @@
}
public PluginBridge(URL codebase, URL documentBase, String archive, String main,
- int width, int height, Map<String, String> atts,
- String uKey, JNLPCreator jnlpCreator)
+ int width, int height, PluginParameters params, JNLPCreator jnlpCreator)
throws Exception {
specVersion = new Version("1.0");
fileVersion = new Version("1.1");
this.codeBase = codebase;
this.sourceLocation = documentBase;
- this.atts = atts;
+ this.params = params;
- if (atts.containsKey("jnlp_href")) {
+ if (params.getJNLPHref() != null) {
useJNLPHref = true;
try {
// Use codeBase as the context for the URL. If jnlp_href's
// value is a complete URL, it will replace codeBase's context.
- URL jnlp = new URL(codeBase, atts.get("jnlp_href"));
+ URL jnlp = new URL(codeBase, params.getJNLPHref());
JNLPFile jnlpFile = null;
- if (atts.containsKey("jnlp_embedded")) {
- InputStream jnlpInputStream = new ByteArrayInputStream(decodeBase64String(atts.get("jnlp_embedded")));
+ if (params.getJNLPEmbedded() != null) {
+ InputStream jnlpInputStream = new ByteArrayInputStream(decodeBase64String(params.getJNLPEmbedded()));
jnlpFile = new JNLPFile(jnlpInputStream, codeBase, false);
} else {
jnlpFile = jnlpCreator.create(jnlp, null, false, JNLPRuntime.getDefaultUpdatePolicy(), codeBase);
@@ -118,7 +114,7 @@
// Change the parameter name to lowercase to follow conventions.
for (Map.Entry<String, String> entry : jnlpParams.entrySet()) {
- this.atts.put(entry.getKey().toLowerCase(), entry.getValue());
+ this.params.put(entry.getKey().toLowerCase(), entry.getValue());
}
JARDesc[] jarDescs = jnlpFile.getResources().getJARs();
for (JARDesc jarDesc : jarDescs) {
@@ -128,7 +124,7 @@
} 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: " + atts.get("jnlp_href")
+ System.err.println("Unable to get JNLP file at: " + params.getJNLPHref()
+ " with context of URL as: " + codeBase.toExternalForm());
}
} else {
@@ -138,14 +134,14 @@
}
// also, see if cache_archive is specified
- String cacheArchive = atts.get("cache_archive");
- if (cacheArchive != null && cacheArchive.length() > 0) {
+ String cacheArchive = params.getCacheArchive();
+ if (!cacheArchive.isEmpty()) {
String[] versions = new String[0];
// are there accompanying versions?
- String cacheVersion = atts.get("cache_version");
- if (cacheVersion != null) {
+ String cacheVersion = params.getCacheVersion();
+ if (!cacheVersion.isEmpty()) {
versions = cacheVersion.split(",");
}
@@ -162,8 +158,8 @@
}
}
- String cacheArchiveEx = atts.get("cache_archive_ex");
- if (cacheArchiveEx != null && cacheArchiveEx.length() > 0) {
+ String cacheArchiveEx = params.getCacheArchiveEx();
+ if (!cacheArchiveEx.isEmpty()) {
cacheExJars = cacheArchiveEx.split(",");
}
@@ -178,19 +174,13 @@
}
}
- name = atts.get("name");
- if (name == null)
- name = "Applet";
- else
- name = name + " applet";
-
if (main.endsWith(".class"))
main = main.substring(0, main.length() - 6);
// the class name should be of the form foo.bar.Baz not foo/bar/Baz
String mainClass = main.replace('/', '.');
- launchType = new AppletDesc(name, mainClass, documentBase, width,
- height, atts);
+ launchType = new AppletDesc(params.getAppletTitle(), mainClass, documentBase, width,
+ height, params.getUnmodifiableMap());
if (main.endsWith(".class")) //single class file only
security = new SecurityDesc(this, SecurityDesc.SANDBOX_PERMISSIONS,
@@ -198,11 +188,11 @@
else
security = null;
- this.uniqueKey = uKey;
+ this.uniqueKey = params.getUniqueKey();
usePack = false;
useVersion = false;
- String jargs = atts.get("java_arguments");
- if (jargs != null) {
+ String jargs = params.getJavaArguments();
+ if (!jargs.isEmpty()) {
for (String s : jargs.split(" ")) {
String[] parts = s.trim().split("=");
if (parts.length == 2 && Boolean.valueOf(parts[1])) {
@@ -214,12 +204,10 @@
}
}
}
- String cbl = atts.get("codebase_lookup");
- codeBaseLookup = cbl == null || (Boolean.valueOf(cbl));
}
public boolean codeBaseLookup() {
- return codeBaseLookup;
+ return params.useCodebaseLookup();
}
public boolean useJNLPHref() {
@@ -235,7 +223,7 @@
}
public String getTitle() {
- return name;
+ return params.getAppletTitle();
}
public ResourcesDesc getResources(final Locale locale, final String os,
@@ -258,9 +246,7 @@
}
boolean cacheable = true;
-
- String cacheOption = atts.get("cache_option");
- if (cacheOption != null && cacheOption.equalsIgnoreCase("no"))
+ if (params.getCacheOption().equalsIgnoreCase("no"))
cacheable = false;
for (String cacheJar : cacheJars) {
diff -r aff6fb36a9ab -r 21756f8bedfc netx/net/sourceforge/jnlp/PluginParameterException.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/netx/net/sourceforge/jnlp/PluginParameterException.java Tue Dec 04 10:54:14 2012 -0500
@@ -0,0 +1,43 @@
+/* Copyright (C) 2012 Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package net.sourceforge.jnlp;
+
+public class PluginParameterException extends RuntimeException {
+ public PluginParameterException(String detail) {
+ super(detail);
+ }
+}
diff -r aff6fb36a9ab -r 21756f8bedfc netx/net/sourceforge/jnlp/PluginParameters.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/netx/net/sourceforge/jnlp/PluginParameters.java Tue Dec 04 10:54:14 2012 -0500
@@ -0,0 +1,238 @@
+/* PluginAppletAttributes -- Provides parsing for applet attributes
+ Copyright (C) 2012 Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package net.sourceforge.jnlp;
+
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Map;
+
+import static net.sourceforge.jnlp.runtime.Translator.R;
+
+/**
+ * Represents plugin applet parameters, backed by a Hashtable.
+ */
+
+public class PluginParameters {
+ private final Hashtable<String, String> parameters;
+
+ public PluginParameters(Map<String, String> params) {
+ this.parameters = createParameterTable(params);
+
More information about the distro-pkg-dev
mailing list