8081589: Output of -XX:+TraceClassLoadingPreorder in JDK9 incompatible with MakeClasslist tool
authorredestad
Wed, 08 Jul 2015 16:04:42 +0200
changeset 31535 648a7c44beef
parent 31534 28d66c729c18
child 31536 3090612af7dd
8081589: Output of -XX:+TraceClassLoadingPreorder in JDK9 incompatible with MakeClasslist tool Reviewed-by: iklam, hseigel
jdk/make/non-build-utils/sharing/README.txt
jdk/make/non-build-utils/sharing/tests/GHello.java
jdk/make/non-build-utils/sharing/tests/Hello.java
jdk/make/non-build-utils/sharing/tests/JHello.java
jdk/make/non-build-utils/src/build/tools/makeclasslist/MakeClasslist.java
jdk/make/non-build-utils/src/build/tools/makeclasslist/makeClasslist.js
--- a/jdk/make/non-build-utils/sharing/README.txt	Wed Jul 08 11:58:14 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-This directory contains tools and tests associated with creating the
-class list for class data sharing.
-
-The class list is produced by running the refWorkload startup3 benchmark with
-the -XX:+TraceClassLoadingPreorder option.  The -Xshare:off option must also be
-used so that bootclasspath classes are loaded from rt.jar.  The MakeClasslist
-program should be built into the jar file makeclasslist.jar and is run
-on one of the logs from each of the benchmarks in the following fashion:
-
-cd .../<resultsdir>/results.startup3
-$JAVA_HOME/bin/java -jar makeclasslist.jar results.Noop/results_1/log results.Framer/results_1/log results.XFramer/results_1/log results.JEdit/results_1/log results.LimeWire/results_1/log results.NetBeans50/results_1/log
-
-Presently, $JAVA_HOME must be the same path used to run the startup3 benchmark.
-
-The logs are deliberately concatenated in roughly smallest to largest order
-based on application size.  The resulting output is redirected into a file
-and results in one of classlist.solaris, classlist.linux, classlist.macosx,
-or classlist.windows.  These files are checked in to the workspace.  A
-necessary checksum (AddJsum.java) is added to the final classlist
-(installed in lib/ or jre/lib/) during the build process by the
-makefiles in make/java/redist.
-
-In a forthcoming JDK build we plan to manually add the dependent
-classes for the calendar manager Glow, which pulls in the Preferences
-classes and, on Unix platforms, the XML parsing classes.
-
-The properties file supplied to the refworkload is approximately the
-following:
-
-javahome=/usr/java/j2sdk1.8.0
-resultsdir=classlist-run
-iterations=1
-benchmarks=startup3
-globalvmoptions=-client -Xshare:off -XX:+TraceClassLoadingPreorder
--- a/jdk/make/non-build-utils/sharing/tests/GHello.java	Wed Jul 08 11:58:14 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import java.awt.Font;
-import java.awt.Frame;
-import java.awt.Label;
-
-public class GHello extends Frame {
-
-    public static void main(String[] args) {
-        System.out.println("Hello");
-
-        new GHello().show();
-        if (args.length == 1 && args[0].equals("quit")) {
-            try {
-                Thread.currentThread().sleep(200);
-            } catch (InterruptedException e) {
-            }
-            System.exit(0);
-        }
-    }
-
-
-    GHello() {
-        Label label = new Label("Hello");
-        label.setFont(new Font("Monospaced", Font.PLAIN, 144));
-        add(label);
-        pack();
-    }
-}
--- a/jdk/make/non-build-utils/sharing/tests/Hello.java	Wed Jul 08 11:58:14 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-
-public class Hello {
-    public static void main(String[] args) {
-        System.out.println("Hello, World!");
-    }
-}
--- a/jdk/make/non-build-utils/sharing/tests/JHello.java	Wed Jul 08 11:58:14 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import java.awt.Font;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-
-public class JHello extends JFrame {
-
-    public static void main(String[] args) {
-        System.out.println("Hello");
-
-        new JHello().show();
-        if (args.length == 1 && args[0].equals("quit")) {
-            try {
-                Thread.currentThread().sleep(1000);
-            } catch (InterruptedException e) {
-            }
-            System.exit(0);
-        }
-    }
-
-
-    JHello() {
-        JLabel jlabel = new JLabel("Hello");
-        jlabel.setFont(new Font("Monospaced", Font.PLAIN, 144));
-        getContentPane().add(jlabel);
-        pack();
-    }
-}
--- a/jdk/make/non-build-utils/src/build/tools/makeclasslist/MakeClasslist.java	Wed Jul 08 11:58:14 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package build.tools.makeclasslist;
-
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-
-/** Reads a set of files containing the output of java
-    -XX:+TraceClassLoadingPreorder runs. Finds all classes that were
-    loaded from the bootstrap class path by comparing the prefix of
-    the load path to the current JRE's java.home system property.
-    Prints the names of these classes to stdout.
-*/
-
-public class MakeClasslist {
-  public static void main(String[] args) throws IOException {
-    List<String> classes = new ArrayList<>();
-    String origJavaHome = System.getProperty("java.home");
-    String javaHome     = origJavaHome.toLowerCase();
-    if (javaHome.endsWith("jre")) {
-      origJavaHome = origJavaHome.substring(0, origJavaHome.length() - 4);
-      javaHome     = javaHome.substring(0, javaHome.length() - 4);
-    }
-    for (int i = 0; i < args.length; i++) {
-      try {
-        File file = new File(args[i]);
-        BufferedReader reader = new BufferedReader(new FileReader(file));
-        String line = null;
-        while ((line = reader.readLine()) != null) {
-          StringTokenizer tok = new StringTokenizer(line, "[ \t\n\r\f");
-          if (tok.hasMoreTokens()) {
-            String t = tok.nextToken();
-            // Understand only "Loading" from -XX:+TraceClassLoadingPreorder.
-            // This ignores old "Loaded" from -verbose:class to force correct
-            // classlist generation on Mustang.
-            if (t.equals("Loading")) {
-              t = tok.nextToken();
-              t = t.replace('.', '/');
-
-              // Check to make sure it came from the boot class path
-              if (tok.hasMoreTokens()) {
-                String tmp = tok.nextToken();
-                if (tmp.equals("from")) {
-                  if (tok.hasMoreTokens()) {
-                    tmp = tok.nextToken().toLowerCase();
-                    // System.err.println("Loaded " + t + " from " + tmp);
-                    if (tmp.startsWith(javaHome)) {
-                      // OK, remember this class for later
-                      classes.add(t);
-                    }
-                  }
-                }
-              }
-            }
-          }
-        }
-      } catch (IOException e) {
-        System.err.println("Error reading file " + args[i]);
-        throw(e);
-      }
-    }
-
-    Set<String> seenClasses = new HashSet<>();
-
-    for (String str : classes) {
-      if (seenClasses.add(str)) {
-        System.out.println(str);
-      }
-    }
-
-    // Try to complete certain packages
-    // Note: not using this new code yet; need to consider whether the
-    // footprint increase is worth any startup gains
-    // Note also that the packages considered below for completion are
-    // (obviously) platform-specific
-    // JarFile rtJar = new JarFile(origJavaHome + File.separator +
-    //                             "jre" + File.separator +
-    //                             "lib" + File.separator +
-    //                             "rt.jar");
-    // completePackage(seenClasses, rtJar, "java/awt");
-    // completePackage(seenClasses, rtJar, "sun/awt");
-    // completePackage(seenClasses, rtJar, "sun/awt/X11");
-    // completePackage(seenClasses, rtJar, "java/awt/im/spi");
-    // completePackage(seenClasses, rtJar, "java/lang");
-  }
-
-  private static void completePackage(Set<String> seenClasses,
-                                      JarFile jar,
-                                      String packageName) {
-    int len = packageName.length();
-    Enumeration<JarEntry> entries = jar.entries();
-    while (entries.hasMoreElements()) {
-      JarEntry entry = entries.nextElement();
-      String name = entry.getName();
-      if (name.startsWith(packageName) &&
-          name.endsWith(".class") &&
-          name.lastIndexOf('/') == len) {
-        // Trim ".class" from end
-        name = name.substring(0, name.length() - 6);
-        if (seenClasses.add(name)) {
-          System.out.println(name);
-        }
-      }
-    }
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/non-build-utils/src/build/tools/makeclasslist/makeClasslist.js	Wed Jul 08 16:04:42 2015 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * This tool is used to help create the class list for class data sharing.
+ *
+ * The classlist is produced internally by first running a select number of
+ * startup benchmarks with the -XX:DumpLoadedClassList=<file> option, then
+ * running this tool in the following fashion to produce a complete classlist:
+ *
+ * jjs -scripting makeClasslist.js -- list1 list2 list3 > classlist.platform
+ *
+ * The lists should be listed in roughly smallest to largest order based on
+ * application size.
+ *
+ * After generating the classlist it's necessary to add a checksum (using
+ * AddJsum.java) before checking it into the workspace as the corresponding
+ * platform-specific classlist, such as make/data/classlist/classlist.linux 
+ */
+"use strict";
+var classlist = [];
+var seenClasses = {};
+
+for (var a in $ARG) {
+  var arg = $ARG[a];
+
+  var classes = readFully(arg).replace(/[\r\n]+/g, "\n").split("\n");
+
+  for (var c in classes) {
+    var clazz = classes[c];
+    if (clazz !== "" && seenClasses[clazz] === undefined) {
+      seenClasses[clazz] = clazz;
+      classlist.push(clazz);
+    }
+  }
+}
+
+for (c in classlist) {
+  print(classlist[c]);
+}