8161138: testlibrary_tests/ctw/* failed with "Failed. Unexpected exit from test [exit code: 0]"
authortpivovarova
Fri, 29 Jul 2016 17:41:14 +0300
changeset 40104 3edf5d1e6399
parent 40092 50da4636cb1c
child 40105 b33c14adfcc3
child 40334 5925b30a8f74
8161138: testlibrary_tests/ctw/* failed with "Failed. Unexpected exit from test [exit code: 0]" Reviewed-by: kvn
hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CompileTheWorld.java
hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java
--- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CompileTheWorld.java	Thu Jul 28 16:09:31 2016 +0300
+++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/CompileTheWorld.java	Fri Jul 29 17:41:14 2016 +0300
@@ -35,8 +35,8 @@
 public class CompileTheWorld {
     // in case when a static constructor changes System::out and System::err
     // we hold these values of output streams
-    public static final PrintStream OUT = System.out;
-    public static final PrintStream ERR = System.err;
+    static PrintStream OUT = System.out;
+    static final PrintStream ERR = System.err;
     /**
      * Entry point. Compiles classes in {@code paths}
      *
@@ -56,7 +56,7 @@
             }
         }
         if (os != null) {
-            System.setOut(os);
+            OUT = os;
         }
 
         try {
@@ -89,9 +89,6 @@
                 os.close();
             }
         }
-        // in case when a static constructor creates and runs a new thread
-        // we force it to exit
-        System.exit(0);
     }
 
     private static ExecutorService createExecutor() {
--- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java	Thu Jul 28 16:09:31 2016 +0300
+++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java	Fri Jul 29 17:41:14 2016 +0300
@@ -28,12 +28,11 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-
 import java.util.Objects;
+import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.util.concurrent.Executor;
 
 /**
  * Abstract handler for path.
@@ -152,7 +151,10 @@
         if (id >= Utils.COMPILE_THE_WORLD_START_AT) {
             try {
                 Class<?> aClass = loader.loadClass(name);
-                UNSAFE.ensureClassInitialized(aClass);
+                if (name != "sun.reflect.misc.Trampoline"
+                        && name != "sun.tools.jconsole.OutputViewer") { // workaround for JDK-8159155
+                    UNSAFE.ensureClassInitialized(aClass);
+                }
                 CompileTheWorld.OUT.printf("[%d]\t%s%n", id, name);
                 Compiler.compileClass(aClass, id, executor);
             } catch (ClassNotFoundException e) {