/hg/icedtea-web: Plugin made run on jdk9

jvanek at icedtea.classpath.org jvanek at icedtea.classpath.org
Fri Nov 4 11:06:27 UTC 2016


changeset f243a4832f32 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=f243a4832f32
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Nov 04 12:11:44 2016 +0100

	Plugin made run on jdk9

	* .Makefile: ($(PLUGIN_DIR)/%.o) and (stamps/cpp-unit-tests-compile.stamp) got setters for -DNETX_JAR, -DPLUGIN_JAR and -DJSOBJECT_JAR
	* configure.ac: added check for sun.net.www.protocol.http.Handler
	* launcher/launchers.in: wrong reads for java.desktop (java.desktop) fixed to java.naming. Added exports for java.base/sun.net.www.protocol.http to ALL-UNAMED,java.desktop.
	* netx/net/sourceforge/jnlp/jdk89acesses/JarIndexAccess.java: fixed type of JarFile - from wrong in sourceforge, to correct in java.util.jar
	* plugin/icedteanp/IcedTeaNPPlugin.cc: added plugin_get_java_version which, by spawning java process determine java version it wonts to be launching. (plugin_start_appletviewer) based on javaVersion adds  patch-module, add-reads, add-exports if jdk9 is detected. rt.jar is  now added only for jdk8. (NP_Initialize) sets javaVersion by calling  plugin_get_java_version


diffstat:

 ChangeLog                                                  |   18 ++
 Makefile.am                                                |    6 +
 configure.ac                                               |    1 +
 launcher/launchers.in                                      |   10 +-
 netx/net/sourceforge/jnlp/jdk89acesses/JarIndexAccess.java |    3 +-
 plugin/icedteanp/IcedTeaNPPlugin.cc                        |  104 ++++++++++++-
 6 files changed, 131 insertions(+), 11 deletions(-)

diffs (262 lines):

diff -r 2cb12ef65318 -r f243a4832f32 ChangeLog
--- a/ChangeLog	Thu Nov 03 13:17:51 2016 +0100
+++ b/ChangeLog	Fri Nov 04 12:11:44 2016 +0100
@@ -1,3 +1,21 @@
+2016-11-04  Jiri Vanek <jvanek at redhat.com>
+
+	Plugin made run on jdk9
+	* .Makefile: ($(PLUGIN_DIR)/%.o) and (stamps/cpp-unit-tests-compile.stamp)
+	got setters for -DNETX_JAR, -DPLUGIN_JAR and -DJSOBJECT_JAR
+	* configure.ac: added cehck for sun.net.www.protocol.http.Handler
+	* launcher/launchers.in: wrong reads for java.desktop (java.desktop)
+	fixed to java.naming. Added exports for java.base/sun.net.www.protocol.http
+	to ALL-UNAMED,java.desktop.
+	* netx/net/sourceforge/jnlp/jdk89acesses/JarIndexAccess.java:
+	fixed type of JarFile - from wrong in sourceforge, to correct in java.util.jar
+	* plugin/icedteanp/IcedTeaNPPlugin.cc: added plugin_get_java_version
+	which, by spawning java process determine java version it wonts to be
+	launching. (plugin_start_appletviewer) based on javaVersion adds 
+	patch-module, add-reads, add-exports if jdk9 is detected. rt.jar is 
+	now added only for jdk8. (NP_Initialize) sets javaVersion by calling 
+	plugin_get_java_version
+
 2016-11-03  Jiri Vanek <jvanek at redhat.com>
 
 	javaws -html made run under jdk9 (if compiled by jdk8)
diff -r 2cb12ef65318 -r f243a4832f32 Makefile.am
--- a/Makefile.am	Thu Nov 03 13:17:51 2016 +0100
+++ b/Makefile.am	Fri Nov 04 12:11:44 2016 +0100
@@ -367,6 +367,9 @@
 	  -DMOZILLA_VERSION_COLLAPSED="$(MOZILLA_VERSION_COLLAPSED)" \
 	  -DICEDTEA_WEB_JRE="\"$(SYSTEM_JRE_DIR)\"" \
 	  -DPLUGIN_BOOTCLASSPATH=$(PLUGIN_BOOTCLASSPATH) \
+	  -DNETX_JAR="\"$(datadir)/$(PACKAGE_NAME)/netx.jar\"" \
+	  -DPLUGIN_JAR="\"$(PLUGIN_JAR)\"" \
+	  -DJSOBJECT_JAR="\"$(JSOBJECT_JAR)\""\
 	  $(GLIB_CFLAGS) \
 	  $(MOZILLA_CFLAGS) \
   	  -fvisibility=hidden \
@@ -419,6 +422,9 @@
 	  -DMOZILLA_VERSION_COLLAPSED="$(MOZILLA_VERSION_COLLAPSED)" \
 	  -DICEDTEA_WEB_JRE="\"$(SYSTEM_JRE_DIR)\"" \
 	  -DPLUGIN_BOOTCLASSPATH=$(PLUGIN_BOOTCLASSPATH) \
