< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/resolvedConstants/ResolvedConstants.java

Print this page

 49                 output.shouldContain("Hello ResolvedConstantsApp");
 50             });
 51 
 52         CDSOptions opts = (new CDSOptions())
 53             .addPrefix("-XX:ExtraSharedClassListFile=" + classList,
 54                        "-cp", appJar,
 55                        "-Xlog:cds+resolve=trace");
 56         CDSTestUtils.createArchiveAndCheck(opts)
 57           // Class References ---
 58 
 59             // Always resolve reference when a class references itself
 60             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsApp app => ResolvedConstantsApp app")
 61 
 62             // Always resolve reference when a class references a super class
 63             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsApp app => java/lang/Object boot")
 64             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsBar app => ResolvedConstantsFoo app")
 65 
 66             // Always resolve reference when a class references a super interface
 67             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsApp app => java/lang/Runnable boot")
 68 


 69             // java/lang/System is in the root loader but ResolvedConstantsApp is loaded by the app loader.
 70             // Even though System is in the vmClasses list, when ResolvedConstantsApp looks up
 71             // "java/lang/System" in its ConstantPool, the app loader may not have resolved the System
 72             // class yet (i.e., there's no initiaited class entry for System in the app loader's dictionary)
 73             .shouldMatch("cds,resolve.*reverted klass.* ResolvedConstantsApp .*java/lang/System")
 74 
 75           // Field References ---
 76 
 77             // Always resolve references to fields in the current class or super class(es)
 78             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsBar => ResolvedConstantsBar.b:I")
 79             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsBar => ResolvedConstantsBar.a:I")
 80             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsBar => ResolvedConstantsFoo.a:I")
 81 
 82             // Do not resolve field references to child classes
 83             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsFoo => ResolvedConstantsFoo.a:I")
 84             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsFoo    ResolvedConstantsBar.a:I")
 85             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsFoo    ResolvedConstantsBar.b:I")
 86 
 87             // Do not resolve field references to unrelated classes
 88             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsApp    ResolvedConstantsBar.a:I")
 89             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsApp    ResolvedConstantsBar.b:I")
 90 
 91           // Method References ---
 92 
 93             // Should resolve references to own constructor
 94             .shouldMatch("cds,resolve.*archived method .* ResolvedConstantsApp ResolvedConstantsApp.<init>:")
 95             // Should resolve references to super constructor
 96             .shouldMatch("cds,resolve.*archived method .* ResolvedConstantsApp java/lang/Object.<init>:")
 97 
 98             // Should resolve interface methods in VM classes
 99             .shouldMatch("cds,resolve.*archived interface method .* ResolvedConstantsApp java/lang/Runnable.run:")
100 
101             // Should resolve references to own non-static method (private or public)
102             .shouldMatch("archived method.*: ResolvedConstantsBar ResolvedConstantsBar.doBar:")
103             .shouldMatch("archived method.*: ResolvedConstantsApp ResolvedConstantsApp.privateInstanceCall:")
104             .shouldMatch("archived method.*: ResolvedConstantsApp ResolvedConstantsApp.publicInstanceCall:")
105 


106             // Should not resolve references to static method
107             .shouldNotMatch(" archived method CP entry.*: ResolvedConstantsApp ResolvedConstantsApp.staticCall:")

