Hi, This patch adds javax.script javascript support through rhino. CCed build-dev since it is mainly build stuff and there doesn't seem to be another list for scripting stuff (not that I am advocating yet another list!)
The idea is pretty simple, if configure can detect rhino being installed on the system already (either the rhino.jar from fedora or the js.jar from debian) it uses that instead of the closed and unreleased sun internal classes. The only wrinkle is that the javascript support is written to expect the implementation on the bootclasspath, I would have liked it to be possible to just add it to the extension dir. This is solved by patching the hardcoded hotspot boostrap path and creating the correct symlink in the jre lib dir. Maybe the modules project and/or the extension/plugin ideas from icedtea can help a bit in the future to rewrite these kind of things a little cleaner: http://icedtea.classpath.org/wiki/PackagingExtensions 2008-06-22 Mark Wielaard <[EMAIL PROTECTED]> * patches/icedtea-rhino.patch: New patch. * Makefile.am: Add RHINO_JAR to environment variable lists. (ICEDTEA_PATHCES): Add patches/icedtea-rhino.patch. * Makefile.in: Regenerated. * acinclude.m4 (FIND_RHINO_JAR): New. * configure.ac: Use FIND_RHINO_JAR. * configure: Regenerated. Committed to icedtea6. With this patch the jrunscript works perfectly, and the javax.script and sun.tools.jscript jtreg tests all pass except for one. The sun/tools/jrunscript/jrunscriptTest.sh test insists that 2 + 5 = 7.0, while our current implementation says it is 7 (without the .0). The tests references two bugs (6265810,6705893) which might help analyze this, unfortunately they are closed to the public (is there anybody who could see what these bugs were about?). Cheers, Mark
diff -r 4999cbdbc405 Makefile.am --- a/Makefile.am Fri Jun 20 11:08:28 2008 -0400 +++ b/Makefile.am Mon Jun 23 11:20:37 2008 +0200 @@ -107,7 +107,8 @@ ICEDTEA_ENV = \ "FT2_LIB=$(FREETYPE2_LIBS)" \ "ALT_PARALLEL_COMPILE_JOBS=$(PARALLEL_JOBS)" \ "HOTSPOT_BUILD_JOBS=$(PARALLEL_JOBS)" \ - "JAVAC=" + "JAVAC=" \ + "RHINO_JAR=$(RHINO_JAR)" if WITH_CACAO ICEDTEA_ENV += \ @@ -172,7 +173,8 @@ ICEDTEA_ENV_ECJ = \ "FT2_LIB=$(FREETYPE2_LIBS)" \ "ALT_PARALLEL_COMPILE_JOBS=$(PARALLEL_JOBS)" \ "HOTSPOT_BUILD_JOBS=$(PARALLEL_JOBS)" \ - "JAVAC=" + "JAVAC=" \ + "RHINO_JAR=$(RHINO_JAR)" if WITH_CACAO ICEDTEA_ENV_ECJ += \ @@ -331,6 +333,7 @@ ICEDTEA_PATCHES = \ patches/icedtea-jscheme.patch \ patches/icedtea-dnd-updatecursor.patch \ patches/icedtea-component.patch \ + patches/icedtea-rhino.patch \ $(GCC_PATCH) \ $(DISTRIBUTION_PATCHES) diff -r 4999cbdbc405 acinclude.m4 --- a/acinclude.m4 Fri Jun 20 11:08:28 2008 -0400 +++ b/acinclude.m4 Mon Jun 23 11:20:37 2008 +0200 @@ -501,6 +501,38 @@ AC_DEFUN([FIND_XERCES2_JAR], AC_SUBST(XERCES2_JAR) ]) +AC_DEFUN([FIND_RHINO_JAR], +[ + AC_ARG_WITH([rhino-jar], + [AS_HELP_STRING(--with-rhino-jar,specify location of the rhino jar)], + [ + if test -f "${withval}"; then + AC_MSG_CHECKING(rhino jar) + RHINO_JAR="${withval}" + AC_MSG_RESULT(${withval}) + fi + ], + [ + RHINO_JAR= + ]) + if test -z "${RHINO_JAR}"; then + AC_MSG_CHECKING(for rhino jar) + if test -e "/usr/share/java/rhino.jar"; then + RHINO_JAR=/usr/share/java/rhino.jar + AC_MSG_RESULT(${RHINO_JAR}) + elif test -e "/usr/share/java/js.jar"; then + RHINO_JAR=/usr/share/java/js.jar + AC_MSG_RESULT(${RHINO_JAR}) + else + AC_MSG_RESULT(no) + fi + fi + if test -z "${RHINO_JAR}"; then + AC_MSG_ERROR("A rhino jar was not found.") + fi + AC_SUBST(RHINO_JAR) +]) + AC_DEFUN([ENABLE_OPTIMIZATIONS], [ AC_MSG_CHECKING(whether to disable optimizations) diff -r 4999cbdbc405 configure.ac --- a/configure.ac Fri Jun 20 11:08:28 2008 -0400 +++ b/configure.ac Mon Jun 23 11:20:37 2008 +0200 @@ -197,6 +197,7 @@ else FIND_XALAN2_JAR FIND_XALAN2_SERIALIZER_JAR FIND_XERCES2_JAR + FIND_RHINO_JAR AC_CONFIG_FILES([javac], [chmod +x javac]) AC_CONFIG_FILES([javap], [chmod +x javap]) fi diff -r 4999cbdbc405 patches/icedtea-rhino.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/icedtea-rhino.patch Mon Jun 23 11:20:37 2008 +0200 @@ -0,0 +1,149 @@ +--- openjdk.orig/jdk/make/com/sun/Makefile 2008-06-22 18:53:03.000000000 +0200 ++++ openjdk/jdk/make/com/sun/Makefile 2008-06-22 18:56:41.000000000 +0200 +@@ -31,15 +31,8 @@ + PRODUCT = sun + include $(BUILDDIR)/common/Defs.gmk + +-ifndef OPENJDK +- ORG_EXISTS := $(call DirExists,$(CLOSED_SRC)/share/classes/sun/org,,) +- ifneq ("$(ORG_EXISTS)", "") +- SCRIPT_SUBDIR = script +- endif +-endif +- + # Omit mirror since it's built with the apt tool. +-SUBDIRS = $(SCRIPT_SUBDIR) image security crypto/provider jndi jmx \ ++SUBDIRS = script image security crypto/provider jndi jmx \ + java inputmethods org xml rowset net/httpserver net/ssl demo \ + tools jarsigner + +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java 2008-06-22 19:02:39.000000000 +0200 +@@ -26,7 +26,7 @@ + package com.sun.script.javascript; + import com.sun.script.util.*; + import javax.script.*; +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + import java.lang.reflect.Method; + import java.io.*; + import java.util.*; +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/JSAdapter.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/JSAdapter.java 2008-06-22 19:02:49.000000000 +0200 +@@ -25,7 +25,7 @@ + + package com.sun.script.javascript; + +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + import java.util.*; + + /** +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/RhinoClassShutter.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoClassShutter.java 2008-06-22 19:03:00.000000000 +0200 +@@ -26,7 +26,7 @@ + package com.sun.script.javascript; + + import java.util.*; +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + + /** + * This class prevents script access to certain sensitive classes. +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java 2008-06-22 19:03:10.000000000 +0200 +@@ -26,7 +26,7 @@ + package com.sun.script.javascript; + import javax.script.*; + import java.util.*; +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + import com.sun.script.util.*; + + /** +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/RhinoCompiledScript.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoCompiledScript.java 2008-06-22 19:03:25.000000000 +0200 +@@ -25,7 +25,7 @@ + + package com.sun.script.javascript; + import javax.script.*; +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + + /** + * Represents compiled JavaScript code. +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java 2008-06-22 19:03:35.000000000 +0200 +@@ -25,7 +25,7 @@ + + package com.sun.script.javascript; + +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + import javax.script.*; + + /** +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/RhinoWrapFactory.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoWrapFactory.java 2008-06-22 19:03:48.000000000 +0200 +@@ -27,7 +27,7 @@ + + import java.lang.reflect.*; + import static sun.security.util.SecurityConstants.*; +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + + /** + * This wrap factory is used for security reasons. JSR 223 script +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/JavaAdapter.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/JavaAdapter.java 2008-06-22 19:05:17.000000000 +0200 +@@ -26,7 +26,7 @@ + package com.sun.script.javascript; + + import javax.script.Invocable; +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + + /** + * This class implements Rhino-like JavaAdapter to help implement a Java +--- openjdk.orig/jdk/src/share/classes/com/sun/script/javascript/ExternalScriptable.java 2008-06-22 18:52:46.000000000 +0200 ++++ openjdk/jdk/src/share/classes/com/sun/script/javascript/ExternalScriptable.java 2008-06-22 19:05:31.000000000 +0200 +@@ -24,7 +24,7 @@ + */ + + package com.sun.script.javascript; +-import sun.org.mozilla.javascript.internal.*; ++import org.mozilla.javascript.*; + import javax.script.*; + import java.util.*; + +--- openjdk.orig/jdk/make/com/sun/script/Makefile 2008-06-22 18:53:02.000000000 +0200 ++++ openjdk/jdk/make/com/sun/script/Makefile 2008-06-22 21:12:35.000000000 +0200 +@@ -31,6 +31,8 @@ + + AUTO_FILES_JAVA_DIRS = com/sun/script + ++OTHER_JAVACFLAGS = -classpath $(RHINO_JAR) ++ + # + # Files that need to be copied + # +--- openjdk.orig/jdk/make/common/Release.gmk 2008-06-22 18:53:02.000000000 +0200 ++++ openjdk/jdk/make/common/Release.gmk 2008-06-23 00:14:02.000000000 +0200 +@@ -772,6 +772,7 @@ + $(CP) $(RT_JAR) $(JRE_IMAGE_DIR)/lib/rt.jar + $(CP) $(RESOURCES_JAR) $(JRE_IMAGE_DIR)/lib/resources.jar + $(CP) $(JSSE_JAR) $(JRE_IMAGE_DIR)/lib/jsse.jar ++ $(LN) -sf $(RHINO_JAR) $(JRE_IMAGE_DIR)/lib/rhino.jar + @# Generate meta-index to make boot and extension class loaders lazier + $(CD) $(JRE_IMAGE_DIR)/lib && \ + $(BOOT_JAVA_CMD) -jar $(BUILDMETAINDEX_JARFILE) \ +--- openjdk/hotspot/src/share/vm/runtime/os.cpp.orig 2008-06-23 00:17:03.000000000 +0200 ++++ openjdk/hotspot/src/share/vm/runtime/os.cpp 2008-06-22 22:34:33.000000000 +0200 +@@ -949,6 +949,7 @@ + "%/lib/jsse.jar:" + "%/lib/jce.jar:" + "%/lib/charsets.jar:" ++ "%/lib/rhino.jar:" + "%/classes"; + char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep); + if (sysclasspath == NULL) return false;