--- old/test/hotspot/jtreg/ProblemList.txt 2018-06-04 03:54:38.501161149 -0400 +++ new/test/hotspot/jtreg/ProblemList.txt 2018-06-04 03:54:36.977073063 -0400 @@ -71,16 +71,8 @@ ############################################################################# # :hotspot_runtime -runtime/appcds/redefineClass/RedefineRunningMethods_Shared.java 8199450 generic-all -runtime/appcds/redefineClass/RedefineBasicTest.java 8199450 generic-all + runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all -runtime/RedefineTests/RedefineFinalizer.java 8199450 generic-all -runtime/RedefineTests/RedefineRunningMethods.java 8199450 generic-all -runtime/RedefineTests/RedefinePreviousVersions.java 8199450 generic-all -runtime/RedefineTests/RedefineDoubleDelete.java 8199450 generic-all -runtime/RedefineTests/RedefineInterfaceMethods.java 8199450 generic-all -runtime/RedefineTests/RedefineInterfaceCall.java 8199450 generic-all -runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java 8199450 generic-all ############################################################################# @@ -111,8 +103,6 @@ ############################################################################# -testlibrary_tests/RedefineClassTest.java 8199450 generic-all - vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded003/TestDescription.java 8153598 generic-all vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java 8198668 generic-all vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002/TestDescription.java 8153598 generic-all @@ -135,8 +125,6 @@ vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l005/TestDescription.java 8068225 generic-all vmTestbase/nsk/jdi/stress/ClassPrepareEvents/ClassPrepareEvents001/ClassPrepareEvents001.java 6426321 generic-all -vmTestbase/nsk/stress/except/except004.java 8203046 generic-all - vmTestbase/metaspace/gc/firstGC_10m/TestDescription.java 8160008 generic-all vmTestbase/metaspace/gc/firstGC_50m/TestDescription.java 8160008 generic-all vmTestbase/metaspace/gc/firstGC_99m/TestDescription.java 8160008 generic-all --- old/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except004.java 2018-06-04 03:54:44.057482275 -0400 +++ new/test/hotspot/jtreg/vmTestbase/nsk/stress/except/except004.java 2018-06-04 03:54:42.513393035 -0400 @@ -211,15 +211,15 @@ Object integerValue = new Integer(0); Object doubleValue = new Double(0); Object trash = null; - Field abraPrivateField; Field abraIntegerField; Field abraBooleanField; + Field extPrivateField; try { - abraPrivateField = Abra.class.getDeclaredField("DONT_TOUCH_ME"); abraIntegerField = Abra.class.getDeclaredField("MAIN_CYR_NUMBER"); abraBooleanField = Abra.class.getDeclaredField("NOT_AN_INTEGER"); + extPrivateField = Ext.class.getDeclaredField("DONT_TOUCH_ME"); } catch (NoSuchFieldException nsfe) { - out.println("Test initialisation failed: field not found in class Abra"); + out.println("Test initialisation failed: field not found: " + nsfe.getMessage()); return 2; } @@ -369,7 +369,6 @@ // Check IllegalAccessException (positive): try { int junkIt = abraIntegerField.getInt(null); // legal - should pass -// int junkIt = abraPrivateField.getInt(null); // illegal - should fail if (TRACE_ON) log[messages++] = "Success: IllegalAccessException (positive)"; } catch (IllegalAccessException iae) { @@ -383,8 +382,7 @@ // Check IllegalAccessException (negative): try { -// int junkIt = abraIntegerField.getInt(null); // legal - should pass - int junkIt = abraPrivateField.getInt(null); // illegal - should fail + int junkIt = extPrivateField.getInt(null); // illegal - should fail log[messages++] = "Failure: IllegalAccessException (negative)"; exitCode = 2; // FAILED } catch (IllegalAccessException iae) { @@ -512,7 +510,7 @@ /** * This class should be used to check CloneNotSupportedException, - * IllegalAccessException, and IllegalArgumentException. + * and IllegalArgumentException. * The class extends except004 in order that its (protected) * method clone() be available from except004. */ @@ -527,10 +525,6 @@ /** * Will try to incorrectly access to this field from outside this class. */ - private static final int DONT_TOUCH_ME = 666; - /** - * Will try to incorrectly access to this field from outside this class. - */ public static final int MAIN_CYR_NUMBER = 47; /** * Will try to get this field like int zero. @@ -551,3 +545,11 @@ } } } + +/* Package accessible class that has non-accessible private member */ +class Ext { + /** + * Will try to incorrectly access to this field from outside this class. + */ + private static final int DONT_TOUCH_ME = 666; +} --- old/test/hotspot/jtreg/runtime/RedefineTests/RedefineDoubleDelete.java 2018-06-04 03:54:50.853875069 -0400 +++ new/test/hotspot/jtreg/runtime/RedefineTests/RedefineDoubleDelete.java 2018-06-04 03:54:49.337787448 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8178870 + * @bug 8178870 8010319 * @summary Redefine class with CFLH twice to test deleting the cached_class_file * @library /test/lib * @modules java.base/jdk.internal.misc @@ -34,27 +34,30 @@ * @run main/othervm/native -Xlog:redefine+class+load+exceptions -agentlib:RedefineDoubleDelete -javaagent:redefineagent.jar RedefineDoubleDelete */ +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. + +// The ClassFileLoadHook for this class turns foo into faa and prints out faa. +class RedefineDoubleDelete_B { + int faa() { System.out.println("foo"); return 1; } +} + public class RedefineDoubleDelete { // Class gets a redefinition error because it adds a data member public static String newB = - "class RedefineDoubleDelete$B {" + + "class RedefineDoubleDelete_B {" + " int count1 = 0;" + "}"; public static String newerB = - "class RedefineDoubleDelete$B { " + + "class RedefineDoubleDelete_B { " + " int faa() { System.out.println(\"baa\"); return 2; }" + "}"; - // The ClassFileLoadHook for this class turns foo into faa and prints out faa. - static class B { - int faa() { System.out.println("foo"); return 1; } - } - public static void main(String args[]) throws Exception { - B b = new B(); + RedefineDoubleDelete_B b = new RedefineDoubleDelete_B(); int val = b.faa(); if (val != 1) { throw new RuntimeException("return value wrong " + val); @@ -62,12 +65,12 @@ // Redefine B twice to get cached_class_file in both B scratch classes try { - RedefineClassHelper.redefineClass(B.class, newB); + RedefineClassHelper.redefineClass(RedefineDoubleDelete_B.class, newB); } catch (java.lang.UnsupportedOperationException e) { // this is expected } try { - RedefineClassHelper.redefineClass(B.class, newB); + RedefineClassHelper.redefineClass(RedefineDoubleDelete_B.class, newB); } catch (java.lang.UnsupportedOperationException e) { // this is expected } @@ -76,7 +79,7 @@ System.gc(); // Redefine with a compatible class - RedefineClassHelper.redefineClass(B.class, newerB); + RedefineClassHelper.redefineClass(RedefineDoubleDelete_B.class, newerB); val = b.faa(); if (val != 2) { throw new RuntimeException("return value wrong " + val); --- old/test/hotspot/jtreg/runtime/RedefineTests/RedefineFinalizer.java 2018-06-04 03:54:57.670269022 -0400 +++ new/test/hotspot/jtreg/runtime/RedefineTests/RedefineFinalizer.java 2018-06-04 03:54:56.154181400 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 6904403 + * @bug 6904403 8010319 * @summary Don't assert if we redefine finalize method * @library /test/lib * @modules java.base/jdk.internal.misc @@ -41,27 +41,31 @@ * * when redefining finalizer method */ + + +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. +class RedefineFinalizer_B { + protected void finalize() { + // should be empty + } +} + public class RedefineFinalizer { public static String newB = - "class RedefineFinalizer$B {" + + "class RedefineFinalizer_B {" + " protected void finalize() { " + " System.out.println(\"Finalizer called\");" + " }" + "}"; public static void main(String[] args) throws Exception { - RedefineClassHelper.redefineClass(B.class, newB); + RedefineClassHelper.redefineClass(RedefineFinalizer_B.class, newB); A a = new A(); } - static class A extends B { - } - - static class B { - protected void finalize() { - // should be empty - } + static class A extends RedefineFinalizer_B { } } --- old/test/hotspot/jtreg/runtime/RedefineTests/RedefineInterfaceCall.java 2018-06-04 03:55:04.862684705 -0400 +++ new/test/hotspot/jtreg/runtime/RedefineTests/RedefineInterfaceCall.java 2018-06-04 03:55:03.294594077 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8174962 + * @bug 8174962 8010319 * @summary Redefine class with interface method call * @library /test/lib * @modules java.base/jdk.internal.misc @@ -39,19 +39,21 @@ interface I1 { default int m() { return 0; } } interface I2 extends I1 {} -public class RedefineInterfaceCall { - - public static class C implements I2 { - public int test(I2 i) { - return i.m(); // invokeinterface cpCacheEntry - } +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. +class RedefineInterfaceCall_C implements I2 { + public int test(I2 i) { + return i.m(); // invokeinterface cpCacheEntry } +} + +public class RedefineInterfaceCall { static String newI1 = "interface I1 { default int m() { return 1; } }"; static String newC = - "public class RedefineInterfaceCall$C implements I2 { " + + "class RedefineInterfaceCall_C implements I2 { " + " public int test(I2 i) { " + " return i.m(); " + " } " + @@ -62,12 +64,12 @@ } public static void main(String[] args) throws Exception { - C c = new C(); + RedefineInterfaceCall_C c = new RedefineInterfaceCall_C(); assertEquals(test(c), 0); assertEquals(c.test(c), 0); - RedefineClassHelper.redefineClass(C.class, newC); + RedefineClassHelper.redefineClass(RedefineInterfaceCall_C.class, newC); assertEquals(c.test(c), 0); @@ -76,7 +78,7 @@ assertEquals(test(c), 1); assertEquals(c.test(c), 1); - RedefineClassHelper.redefineClass(C.class, newC); + RedefineClassHelper.redefineClass(RedefineInterfaceCall_C.class, newC); assertEquals(c.test(c), 1); } --- old/test/hotspot/jtreg/runtime/RedefineTests/RedefineInterfaceMethods.java 2018-06-04 03:55:11.671078193 -0400 +++ new/test/hotspot/jtreg/runtime/RedefineTests/RedefineInterfaceMethods.java 2018-06-04 03:55:10.146990108 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8081800 + * @bug 8081800 8010319 * @summary Redefine private and default interface methods * @library /test/lib * @modules java.base/jdk.internal.misc @@ -33,23 +33,27 @@ * @run main RedefineClassHelper * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class*=trace RedefineInterfaceMethods */ -public class RedefineInterfaceMethods { - static final int RET = -2; +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. - static interface B { - int ORIGINAL_RETURN = 1; - int NEW_RETURN = 2; - private int privateMethod() { - return ORIGINAL_RETURN; - } - public default int defaultMethod() { - return privateMethod(); - } +interface RedefineInterfaceMethods_B { + int ORIGINAL_RETURN = 1; + int NEW_RETURN = 2; + private int privateMethod() { + return ORIGINAL_RETURN; } + public default int defaultMethod() { + return privateMethod(); + } +} + +public class RedefineInterfaceMethods { + + static final int RET = -2; public static String redefinedPrivateMethod = - "interface RedefineInterfaceMethods$B {" + + "interface RedefineInterfaceMethods_B {" + " int ORIGINAL_RETURN = 1;" + " int NEW_RETURN = 2;" + " private int privateMethod() {" + @@ -61,7 +65,7 @@ "}"; public static String redefinedDefaultMethod = - "interface RedefineInterfaceMethods$B {" + + "interface RedefineInterfaceMethods_B {" + " int ORIGINAL_RETURN = 1;" + " int NEW_RETURN = 2;" + " private int privateMethod() {" + @@ -72,7 +76,7 @@ " }" + "}"; - static class Impl implements B { + static class Impl implements RedefineInterfaceMethods_B { } @@ -81,20 +85,20 @@ Impl impl = new Impl(); int res = impl.defaultMethod(); - if (res != B.ORIGINAL_RETURN) + if (res != RedefineInterfaceMethods_B.ORIGINAL_RETURN) throw new Error("defaultMethod returned " + res + - " expected " + B.ORIGINAL_RETURN); + " expected " + RedefineInterfaceMethods_B.ORIGINAL_RETURN); - RedefineClassHelper.redefineClass(B.class, redefinedPrivateMethod); + RedefineClassHelper.redefineClass(RedefineInterfaceMethods_B.class, redefinedPrivateMethod); res = impl.defaultMethod(); - if (res != B.NEW_RETURN) + if (res != RedefineInterfaceMethods_B.NEW_RETURN) throw new Error("defaultMethod returned " + res + - " expected " + B.NEW_RETURN); + " expected " + RedefineInterfaceMethods_B.NEW_RETURN); System.gc(); - RedefineClassHelper.redefineClass(B.class, redefinedDefaultMethod); + RedefineClassHelper.redefineClass(RedefineInterfaceMethods_B.class, redefinedDefaultMethod); res = impl.defaultMethod(); if (res != RET) --- old/test/hotspot/jtreg/runtime/RedefineTests/RedefinePreviousVersions.java 2018-06-04 03:55:18.475471449 -0400 +++ new/test/hotspot/jtreg/runtime/RedefineTests/RedefinePreviousVersions.java 2018-06-04 03:55:16.955383597 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8165246 + * @bug 8165246 8010319 * @summary Test has_previous_versions flag and processing during class unloading. * @library /test/lib * @modules java.base/jdk.internal.misc @@ -37,38 +37,43 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; +// package access top-level classes to avoid problem with RedefineClassHelper +// and nested types. + +class RedefinePreviousVersions_B { } + +class RedefinePreviousVersions_Running { + public static volatile boolean stop = false; + public static volatile boolean running = false; + static void localSleep() { + try { + Thread.sleep(10); // sleep for 10 ms + } catch(InterruptedException ie) { + } + } + + public static void infinite() { + running = true; + while (!stop) { localSleep(); } + } +} + + + public class RedefinePreviousVersions { public static String newB = - "class RedefinePreviousVersions$B {" + + "class RedefinePreviousVersions_B {" + "}"; - static class B { } - public static String newRunning = - "class RedefinePreviousVersions$Running {" + + "class RedefinePreviousVersions_Running {" + " public static volatile boolean stop = true;" + " public static volatile boolean running = true;" + " static void localSleep() { }" + " public static void infinite() { }" + "}"; - static class Running { - public static volatile boolean stop = false; - public static volatile boolean running = false; - static void localSleep() { - try{ - Thread.sleep(10); // sleep for 10 ms - } catch(InterruptedException ie) { - } - } - - public static void infinite() { - running = true; - while (!stop) { localSleep(); } - } - } - public static void main(String[] args) throws Exception { if (args.length > 0) { @@ -87,7 +92,7 @@ // Redefine a class and create some garbage // Since there are no methods running, the previous version is never added to the // previous_version_list and the flag _has_previous_versions should stay false - RedefineClassHelper.redefineClass(B.class, newB); + RedefineClassHelper.redefineClass(RedefinePreviousVersions_B.class, newB); for (int i = 0; i < 10 ; i++) { String s = new String("some garbage"); @@ -97,17 +102,17 @@ // Start a class that has a method running new Thread() { public void run() { - Running.infinite(); + RedefinePreviousVersions_Running.infinite(); } }.start(); - while (!Running.running) { + while (!RedefinePreviousVersions_Running.running) { Thread.sleep(10); // sleep for 10 ms } // Since a method of newRunning is running, this class should be added to the previous_version_list // of Running, and _has_previous_versions should return true at class unloading. - RedefineClassHelper.redefineClass(Running.class, newRunning); + RedefineClassHelper.redefineClass(RedefinePreviousVersions_Running.class, newRunning); for (int i = 0; i < 10 ; i++) { String s = new String("some garbage"); @@ -115,7 +120,7 @@ } // purge should clean everything up, except Xcomp it might not. - Running.stop = true; + RedefinePreviousVersions_Running.stop = true; for (int i = 0; i < 10 ; i++) { String s = new String("some garbage"); --- old/test/hotspot/jtreg/runtime/RedefineTests/RedefineRunningMethods.java 2018-06-04 03:55:25.271864243 -0400 +++ new/test/hotspot/jtreg/runtime/RedefineTests/RedefineRunningMethods.java 2018-06-04 03:55:23.755776622 -0400 @@ -23,7 +23,7 @@ /* * @test - * @bug 8055008 8197901 + * @bug 8055008 8197901 8010319 * @summary Redefine EMCP and non-EMCP methods that are running in an infinite loop * @library /test/lib * @modules java.base/jdk.internal.misc @@ -34,10 +34,33 @@ * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace,all=trace:file=all.log RedefineRunningMethods */ // Test is executed with full trace logging redirected to a file to ensure there is no crash during logging anonymous classes - see JDK-8197901 + + +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. +class RedefineRunningMethods_B { + static int count1 = 0; + static int count2 = 0; + public static volatile boolean stop = false; + static void localSleep() { + try{ + Thread.currentThread().sleep(10);//sleep for 10 ms + } catch(InterruptedException ie) { + } + } + + public static void infinite() { + while (!stop) { count1++; localSleep(); } + } + public static void infinite_emcp() { + while (!stop) { count2++; localSleep(); } + } +} + public class RedefineRunningMethods { public static String newB = - "class RedefineRunningMethods$B {" + + "class RedefineRunningMethods_B {" + " static int count1 = 0;" + " static int count2 = 0;" + " public static volatile boolean stop = false;" + @@ -56,7 +79,7 @@ "}"; public static String evenNewerB = - "class RedefineRunningMethods$B {" + + "class RedefineRunningMethods_B {" + " static int count1 = 0;" + " static int count2 = 0;" + " public static volatile boolean stop = false;" + @@ -72,50 +95,31 @@ " }" + "}"; - static class B { - static int count1 = 0; - static int count2 = 0; - public static volatile boolean stop = false; - static void localSleep() { - try{ - Thread.currentThread().sleep(10);//sleep for 10 ms - } catch(InterruptedException ie) { - } - } - - public static void infinite() { - while (!stop) { count1++; localSleep(); } - } - public static void infinite_emcp() { - while (!stop) { count2++; localSleep(); } - } - } - public static void main(String[] args) throws Exception { new Thread() { public void run() { - B.infinite(); + RedefineRunningMethods_B.infinite(); } }.start(); new Thread() { public void run() { - B.infinite_emcp(); + RedefineRunningMethods_B.infinite_emcp(); } }.start(); - RedefineClassHelper.redefineClass(B.class, newB); + RedefineClassHelper.redefineClass(RedefineRunningMethods_B.class, newB); System.gc(); - B.infinite(); + RedefineRunningMethods_B.infinite(); // Start a thread with the second version of infinite_emcp running new Thread() { public void run() { - B.infinite_emcp(); + RedefineRunningMethods_B.infinite_emcp(); } }.start(); @@ -124,22 +128,22 @@ System.gc(); } - RedefineClassHelper.redefineClass(B.class, evenNewerB); + RedefineClassHelper.redefineClass(RedefineRunningMethods_B.class, evenNewerB); System.gc(); for (int i = 0; i < 20 ; i++) { - B.infinite(); + RedefineRunningMethods_B.infinite(); String s = new String("some garbage"); System.gc(); } - B.infinite_emcp(); + RedefineRunningMethods_B.infinite_emcp(); // purge should clean everything up. - B.stop = true; + RedefineRunningMethods_B.stop = true; for (int i = 0; i < 20 ; i++) { - B.infinite(); + RedefineRunningMethods_B.infinite(); String s = new String("some garbage"); System.gc(); } --- old/test/hotspot/jtreg/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java 2018-06-04 03:55:33.368332174 -0400 +++ new/test/hotspot/jtreg/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java 2018-06-04 03:55:31.844244090 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8087315 + * @bug 8087315 8010319 * @summary Get old method's stack trace elements after GC * @library /test/lib * @modules java.base/jdk.internal.misc @@ -36,16 +36,58 @@ import static jdk.test.lib.Asserts.*; +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. + +class RedefineRunningMethodsWithBacktrace_B { + static int count1 = 0; + static int count2 = 0; + public static volatile boolean stop = false; + static void localSleep() { + try { + Thread.sleep(10);//sleep for 10 ms + } catch(InterruptedException ie) { + } + } + + public static void infinite() { + while (!stop) { count1++; localSleep(); } + } + public static void throwable() { + // add some stuff to the original constant pool + String s1 = new String ("string1"); + String s2 = new String ("string2"); + String s3 = new String ("string3"); + String s4 = new String ("string4"); + String s5 = new String ("string5"); + String s6 = new String ("string6"); + String s7 = new String ("string7"); + String s8 = new String ("string8"); + String s9 = new String ("string9"); + String s10 = new String ("string10"); + String s11 = new String ("string11"); + String s12 = new String ("string12"); + String s13 = new String ("string13"); + String s14 = new String ("string14"); + String s15 = new String ("string15"); + String s16 = new String ("string16"); + String s17 = new String ("string17"); + String s18 = new String ("string18"); + String s19 = new String ("string19"); + throw new RuntimeException("throwable called"); + } +} + public class RedefineRunningMethodsWithBacktrace { public static String newB = - "class RedefineRunningMethodsWithBacktrace$B {" + + "class RedefineRunningMethodsWithBacktrace_B {" + " static int count1 = 0;" + " static int count2 = 0;" + " public static volatile boolean stop = false;" + " static void localSleep() { " + " try{ " + - " Thread.currentThread().sleep(10);" + + " Thread.sleep(10);" + " } catch(InterruptedException ie) { " + " } " + " } " + @@ -58,13 +100,13 @@ "}"; public static String evenNewerB = - "class RedefineRunningMethodsWithBacktrace$B {" + + "class RedefineRunningMethodsWithBacktrace_B {" + " static int count1 = 0;" + " static int count2 = 0;" + " public static volatile boolean stop = false;" + " static void localSleep() { " + " try{ " + - " Thread.currentThread().sleep(1);" + + " Thread.sleep(1);" + " } catch(InterruptedException ie) { " + " } " + " } " + @@ -74,45 +116,6 @@ " }" + "}"; - static class B { - static int count1 = 0; - static int count2 = 0; - public static volatile boolean stop = false; - static void localSleep() { - try { - Thread.currentThread().sleep(10);//sleep for 10 ms - } catch(InterruptedException ie) { - } - } - - public static void infinite() { - while (!stop) { count1++; localSleep(); } - } - public static void throwable() { - // add some stuff to the original constant pool - String s1 = new String ("string1"); - String s2 = new String ("string2"); - String s3 = new String ("string3"); - String s4 = new String ("string4"); - String s5 = new String ("string5"); - String s6 = new String ("string6"); - String s7 = new String ("string7"); - String s8 = new String ("string8"); - String s9 = new String ("string9"); - String s10 = new String ("string10"); - String s11 = new String ("string11"); - String s12 = new String ("string12"); - String s13 = new String ("string13"); - String s14 = new String ("string14"); - String s15 = new String ("string15"); - String s16 = new String ("string16"); - String s17 = new String ("string17"); - String s18 = new String ("string18"); - String s19 = new String ("string19"); - throw new RuntimeException("throwable called"); - } - } - private static void touchRedefinedMethodInBacktrace(Throwable throwable) { System.out.println("touchRedefinedMethodInBacktrace: "); throwable.printStackTrace(); // this actually crashes with the bug in @@ -133,7 +136,7 @@ private static Throwable getThrowableInB() { Throwable t = null; try { - B.throwable(); + RedefineRunningMethodsWithBacktrace_B.throwable(); } catch (Exception e) { t = e; // Don't print here because Throwable will cache the constructed stacktrace @@ -147,32 +150,32 @@ new Thread() { public void run() { - B.infinite(); + RedefineRunningMethodsWithBacktrace_B.infinite(); } }.start(); Throwable t1 = getThrowableInB(); - RedefineClassHelper.redefineClass(B.class, newB); + RedefineClassHelper.redefineClass(RedefineRunningMethodsWithBacktrace_B.class, newB); System.gc(); Throwable t2 = getThrowableInB(); - B.infinite(); + RedefineRunningMethodsWithBacktrace_B.infinite(); for (int i = 0; i < 20 ; i++) { String s = new String("some garbage"); System.gc(); } - RedefineClassHelper.redefineClass(B.class, evenNewerB); + RedefineClassHelper.redefineClass(RedefineRunningMethodsWithBacktrace_B.class, evenNewerB); System.gc(); Throwable t3 = getThrowableInB(); for (int i = 0; i < 20 ; i++) { - B.infinite(); + RedefineRunningMethodsWithBacktrace_B.infinite(); String s = new String("some garbage"); System.gc(); } @@ -182,10 +185,10 @@ touchRedefinedMethodInBacktrace(t3); // purge should clean everything up. - B.stop = true; + RedefineRunningMethodsWithBacktrace_B.stop = true; for (int i = 0; i < 20 ; i++) { - B.infinite(); + RedefineRunningMethodsWithBacktrace_B.infinite(); String s = new String("some garbage"); System.gc(); } --- old/test/hotspot/jtreg/runtime/appcds/redefineClass/RedefineBasic.java 2018-06-04 03:55:40.156724505 -0400 +++ new/test/hotspot/jtreg/runtime/appcds/redefineClass/RedefineBasic.java 2018-06-04 03:55:38.644637115 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -24,10 +24,21 @@ import sun.hotspot.WhiteBox; +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. +class RedefineBasic_B { + public static void okToCallBeforeRedefine() { + System.out.println("okToCallBeforeRedefine"); + } + public static void okToCallAfterRedefine() { + throw new RuntimeException("okToCallAfterRedefine is called before redefinition, test failed"); + } +} + public class RedefineBasic { public static String newB = - " class RedefineBasic$B { " + + " class RedefineBasic_B { " + " public static void okToCallBeforeRedefine() { " + " throw new RuntimeException(\"newB: okToCallBeforeRedefine is " + " called after redefinition, test failed\"); }" + @@ -36,23 +47,14 @@ " } "; - static class B { - public static void okToCallBeforeRedefine() { - System.out.println("okToCallBeforeRedefine"); - } - public static void okToCallAfterRedefine() { - throw new RuntimeException( - "okToCallAfterRedefine is called before redefinition, test failed"); - } - } - static class SubclassOfB extends B { + static class SubclassOfB extends RedefineBasic_B { public static void testAfterRedefine() { - B.okToCallAfterRedefine(); + RedefineBasic_B.okToCallAfterRedefine(); } } - class Subclass2OfB extends B { + class Subclass2OfB extends RedefineBasic_B { public void testAfterRedefine() { super.okToCallAfterRedefine(); } @@ -74,17 +76,17 @@ WhiteBox wb = WhiteBox.getWhiteBox(); verifyClassIsShared(wb, RedefineBasic.class); - verifyClassIsShared(wb, B.class); + verifyClassIsShared(wb, RedefineBasic_B.class); verifyClassIsShared(wb, SubclassOfB.class); verifyClassIsShared(wb, Subclass2OfB.class); // (1) Test case: verify that original B works as expected // and that redefined B is shared and works as expected, // with new behavior - B.okToCallBeforeRedefine(); - RedefineClassHelper.redefineClass(B.class, newB); - verifyClassIsShared(wb, B.class); - B.okToCallAfterRedefine(); + RedefineBasic_B.okToCallBeforeRedefine(); + RedefineClassHelper.redefineClass(RedefineBasic_B.class, newB); + verifyClassIsShared(wb, RedefineBasic_B.class); + RedefineBasic_B.okToCallAfterRedefine(); // Static subclass of the super: // 1. Make sure it is still shared --- old/test/hotspot/jtreg/runtime/appcds/redefineClass/RedefineBasicTest.java 2018-06-04 03:55:46.965117990 -0400 +++ new/test/hotspot/jtreg/runtime/appcds/redefineClass/RedefineBasicTest.java 2018-06-04 03:55:45.437029676 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -43,7 +43,7 @@ public class RedefineBasicTest { public static String sharedClasses[] = { "RedefineBasic", - "RedefineBasic$B", + "RedefineBasic_B", "RedefineBasic$SubclassOfB", "RedefineBasic$Subclass2OfB", "RedefineClassHelper", --- old/test/hotspot/jtreg/runtime/appcds/redefineClass/RedefineRunningMethods_Shared.java 2018-06-04 03:55:53.801513096 -0400 +++ new/test/hotspot/jtreg/runtime/appcds/redefineClass/RedefineRunningMethods_Shared.java 2018-06-04 03:55:52.273424781 -0400 @@ -1,5 +1,5 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + /* + * Copyright (c) 2016, 2018, 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 @@ -47,7 +47,7 @@ "RedefineRunningMethods$1", "RedefineRunningMethods$2", "RedefineRunningMethods$3", - "RedefineRunningMethods$B", + "RedefineRunningMethods_B", "RedefineClassHelper", "jdk/test/lib/compiler/InMemoryJavaCompiler", "jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper", --- old/test/hotspot/jtreg/testlibrary_tests/RedefineClassTest.java 2018-06-04 03:55:59.361834449 -0400 +++ new/test/hotspot/jtreg/testlibrary_tests/RedefineClassTest.java 2018-06-04 03:55:57.833746135 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, 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 @@ -38,19 +38,22 @@ /* * Proof of concept test for the test utility class RedefineClassHelper */ + +// package access top-level class to avoid problem with RedefineClassHelper +// and nested types. +class RedefineClassTest_A { + public int Method() { + return 1; + } +} + public class RedefineClassTest { - public static String newClass = "class RedefineClassTest$A { public int Method() { return 2; } }"; + public static String newClass = "class RedefineClassTest_A { public int Method() { return 2; } }"; public static void main(String[] args) throws Exception { - A a = new A(); + RedefineClassTest_A a = new RedefineClassTest_A(); assertTrue(a.Method() == 1); - RedefineClassHelper.redefineClass(A.class, newClass); + RedefineClassHelper.redefineClass(RedefineClassTest_A.class, newClass); assertTrue(a.Method() == 2); } - - static class A { - public int Method() { - return 1; - } - } }