108 
109             // Should resolve references to method in super type
110             .shouldMatch(" archived method CP entry.*: ResolvedConstantsBar ResolvedConstantsFoo.doBar:")
111 
112             // App class cannot resolve references to methods in boot classes:
113             //    When the app class loader tries to resolve a class X that's normally loaded by
114             //    the boot loader, it's possible for the app class loader to get a different copy of
115             //    X (by using MethodHandles.Lookup.defineClass(), etc). Therefore, let's be on
116             //    the side of safety and revert all such references.
117             //
118             //    This will be addressed in JDK-8315737.
119             .shouldMatch("reverted method.*: ResolvedConstantsApp java/io/PrintStream.println:")
120             .shouldMatch("reverted method.*: ResolvedConstantsBar java/lang/Class.getName:")
121 
122             // Should not resolve methods in unrelated classes.
123             .shouldMatch("reverted method.*: ResolvedConstantsApp ResolvedConstantsBar.doit:")
124 
125           // End ---
126             ;
127     }

 49                 output.shouldContain("Hello ResolvedConstantsApp");
 50             });
 51 
 52         CDSOptions opts = (new CDSOptions())
 53             .addPrefix("-XX:ExtraSharedClassListFile=" + classList,
 54                        "-cp", appJar,
 55                        "-Xlog:cds+resolve=trace");
 56         CDSTestUtils.createArchiveAndCheck(opts)
 57           // Class References ---
 58 
 59             // Always resolve reference when a class references itself
 60             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsApp app => ResolvedConstantsApp app")
 61 
 62             // Always resolve reference when a class references a super class
 63             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsApp app => java/lang/Object boot")
 64             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsBar app => ResolvedConstantsFoo app")
 65 
 66             // Always resolve reference when a class references a super interface
 67             .shouldMatch("cds,resolve.*archived klass.* ResolvedConstantsApp app => java/lang/Runnable boot")
 68 
 69 /** Work around JDK-8336414
 70 
 71             // java/lang/System is in the root loader but ResolvedConstantsApp is loaded by the app loader.
 72             // Even though System is in the vmClasses list, when ResolvedConstantsApp looks up
 73             // "java/lang/System" in its ConstantPool, the app loader may not have resolved the System
 74             // class yet (i.e., there's no initiaited class entry for System in the app loader's dictionary)
 75             .shouldMatch("cds,resolve.*reverted klass.* ResolvedConstantsApp .*java/lang/System")
 76 */
 77           // Field References ---
 78 
 79             // Always resolve references to fields in the current class or super class(es)
 80             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsBar => ResolvedConstantsBar.b:I")
 81             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsBar => ResolvedConstantsBar.a:I")
 82             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsBar => ResolvedConstantsFoo.a:I")
 83 
 84             // Do not resolve field references to child classes
 85             .shouldMatch("cds,resolve.*archived field.* ResolvedConstantsFoo => ResolvedConstantsFoo.a:I")
 86             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsFoo    ResolvedConstantsBar.a:I")
 87             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsFoo    ResolvedConstantsBar.b:I")
 88 
 89             // Do not resolve field references to unrelated classes
 90             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsApp    ResolvedConstantsBar.a:I")
 91             .shouldMatch("cds,resolve.*reverted field.* ResolvedConstantsApp    ResolvedConstantsBar.b:I")
 92 
 93           // Method References ---
 94 
 95             // Should resolve references to own constructor
 96             .shouldMatch("cds,resolve.*archived method .* ResolvedConstantsApp ResolvedConstantsApp.<init>:")
 97             // Should resolve references to super constructor
 98             .shouldMatch("cds,resolve.*archived method .* ResolvedConstantsApp java/lang/Object.<init>:")
 99 
100             // Should resolve interface methods in VM classes
101             .shouldMatch("cds,resolve.*archived interface method .* ResolvedConstantsApp java/lang/Runnable.run:")
102 
103             // Should resolve references to own non-static method (private or public)
104             .shouldMatch("archived method.*: ResolvedConstantsBar ResolvedConstantsBar.doBar:")
105             .shouldMatch("archived method.*: ResolvedConstantsApp ResolvedConstantsApp.privateInstanceCall:")
106             .shouldMatch("archived method.*: ResolvedConstantsApp ResolvedConstantsApp.publicInstanceCall:")
107 
108 /** premain allows static method pre-resolution
109 
110             // Should not resolve references to static method
111             .shouldNotMatch(" archived method CP entry.*: ResolvedConstantsApp ResolvedConstantsApp.staticCall:")
112 **/
113 
114             // Should resolve references to method in super type
115             .shouldMatch(" archived method CP entry.*: ResolvedConstantsBar ResolvedConstantsFoo.doBar:")
116 
117             // App class cannot resolve references to methods in boot classes:
118             //    When the app class loader tries to resolve a class X that's normally loaded by
119             //    the boot loader, it's possible for the app class loader to get a different copy of
120             //    X (by using MethodHandles.Lookup.defineClass(), etc). Therefore, let's be on
121             //    the side of safety and revert all such references.
122             //
123             //    This will be addressed in JDK-8315737.
124             .shouldMatch("reverted method.*: ResolvedConstantsApp java/io/PrintStream.println:")
125             .shouldMatch("reverted method.*: ResolvedConstantsBar java/lang/Class.getName:")
126 
127             // Should not resolve methods in unrelated classes.
128             .shouldMatch("reverted method.*: ResolvedConstantsApp ResolvedConstantsBar.doit:")
129 
130           // End ---
131             ;
132     }
< prev index next >