+	  -DNETX_JAR="\"$(datadir)/$(PACKAGE_NAME)/netx.jar\"" \
+	  -DPLUGIN_JAR="\"$(PLUGIN_JAR)\"" \
+	  -DJSOBJECT_JAR="\"$(JSOBJECT_JAR)\""\
 	  $(GLIB_CFLAGS) \
 	  $(MOZILLA_CFLAGS) \
 	  "-I$(CPP_UNITTEST_FRAMEWORK_SRCDIR)/src" \
diff -r 2cb12ef65318 -r f243a4832f32 configure.ac
--- a/configure.ac	Thu Nov 03 13:17:51 2016 +0100
+++ b/configure.ac	Fri Nov 04 12:11:44 2016 +0100
@@ -94,6 +94,7 @@
 IT_CHECK_FOR_CLASS(SUN_NET_WWW_PROTOCOL_JAR_URLJARFILECALLBACK, [sun.net.www.protocol.jar.URLJarFileCallBack], [some.pkg], [$JAVA_BASE])
 IT_CHECK_FOR_CLASS(SUN_AWT_X11_XEMBEDDEDFRAME, [sun.awt.X11.XEmbeddedFrame], [some.pkg], [$JAVA_DESKTOP])
 IT_CHECK_FOR_CLASS(COM_SUN_JNDI_TOOLKIT_URL_URLUTIL, [com.sun.jndi.toolkit.url.UrlUtil], [some.pkg], [$JAVA_NAMING])
+IT_CHECK_FOR_CLASS(SUN_NET_WWW_PROTOCOL_HTTP_HANDLER, [sun.net.www.protocol.http.Handler], [some.pkg], [$JAVA_BASE])
 IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef], [sun.applet], [$JAVA_DESKTOP])
 
 IT_CHECK_FOR_SUN_APPLET_ACCESSIBILITY
diff -r 2cb12ef65318 -r f243a4832f32 launcher/launchers.in
--- a/launcher/launchers.in	Thu Nov 03 13:17:51 2016 +0100
+++ b/launcher/launchers.in	Fri Nov 04 12:11:44 2016 +0100
@@ -79,12 +79,10 @@
 k=$((k+1))
 
 if [ "x$JDK9" == "xYES" ] ; then
-
 COMMAND[k]="--patch-module"
 k=$((k+1))
 COMMAND[k]="java.desktop=@PLUGIN_JAR@:@NETX_JAR@"
 k=$((k+1))
-
 # jsobject must be pathched separately from plugin
 # otherwise netscape pkg would be shared by two modules, which is forbiden
 COMMAND[k]="--patch-module"
@@ -92,14 +90,13 @@
 COMMAND[k]="jdk.jsobject=@JSOBJECT_JAR@"
 k=$((k+1))
 
-
 COMMAND[k]="--add-reads"
 k=$((k+1))
 COMMAND[k]="java.base=ALL-UNNAMED,java.desktop"
 k=$((k+1))
 COMMAND[k]="--add-reads"
 k=$((k+1))
-COMMAND[k]="java.desktop=ALL-UNNAMED,java.desktop"
+COMMAND[k]="java.desktop=ALL-UNNAMED,java.naming"
 k=$((k+1))
 COMMAND[k]="--add-reads"
 k=$((k+1))
@@ -150,11 +147,14 @@
 k=$((k+1))
 COMMAND[k]="java.desktop/sun.applet=ALL-UNNAMED,java.desktop"
 k=$((k+1))
-
 COMMAND[k]="--add-exports"
 k=$((k+1))
 COMMAND[k]="java.base/sun.security.action=ALL-UNNAMED,java.desktop"
 k=$((k+1))
+COMMAND[k]="--add-exports"
+k=$((k+1))
+COMMAND[k]="java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop"
+k=$((k+1))
 fi
 
 
