< prev index next >

test/runtime/getSysPackage/GetSysPkgTest.java

Print this page




  81 
  82             // Create a package found via -Xbootclasspath/a
  83             String source = "package BootLdr_package; " +
  84                             "public class BootLdrPkg { " +
  85                             "    public int mth() { return 4; } " +
  86                             "}";
  87             byte[] klassbuf =
  88                 InMemoryJavaCompiler.compile("BootLdr_package.BootLdrPkg", source);
  89             ClassFileInstaller.writeClassToDisk("BootLdr_package/BootLdrPkg", klassbuf, "bl_dir");
  90 
  91             // Create a package found via -cp.
  92             source = "package GetSysPkg_package; " +
  93                      "public class GetSysClass { " +
  94                      "    public int mth() { return 4; } " +
  95                      "}";
  96             klassbuf =
  97                 InMemoryJavaCompiler.compile("GetSysPkg_package.GetSysClass", source);
  98             ClassFileInstaller.writeClassToDisk("GetSysPkg_package/GetSysClass", klassbuf);
  99 
 100             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:bl_dir",
 101                 "-XaddExports:java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator +
 102                 System.getProperty("test.classes"), "GetSysPkgTest", "do_tests");
 103             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 104             output.shouldHaveExitValue(0);
 105             return;
 106         }
 107 
 108         getPkg("java/lang", "jrt:/java.base");
 109         getPkg("javax/script", null);          // Package not defined
 110 
 111         // Test a package that does not yet have any referenced classes.
 112         // Note: if another class in com/sun/crypto/provider/ happens to get
 113         //       loaded or if class PrivateKeyInfo disappears from this package
 114         //       then this test will fail.
 115         getPkg("com/sun/crypto/provider", null);
 116         // Now make sure a class in the package is referenced.
 117         Class newClass = Class.forName("com.sun.crypto.provider.PrivateKeyInfo");
 118         getPkg("com/sun/crypto/provider", "jrt:/java.base");
 119 
 120         getPkg("java/nio/charset", "jrt:/java.base");
 121 




  81 
  82             // Create a package found via -Xbootclasspath/a
  83             String source = "package BootLdr_package; " +
  84                             "public class BootLdrPkg { " +
  85                             "    public int mth() { return 4; } " +
  86                             "}";
  87             byte[] klassbuf =
  88                 InMemoryJavaCompiler.compile("BootLdr_package.BootLdrPkg", source);
  89             ClassFileInstaller.writeClassToDisk("BootLdr_package/BootLdrPkg", klassbuf, "bl_dir");
  90 
  91             // Create a package found via -cp.
  92             source = "package GetSysPkg_package; " +
  93                      "public class GetSysClass { " +
  94                      "    public int mth() { return 4; } " +
  95                      "}";
  96             klassbuf =
  97                 InMemoryJavaCompiler.compile("GetSysPkg_package.GetSysClass", source);
  98             ClassFileInstaller.writeClassToDisk("GetSysPkg_package/GetSysClass", klassbuf);
  99 
 100             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:bl_dir",
 101                 "--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator +
 102                 System.getProperty("test.classes"), "GetSysPkgTest", "do_tests");
 103             OutputAnalyzer output = new OutputAnalyzer(pb.start());
 104             output.shouldHaveExitValue(0);
 105             return;
 106         }
 107 
 108         getPkg("java/lang", "jrt:/java.base");
 109         getPkg("javax/script", null);          // Package not defined
 110 
 111         // Test a package that does not yet have any referenced classes.
 112         // Note: if another class in com/sun/crypto/provider/ happens to get
 113         //       loaded or if class PrivateKeyInfo disappears from this package
 114         //       then this test will fail.
 115         getPkg("com/sun/crypto/provider", null);
 116         // Now make sure a class in the package is referenced.
 117         Class newClass = Class.forName("com.sun.crypto.provider.PrivateKeyInfo");
 118         getPkg("com/sun/crypto/provider", "jrt:/java.base");
 119 
 120         getPkg("java/nio/charset", "jrt:/java.base");
 121 


< prev index next >