< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/ClassPathAttr.java

Print this page


  99   }
 100 
 101   static void testNonExistentJars() throws Exception {
 102     buildCpAttr("cpattr6", "cpattr6.mf", "CpAttr6", "CpAttr6");
 103 
 104     String cp = TestCommon.getTestJar("cpattr6.jar");
 105     String nonExistPath = System.getProperty("test.classes") + File.separator + "cpattrX.jar";
 106     (new File(nonExistPath)).delete();
 107 
 108     TestCommon.testDump(cp, TestCommon.list("CpAttr6"),
 109         "-Xlog:class+path");
 110 
 111     TestCommon.run(
 112         "-Xlog:class+path",
 113         "-cp", cp,
 114         "CpAttr6")
 115       .assertNormalExit(output -> {
 116           output.shouldMatch("should be non-existent: .*cpattrX.jar");
 117         });
 118 
 119     // Now make nonExistPath exist. CDS will fail to load.
 120     Files.copy(Paths.get(cp), Paths.get(nonExistPath),
 121                StandardCopyOption.REPLACE_EXISTING);
 122 
 123     TestCommon.run(
 124         "-Xlog:class+path",
 125         "-cp", cp,
 126         "CpAttr6")
 127       .assertAbnormalExit(output -> {
 128           output.shouldMatch("should be non-existent: .*cpattrX.jar");
 129           output.shouldMatch("file must not exist: .*cpattrX.jar");
 130         });
 131   }
 132 
 133   private static void buildCpAttr(String jarName, String manifest, String enclosingClassName, String ...testClassNames) throws Exception {
 134     String jarClassesDir = System.getProperty("test.classes") + File.separator + jarName + "_classes";
 135     try { Files.createDirectory(Paths.get(jarClassesDir)); } catch (FileAlreadyExistsException e) { }
 136 
 137     JarBuilder.compile(jarClassesDir, System.getProperty("test.src") + File.separator +
 138         "test-classes" + File.separator + enclosingClassName + ".java");
 139     JarBuilder.buildWithManifest(jarName, manifest, jarClassesDir, testClassNames);
 140   }
 141 }


  99   }
 100 
 101   static void testNonExistentJars() throws Exception {
 102     buildCpAttr("cpattr6", "cpattr6.mf", "CpAttr6", "CpAttr6");
 103 
 104     String cp = TestCommon.getTestJar("cpattr6.jar");
 105     String nonExistPath = System.getProperty("test.classes") + File.separator + "cpattrX.jar";
 106     (new File(nonExistPath)).delete();
 107 
 108     TestCommon.testDump(cp, TestCommon.list("CpAttr6"),
 109         "-Xlog:class+path");
 110 
 111     TestCommon.run(
 112         "-Xlog:class+path",
 113         "-cp", cp,
 114         "CpAttr6")
 115       .assertNormalExit(output -> {
 116           output.shouldMatch("should be non-existent: .*cpattrX.jar");
 117         });
 118 
 119     // Now make nonExistPath exist. CDS still loads, but archived non-system classes will not be used.
 120     Files.copy(Paths.get(cp), Paths.get(nonExistPath),
 121                StandardCopyOption.REPLACE_EXISTING);
 122 
 123     TestCommon.run(
 124         "-Xlog:class+path",
 125         "-cp", cp,
 126         "CpAttr6")
 127       .assertNormalExit(output -> {
 128           output.shouldMatch("Archived non-system classes are disabled because the file .*/cpattrX.jar exists");

 129         });
 130   }
 131 
 132   private static void buildCpAttr(String jarName, String manifest, String enclosingClassName, String ...testClassNames) throws Exception {
 133     String jarClassesDir = System.getProperty("test.classes") + File.separator + jarName + "_classes";
 134     try { Files.createDirectory(Paths.get(jarClassesDir)); } catch (FileAlreadyExistsException e) { }
 135 
 136     JarBuilder.compile(jarClassesDir, System.getProperty("test.src") + File.separator +
 137         "test-classes" + File.separator + enclosingClassName + ".java");
 138     JarBuilder.buildWithManifest(jarName, manifest, jarClassesDir, testClassNames);
 139   }
 140 }
< prev index next >