Mercurial > hg > release > icedtea6-1.8
changeset 1885:4ac1082a1626
Fix a number of issues and enable the Rhino rewriter in the build.
2010-02-17 Andrew John Hughes <ahughes@redhat.com>
PR icedtea/179
* ChangeLog: Remove rogue whitespace highlighted
by emacs.
* Makefile.am:
(REWRITER_SRCS): Sources for class file rewriter.
Only set RHINO_JAR when WITH_RHINO is set. Point
to rewritten JAR file in build directory. Add
rewriter and license to EXTRA_DIST. Make icedtea,
icedtea-debug and icedtea-ecj depend on rewrite-rhino.stamp.
(stamps/rewriter.stamp): Build the class file rewriter.
(stamps/rewrite-rhino.stamp): Rewrite the system Rhino JAR
file to use the sun.org.mozilla namespace to avoid conflicts.
(rewriter): New alias for stamps/rewriter.stamp.
(rewrite-rhino): Likewise for stamps/rewrite-rhino.stamp.
* patches/icedtea-rhino.patch:
Copy rather than symlink the JAR file. Only drop the
internal suffix on the javascript package names.
* rewriter/com/redhat/rewriter/ClassRewriter.java:
(executor): Use a single threaded executor when
debugging is enabled.
(tasks): Store the Futures returned by the executor
for later checking.
(main(String[])): Log what happens when processFile
returns and handle any exceptions using Futures.
(call()): Ensure srcDir/destDir replacement always
matches with a trailing slash to avoid odd rewrites.
Loop directory creation to avoid possible race issues.
Increase logging and fix a number of issues with the rewrite:
* Fix off-by-one loop bug so final entry is inspected.
* Handle double entries which occur with 8-byte entries
(doubles and longs):
http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#16628
author | Andrew John Hughes <ahughes@redhat.com> |
---|---|
date | Wed, 17 Feb 2010 23:15:20 +0000 |
parents | 6dccdd4c25c7 |
children | 0e7eb56f320b |
files | ChangeLog Makefile.am patches/icedtea-rhino.patch rewriter/com/redhat/rewriter/ClassRewriter.java |
diffstat | 4 files changed, 169 insertions(+), 59 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Feb 17 14:46:46 2010 +0100 +++ b/ChangeLog Wed Feb 17 23:15:20 2010 +0000 @@ -1,3 +1,38 @@ +2010-02-17 Andrew John Hughes <ahughes@redhat.com> + + PR icedtea/179 + * ChangeLog: Remove rogue whitespace highlighted + by emacs. + * Makefile.am: + (REWRITER_SRCS): Sources for class file rewriter. + Only set RHINO_JAR when WITH_RHINO is set. Point + to rewritten JAR file in build directory. Add + rewriter and license to EXTRA_DIST. Make icedtea, + icedtea-debug and icedtea-ecj depend on rewrite-rhino.stamp. + (stamps/rewriter.stamp): Build the class file rewriter. + (stamps/rewrite-rhino.stamp): Rewrite the system Rhino JAR + file to use the sun.org.mozilla namespace to avoid conflicts. + (rewriter): New alias for stamps/rewriter.stamp. + (rewrite-rhino): Likewise for stamps/rewrite-rhino.stamp. + * patches/icedtea-rhino.patch: + Copy rather than symlink the JAR file. Only drop the + internal suffix on the javascript package names. + * rewriter/com/redhat/rewriter/ClassRewriter.java: + (executor): Use a single threaded executor when + debugging is enabled. + (tasks): Store the Futures returned by the executor + for later checking. + (main(String[])): Log what happens when processFile + returns and handle any exceptions using Futures. + (call()): Ensure srcDir/destDir replacement always + matches with a trailing slash to avoid odd rewrites. + Loop directory creation to avoid possible race issues. + Increase logging and fix a number of issues with the rewrite: + * Fix off-by-one loop bug so final entry is inspected. + * Handle double entries which occur with 8-byte entries + (doubles and longs): + http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#16628 + 2010-02-17 Xerxes RĂ„nby <xerxes@zafena.se> * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp @@ -9,7 +44,7 @@ Allways define llvm/Support/CommandLine.h. 2010-02-16 Gary Benson <gbenson@redhat.com> - + * contrib/jck/compile-native-code.sh: Add s390. 2010-02-15 Andrew John Hughes <ahughes@redhat.com> @@ -177,7 +212,7 @@ * NEWS: Add missing items for 1.5.1, 1.5.2, 1.5.3, 1.6.1 and 1.6.2. - + 2010-01-27 Edward Nevill <ed@camswl.com> * ports/hotspot/src/cpu/zero/vm/thumb2.cpp @@ -188,7 +223,7 @@ * NEWS: Added message about alpha release for the new NPR based plugin. 2010-01-27 Matthias Klose <doko@ubuntu.com> - + * Makefile.am: Remove quoting from ICEDTEA_NAME ICEDTEA_REV ICEDTEA_PKG. @@ -221,39 +256,39 @@ * Makefile.am: Build NPPlugin source files separately. - + 2010-01-25 Andrew John Hughes <ahughes@redhat.com> * Makefile.am: Fix ICEDTEAPLUGIN_TARGET to use new stamp targets and remove redundant ICEDTEANPPPLUGIN_TARGET. - + 2010-01-25 Andrew John Hughes <ahughes@redhat.com> * Makefile.am: Use NPPLUGIN_SRCDIR for Java plugin sources. - + 2010-01-25 Andrew John Hughes <ahughes@redhat.com> * Makefile.am: Provide stamp targets for both npplugin and the old plugin so 'make plugin' builds the one configured. - + 2010-01-25 Andrew John Hughes <ahughes@redhat.com> * Makefile.am: Remove trailing space after IcedTea version in plugin version information when package version is not set. - + 2010-01-25 Andrew John Hughes <ahughes@redhat.com> * Makefile.am: Build NPPlugin in the build directory, not the source tree. - + 2010-01-22 Deepak Bhole <dbhole@redhat.com> * Makefile.am: @@ -289,7 +324,7 @@ * patches/icedtea-libraries.patch: Make all dlopen choices at build-time, not just one. Support libjpeg8 as well. - + 2010-01-21 Andrew John Hughes <ahughes@redhat.com> PR icedtea/433 @@ -316,7 +351,7 @@ * Makefile.am: Fix paths to patches and IcedTeaNPPlugin.cc for make dist. - + 2010-01-20 Andrew John Hughes <ahughes@redhat.com> * Makefile.am: @@ -380,7 +415,7 @@ * configure.ac: Use AC_LANG_PUSH and AC_LANG_POP instead of deprecated SAVE and RESTORE macros. - + 2010-01-18 Andrew John Hughes <ahughes@redhat.com> PR icedtea/416: @@ -388,7 +423,7 @@ Use $(OPENJDK_SRC_ZIP) and $(HOTSPOT_SRC_ZIP) to determine names of tarballs rather than hardcoding openjdk.tar.gz and hotspot.tar.gz - + 2010-01-17 Matthias Klose <doko@ubuntu.com> * patches/icedtea-sparc-trapsfix.patch: Merged sparc headers @@ -406,13 +441,13 @@ (IT_FIND_NUMBER_OF_PROCESSORS): Dependency of above. Uses getconf to obtain the number of available processors. - + 2010-01-16 Andrew John Hughes <ahughes@redhat.com> * acinclude.m4: Send output to AS_MESSAGE_LOG_FD rather than /dev/null so we have a record of errors. - + 2010-01-16 Andrew John Hughes <ahughes@redhat.com> configure output and option cleanup @@ -523,7 +558,7 @@ * patches/hotspot/hs16/memory-limits.patch: Add HotSpot 16 version of memory limits patch. - + 2010-01-11 Andrew John Hughes <ahughes@redhat.com> Bump to latest HotSpot 16 (b13). @@ -601,14 +636,14 @@ using any Mozilla code) in IcedTeaPluginUtils. (get_scriptable_object): Initialize handle to 0 if not already set. (GCJ_SetWindow): Set proper instance id when manipulating height. - * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc: Add temporary + * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc: Add temporary workaround for chromium which seems to free on calls to NPN_PluginThreadAsyncCall. * plugin/icedteanp/IcedTeaPluginUtils.cc (decodeURL): New function. Decodes an encoded URL. * plugin/icedteanp/IcedTeaPluginUtils.h: Added helper macros for decodeURL. - * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: Make panel + * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: Make panel visible only if handle is non-zero. (parse): Fix regression introduced when fix for Bug# 406 was ported over. Normalized default width and height. @@ -617,7 +652,7 @@ * configure.ac: Bump version to 1.8pre. * NEWS: Mention X11 fix. - + 2009-12-22 Deepak Bhole <dbhole@redhat.com> * Makefile.am: Set JDK_UPDATE_VERSION based on upstream drop version @@ -645,7 +680,7 @@ 2009-12-14 Man Lung Wong <mwong@redhat.com> * rt/net/sourceforge/jnlp/Launcher.java - (launch): File is not launched if offline-allowed tag not present and + (launch): File is not launched if offline-allowed tag not present and system offline. 2009-12-13 Mark Wielaard <mjw@redhat.com>
--- a/Makefile.am Wed Feb 17 14:46:46 2010 +0100 +++ b/Makefile.am Wed Feb 17 23:15:20 2010 +0000 @@ -197,6 +197,8 @@ PLUGIN_TEST_SRCS = $(abs_top_srcdir)/plugin/tests/LiveConnect/*.java +REWRITER_SRCS = $(abs_top_srcdir)/rewriter/com/redhat/rewriter/ClassRewriter.java + # Patch list ICEDTEA_FSG_PATCHES = @@ -446,7 +448,6 @@ JAVAC="" \ JAVA_HOME="" \ JDK_HOME="" \ - RHINO_JAR="$(RHINO_JAR)" \ DISTRIBUTION_ID="$(DIST_ID)" \ DERIVATIVE_ID="$(ICEDTEA_NAME) $(PACKAGE_VERSION)$(ICEDTEA_REV)" \ DEBUG_CLASSFILES="true" \ @@ -484,6 +485,11 @@ HOTSPOT_BUILD_VERSION="$(HOTSPOT_REVISION)" endif +if WITH_RHINO +ICEDTEA_ENV += \ + RHINO_JAR="$(abs_top_builddir)/rhino/rhino.jar" +endif + # OpenJDK ecj build environment. # FIXME (bootstrap): Remove duplication ICEDTEA_ENV_ECJ = \ @@ -529,7 +535,6 @@ JAVAC="" \ JAVA_HOME="" \ JDK_HOME="" \ - RHINO_JAR="$(RHINO_JAR)" \ JAR_KNOWS_ATFILE="$(JAR_KNOWS_ATFILE)" \ JAR_KNOWS_J_OPTIONS="$(JAR_KNOWS_J_OPTIONS)" \ JAR_ACCEPTS_STDIN_LIST="$(JAR_ACCEPTS_STDIN_LIST)" \ @@ -565,6 +570,11 @@ HOTSPOT_BUILD_VERSION="$(HOTSPOT_REVISION)" endif +if WITH_RHINO +ICEDTEA_ENV_ECJ += \ + RHINO_JAR="$(abs_top_builddir)/rhino/rhino.jar" +endif + # Source files # FIXME (distclean): Add generated file list # FIXME (distclean): Add jtreg sources @@ -585,7 +595,9 @@ tapset/hotspot.stp.in \ tapset/hotspot_jni.stp.in \ scripts/jni_create_stap.c \ - scripts/jni_desc + scripts/jni_desc \ + rewriter/agpl-3.0.txt \ + $(REWRITER_SRCS) # Top-Level Targets # ================= @@ -1226,7 +1238,7 @@ stamps/ports.stamp stamps/patch.stamp stamps/overlay.stamp \ $(ICEDTEAPLUGIN_TARGET) $(ICEDTEANPPLUGIN_TARGET) \ extra-lib/about.jar stamps/cacao.stamp stamps/visualvm.stamp \ - stamps/pulse-java.stamp + stamps/pulse-java.stamp stamps/rewrite-rhino.stamp $(ARCH_PREFIX) $(MAKE) \ $(ICEDTEA_ENV) \ -C openjdk \ @@ -1325,7 +1337,7 @@ stamps/ports.stamp stamps/patch.stamp stamps/overlay.stamp \ $(ICEDTEAPLUGIN_TARGET) $(ICEDTEANPPLUGIN_TARGET) \ extra-lib/about.jar stamps/cacao.stamp stamps/visualvm.stamp \ - stamps/pulse-java.stamp + stamps/pulse-java.stamp stamps/rewrite-rhino.stamp $(ARCH_PREFIX) $(MAKE) \ $(ICEDTEA_ENV) \ -C openjdk \ @@ -1447,7 +1459,7 @@ stamps/icedtea-ecj.stamp: stamps/bootstrap-directory-symlink-ecj.stamp \ stamps/hotspot-tools.stamp stamps/plugs.stamp \ - stamps/patch-ecj.stamp stamps/cacao.stamp + stamps/patch-ecj.stamp stamps/cacao.stamp stamps/rewrite-rhino.stamp $(ARCH_PREFIX) $(MAKE) \ $(ICEDTEA_ENV_ECJ) \ -C openjdk-ecj/ \ @@ -1680,6 +1692,39 @@ # end of pulse-java +# Rhino support + +stamps/rewriter.stamp: $(INITIAL_BOOTSTRAP_LINK_STAMP) +if WITH_RHINO + (cd $(abs_top_srcdir)/rewriter ; \ + $(ICEDTEA_BOOT_DIR)/bin/javac -g \ + -d $(abs_top_builddir)/rewriter $(REWRITER_SRCS) \ + ) +endif + mkdir -p stamps + touch stamps/rewriter.stamp + +stamps/rewrite-rhino.stamp: stamps/rewriter.stamp $(RHINO_JAR) +if WITH_RHINO + mkdir -p rhino/rhino.{old,new} + (cd rhino/rhino.old ; jar xf $(RHINO_JAR)) + $(ICEDTEA_BOOT_DIR)/bin/java -cp $(abs_top_builddir)/rewriter \ + com.redhat.rewriter.ClassRewriter \ + $(abs_top_builddir)/rhino/rhino.old $(abs_top_builddir)/rhino/rhino.new \ + org.mozilla sun.org.mozilla + (cd rhino/rhino.old ; \ + for files in `find -type f -not -name '*.class'` ; do \ + new_file=../rhino.new/`echo $$files|sed -e 's#org#sun/org#'` ; \ + mkdir -p `dirname $$new_file` ; \ + cp -v $$files $$new_file ; \ + sed -ie 's#org\.mozilla#sun.org.mozilla#g' $$new_file ; \ + done \ + ) + (cd rhino/rhino.new ; jar cfm ../rhino.jar META-INF/MANIFEST.MF sun ) +endif + mkdir -p stamps + touch stamps/rewrite-rhino.stamp + # VisualVM stamps/nbplatform.stamp: $(INITIAL_BOOTSTRAP_LINK_STAMP) stamps/extract.stamp @@ -2189,6 +2234,10 @@ overlay: stamps/overlay.stamp +rewriter: stamps/rewriter.stamp + +rewrite-rhino: stamps/rewrite-rhino.stamp + plugs: stamps/plugs.stamp rt-class-files: stamps/rt-class-files.stamp
--- a/patches/icedtea-rhino.patch Wed Feb 17 14:46:46 2010 +0100 +++ b/patches/icedtea-rhino.patch Wed Feb 17 23:15:20 2010 +0000 @@ -44,7 +44,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 ++ $(CP) $(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) \ @@ -55,7 +55,7 @@ package com.sun.script.javascript; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; import javax.script.*; /** @@ -66,7 +66,7 @@ import javax.script.*; import java.util.*; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; import com.sun.script.util.*; /** @@ -77,7 +77,7 @@ package com.sun.script.javascript; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; import javax.script.*; import java.util.*; @@ -88,7 +88,7 @@ import com.sun.script.util.*; import javax.script.*; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; import java.lang.reflect.Method; import java.io.*; import java.util.*; @@ -99,7 +99,7 @@ import java.util.*; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; /** * This class prevents script access to certain sensitive classes. @@ -110,7 +110,7 @@ import javax.script.Invocable; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; /** * This class implements Rhino-like JavaAdapter to help implement a Java @@ -121,7 +121,7 @@ package com.sun.script.javascript; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; import java.util.*; /** @@ -132,7 +132,7 @@ import java.lang.reflect.*; import static sun.security.util.SecurityConstants.*; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; /** * This wrap factory is used for security reasons. JSR 223 script @@ -143,7 +143,7 @@ package com.sun.script.javascript; import javax.script.*; -import sun.org.mozilla.javascript.internal.*; -+import org.mozilla.javascript.*; ++import sun.org.mozilla.javascript.*; /** * Represents compiled JavaScript code.
--- a/rewriter/com/redhat/rewriter/ClassRewriter.java Wed Feb 17 14:46:46 2010 +0100 +++ b/rewriter/com/redhat/rewriter/ClassRewriter.java Wed Feb 17 23:15:20 2010 +0000 @@ -27,11 +27,15 @@ import java.nio.charset.Charset; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.logging.ConsoleHandler; @@ -56,15 +60,21 @@ /** * The executor for submitting rewriting jobs. */ - private static final ExecutorService executor = Executors.newCachedThreadPool(); + private static final ExecutorService executor = DEBUG ? + Executors.newSingleThreadExecutor() : Executors.newCachedThreadPool(); /** * The source directory, set once by main. */ private static File srcDir; + /** + * The list of tasks submitted to the executor. + */ + private static List<Future<Void>> tasks = new ArrayList<Future<Void>>(); + public static void main(String[] args) - throws Exception + throws ExecutionException, InterruptedException { if (args.length < 4) { @@ -78,17 +88,15 @@ handler.setLevel(level); logger.addHandler(handler); srcDir = new File(args[0]); - try - { - processFile(srcDir, args[1], args[2], args[3]); - } - finally - { - executor.shutdown(); - executor.awaitTermination(1, TimeUnit.MINUTES); - if (!executor.isTerminated()) - throw new Exception("Rewriting failed to complete"); - } + processFile(srcDir, args[1], args[2], args[3]); + logger.info("Waiting for rewrites to complete..."); + executor.shutdown(); + executor.awaitTermination(1, TimeUnit.MINUTES); + logger.info("Checking for errors..."); + // Check for exceptions + for (Future<Void> f : tasks) + f.get(); + logger.info("Rewriting completed successfully."); } private static void processFile(File srcDir, String destDir, @@ -103,7 +111,8 @@ else if (srcDir.getName().endsWith(".class")) { logger.info("Processing class " + srcDir); - executor.submit(new ClassRewriter(srcDir, destDir, oldPkg, newPkg)); + tasks.add(executor.submit(new ClassRewriter(srcDir, destDir, + oldPkg, newPkg))); } else logger.fine("Skipping " + srcDir); @@ -147,8 +156,11 @@ String dollaredNewPackage = newPackage.replace(".", "$"); File outClass = - new File(classFile.getPath().replace(srcDir.getPath(), destDir).replace(slashedOldPackage, slashedNewPackage)); - outClass.getParentFile().mkdirs(); + new File(classFile.getPath().replace(srcDir.getPath() + File.separator, + destDir + File.separator).replace(slashedOldPackage, slashedNewPackage)); + File targetDir = outClass.getParentFile(); + while (!targetDir.exists()) + outClass.getParentFile().mkdirs(); DataInputStream is = new DataInputStream(new FileInputStream(classFile)); DataOutputStream os = new DataOutputStream(new FileOutputStream(outClass)); @@ -170,14 +182,14 @@ throw new IOException("Could not read version number."); os.write(version); - short cpCount = is.readShort(); + int cpCount = is.readUnsignedShort(); os.writeShort(cpCount); logger.fine("Constant pool has " + cpCount + " items."); - for (int a = 1; a < cpCount - 1; ++a) + for (int a = 1; a < cpCount ; ++a) { - String prefix = "At index " + a + " : "; - byte tag = (byte) is.read(); + byte tag = is.readByte(); + String prefix = "At index " + a + ", tag " + tag + ": "; os.write(tag); switch (tag) { @@ -186,11 +198,23 @@ String data = is.readUTF(); logger.fine(prefix + "String " + data); if (data.contains(oldPackage)) - data = data.replace(oldPackage, newPackage); + { + logger.fine(String.format("%s: Found %s\n", outClass.toString(), data)); + data = data.replace(oldPackage, newPackage); + logger.fine(String.format("%s: Rewriting to %s\n", outClass.toString(), data)); + } else if (data.contains(slashedOldPackage)) - data = data.replace(slashedOldPackage, slashedNewPackage); + { + logger.fine(String.format("%s: Found %s\n", outClass.toString(), data)); + data = data.replace(slashedOldPackage, slashedNewPackage); + logger.fine(String.format("%s: Rewriting to %s\n", outClass.toString(), data)); + } else if (data.contains(dollaredOldPackage)) - data = data.replace(dollaredOldPackage, dollaredNewPackage); + { + logger.fine(String.format("%s: Found %s\n", outClass.toString(), data)); + data = data.replace(dollaredOldPackage, dollaredNewPackage); + logger.fine(String.format("%s: Rewriting to %s\n", outClass.toString(), data)); + } os.writeUTF(data); break; case 3: @@ -210,12 +234,14 @@ long longBytes = is.readLong(); logger.fine(prefix + "Long " + longBytes); os.writeLong(longBytes); + ++a; // longs count as two entries break; case 6: /* CONSTANT_Double_Info */ double doubleBytes = is.readDouble(); logger.fine(prefix + "Double " + doubleBytes); os.writeDouble(doubleBytes); + ++a; // doubles count as two entries break; case 7: case 8: