test/hotspot/jtreg/runtime/appcds/javaldr/CheckAnonymousClass.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/hotspot/jtreg/runtime/appcds/javaldr

test/hotspot/jtreg/runtime/appcds/javaldr/CheckAnonymousClass.java

Print this page




  24 
  25 /*
  26  * @test
  27  * @summary ensure no anonymous class is being dumped into the CDS archive
  28  * @requires vm.cds
  29  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  30  * @modules jdk.jartool/sun.tools.jar
  31  * @compile ../test-classes/Hello.java
  32  * @run main CheckAnonymousClass
  33  */
  34 
  35 import jdk.test.lib.process.OutputAnalyzer;
  36 
  37 public class CheckAnonymousClass {
  38 
  39   public static void main(String[] args) throws Exception {
  40     JarBuilder.build("hello", "Hello");
  41 
  42     String appJar = TestCommon.getTestJar("hello.jar");
  43 
  44     TestCommon.dump(appJar, TestCommon.list("Hello", "org/omg/CORBA/ORB"),
  45         "--add-modules", "java.corba", "-Xlog:class+load=info");


  46 
  47     String prefix = ".class.load. ";
  48     // class name pattern like the following:
  49     // jdk.internal.loader.BuiltinClassLoader$$Lambda$1/1816757085
  50     // java.lang.invoke.LambdaForm$MH/1585787493
  51     String class_pattern = ".*Lambda([a-z0-9$]+)/([0-9]+).*";
  52     String suffix = ".*source: shared objects file.*";
  53     String pattern = prefix + class_pattern + suffix;
  54     // during run time, anonymous classes shouldn't be loaded from the archive
  55     TestCommon.run("-XX:+UnlockDiagnosticVMOptions",
  56         "-cp", appJar, "-Xlog:class+load=info", "--add-modules", "java.corba", "Hello")
  57       .assertNormalExit(output -> output.shouldNotMatch(pattern));
  58 
  59     // inspect the archive and make sure no anonymous class is in there
  60     TestCommon.run("-XX:+UnlockDiagnosticVMOptions",
  61         "-cp", appJar, "-Xlog:class+load=info", "-XX:+PrintSharedArchiveAndExit",
  62         "-XX:+PrintSharedDictionary", "--add-modules", "java.corba", "Hello")
  63       .assertNormalExit(output -> output.shouldNotMatch(class_pattern));
  64   }
  65 }


  24 
  25 /*
  26  * @test
  27  * @summary ensure no anonymous class is being dumped into the CDS archive
  28  * @requires vm.cds
  29  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  30  * @modules jdk.jartool/sun.tools.jar
  31  * @compile ../test-classes/Hello.java
  32  * @run main CheckAnonymousClass
  33  */
  34 
  35 import jdk.test.lib.process.OutputAnalyzer;
  36 
  37 public class CheckAnonymousClass {
  38 
  39   public static void main(String[] args) throws Exception {
  40     JarBuilder.build("hello", "Hello");
  41 
  42     String appJar = TestCommon.getTestJar("hello.jar");
  43 
  44     TestCommon.dump(appJar,
  45         TestCommon.list("Hello",
  46             "javax/annotation/processing/FilerException"), // from java.compiler module
  47         "-Xlog:class+load=info");
  48 
  49     String prefix = ".class.load. ";
  50     // class name pattern like the following:
  51     // jdk.internal.loader.BuiltinClassLoader$$Lambda$1/1816757085
  52     // java.lang.invoke.LambdaForm$MH/1585787493
  53     String class_pattern = ".*Lambda([a-z0-9$]+)/([0-9]+).*";
  54     String suffix = ".*source: shared objects file.*";
  55     String pattern = prefix + class_pattern + suffix;
  56     // during run time, anonymous classes shouldn't be loaded from the archive
  57     TestCommon.run("-XX:+UnlockDiagnosticVMOptions",
  58         "-cp", appJar, "-Xlog:class+load=info", "Hello")
  59       .assertNormalExit(output -> output.shouldNotMatch(pattern));
  60 
  61     // inspect the archive and make sure no anonymous class is in there
  62     TestCommon.run("-XX:+UnlockDiagnosticVMOptions",
  63         "-cp", appJar, "-Xlog:class+load=info", "-XX:+PrintSharedArchiveAndExit",
  64         "-XX:+PrintSharedDictionary", "Hello")
  65       .assertNormalExit(output -> output.shouldNotMatch(class_pattern));
  66   }
  67 }
test/hotspot/jtreg/runtime/appcds/javaldr/CheckAnonymousClass.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File