diff -r 2cb12ef65318 -r f243a4832f32 netx/net/sourceforge/jnlp/jdk89acesses/JarIndexAccess.java
--- a/netx/net/sourceforge/jnlp/jdk89acesses/JarIndexAccess.java	Thu Nov 03 13:17:51 2016 +0100
+++ b/netx/net/sourceforge/jnlp/jdk89acesses/JarIndexAccess.java	Fri Nov 04 12:11:44 2016 +0100
@@ -4,7 +4,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.LinkedList;
-import net.sourceforge.jnlp.util.JarFile;
+import java.util.jar.JarFile;
 import net.sourceforge.jnlp.util.logging.OutputController;
 
 /**
@@ -24,6 +24,7 @@
         } catch (ClassNotFoundException ex) {
             try {
                 OutputController.getLogger().log(ex);
+                OutputController.getLogger().log("Running jdk9+ ?");
                 jarIndexClass = Class.forName("jdk.internal.util.jar.JarIndex");
             } catch (ClassNotFoundException exx) {
                 OutputController.getLogger().log(exx);
diff -r 2cb12ef65318 -r f243a4832f32 plugin/icedteanp/IcedTeaNPPlugin.cc
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Thu Nov 03 13:17:51 2016 +0100
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Fri Nov 04 12:11:44 2016 +0100
@@ -185,6 +185,7 @@
 // Keeps track of initialization. NP_Initialize should only be
 // called once.
 gboolean initialized = false;
+int javaVersion = 0;
 
 // browser functions into mozilla
 NPNetscapeFuncs browser_functions;
@@ -1488,6 +1489,80 @@
   return error;
 }
 
+static int
+plugin_get_java_version ()
+{
+
+  PLUGIN_DEBUG ("plugin_get_java_version: %s\n", get_plugin_executable().c_str());
+
+  gchar* command_line[3] = { NULL, NULL, NULL };
+  gchar** environment;
+
+  gchar* standard_output;
+  gchar* standard_error;
+  gint exit_status;
+
+  command_line[0] = g_strdup (get_plugin_executable().c_str());
+  command_line[1] = g_strdup("-version");
+  command_line[2] = NULL;
+
+  environment = plugin_filter_environment();
+
+  gboolean result = g_spawn_sync (NULL, command_line, environment,
+          (GSpawnFlags) 0,
+          NULL/*GSpawnChildSetupFunc*/,
+          NULL/*user_data*/,
+          &standard_output,
+          &standard_error,
+          &exit_status,
+          &channel_error);
+  if (channel_error)
+        {
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+  PLUGIN_DEBUG ("got_out: %s\n", standard_output);
+  PLUGIN_DEBUG ("got_err: %s\n", standard_error);
+
+  g_strfreev (environment);
+
+  g_free (command_line[0]);
+  command_line[0] = NULL;
+  g_free (command_line[1]);
+  command_line[1] = NULL;
+  g_free (command_line[2]);
+  command_line[2] = NULL;
+
+  if ( standard_error != NULL ){
+    if(strstr(standard_error, "\"9") != NULL) {
+      PLUGIN_DEBUG ("detected 9\n");
+      PLUGIN_DEBUG ("plugin_get_java_version return\n");
+      return 9;
+    }
+  }
+  PLUGIN_DEBUG ("detected 8 (or generally non nine)\n");
+  PLUGIN_DEBUG ("plugin_get_java_version return\n");
+  return 8;
+}
+
+
+
+const char *knownExports[]{
+    "java.desktop/sun.awt=ALL-UNNAMED,java.desktop",
+    "java.base/sun.security.provider=ALL-UNNAMED,java.desktop",
+    "java.base/sun.security.util=ALL-UNNAMED,java.desktop",
+    "java.base/sun.security.x509=ALL-UNNAMED,java.desktop",
+    "java.base/jdk.internal.util.jar=ALL-UNNAMED,java.desktop",
+    "java.base/sun.security.validator=ALL-UNNAMED,java.desktop",
+    "java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED,java.desktop",
+    "java.base/sun.net.www.protocol.jar=ALL-UNNAMED,java.desktop",
+    "java.desktop/sun.awt.X11=ALL-UNNAMED,java.desktop",
+    "java.naming/com.sun.jndi.toolkit.url=ALL-UNNAMED,java.desktop",
+    "java.desktop/sun.applet=ALL-UNNAMED,java.desktop",
+    "java.base/sun.security.action=ALL-UNNAMED,java.desktop",
+    "java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop"
+};
+
 NPError
 plugin_start_appletviewer (ITNPPluginData* data)
 {
@@ -1511,10 +1586,29 @@
   }
 
   command_line.push_back(PLUGIN_BOOTCLASSPATH);
-  // set the classpath to avoid using the default (cwd).
-  command_line.push_back("-classpath");
-  command_line.push_back(get_plugin_rt_jar());
-
+  if (javaVersion < 9 ) {
+    // for jdk8 set the classpath to avoid using the default (cwd).
+    command_line.push_back("-classpath");
+    command_line.push_back(get_plugin_rt_jar());
+  } else {
+    command_line.push_back("--patch-module");
+    command_line.push_back("java.desktop="PLUGIN_JAR":"NETX_JAR);
+    command_line.push_back("--patch-module");
+    command_line.push_back("jdk.jsobject="JSOBJECT_JAR);
+    command_line.push_back("--add-reads");
+    command_line.push_back("java.base=ALL-UNNAMED,java.desktop");
+    command_line.push_back("--add-reads");
+    command_line.push_back("java.desktop=ALL-UNNAMED,java.naming");
+    command_line.push_back("--add-reads");
+    command_line.push_back("java.naming=ALL-UNNAMED,java.desktop");
+
+    for(int i = 0; i < sizeof(knownExports)/sizeof(knownExports[0]); i++) {
+      command_line.push_back("--add-exports");
+      command_line.push_back(knownExports[i]);
+    }
+
+
+  }
   // Enable coverage agent if we are running instrumented plugin
 #ifdef COVERAGE_AGENT
   command_line.push_back(COVERAGE_AGENT);
@@ -2066,7 +2160,7 @@
       PLUGIN_ERROR("Unable to find java executable %s\n", get_plugin_executable().c_str());
       return np_error;
     }
-
+  javaVersion = plugin_get_java_version();
   initialized = true;
 
   // Initialize threads (needed for mutexes).


More information about the distro-pkg-dev mailing list