< prev index next >

test/hotspot/jtreg/runtime/appcds/redefineClass/RedefineBasic.java

Print this page
rev 50608 : imported patch jep181-rev5

@@ -1,7 +1,7 @@
 /*
- * 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -22,39 +22,41 @@
  *
  */
 
 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\"); }" +
         " public static void okToCallAfterRedefine() { " +
         "     System.out.println(\"newB: okToCallAfterRedefine\"); } " +
         " } ";
 
 
-    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();
         }
     }
 

@@ -72,21 +74,21 @@
 
     public static void main(String[] args) throws Exception {
         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
         // 2. and it calls the correct super (the redefined one)
         verifyClassIsShared(wb, SubclassOfB.class);
< prev index next >