< prev index next >
test/jdk/jdk/internal/loader/URLClassPath/JarClassPathFileEntry.java
Print this page
@@ -31,12 +31,12 @@
import jdk.test.lib.util.JarUtils;
import jdk.test.lib.compiler.InMemoryJavaCompiler;
/*
* @test
- * @bug 8216401
- * @summary Test loading of JAR Class-Path entry with file: scheme
+ * @bug 8216401 8235361
+ * @summary Test classloading via JAR Class-Path entries
* @library /test/lib
*
* @run main/othervm JarClassPathFileEntry
* @run main/othervm -Djdk.net.URLClassPath.disableClassPathURLCheck=true JarClassPathFileEntry
* @run main/othervm -Djdk.net.URLClassPath.disableClassPathURLCheck=false JarClassPathFileEntry
@@ -50,10 +50,23 @@
private final static Path OTHER_JAR_PATH = Paths.get(OTHER_DIR, "Other.jar");
private final static Path CONTEXT_JAR_PATH = Paths.get(TEST_CLASSES, "Context.jar");
public static void main(String[] args) throws Throwable {
+ String fileScheme = "file:" + (IS_WINDOWS ? toUnixPath(OTHER_JAR_PATH.toString())
+ : OTHER_JAR_PATH.toString());
+ doTest(fileScheme);
+
+ if (IS_WINDOWS) {
+ // Relative URL encoding of absolute path, e.g. /C:\\path\\to\\file.jar
+ String driveLetter = "/" + OTHER_JAR_PATH;
+ doTest(driveLetter);
+ }
+ }
+
+ /* Load a class from Other.jar via the given Class-Path entry */
+ private static void doTest(String classPathEntry) throws Throwable {
// Create Other.class in OTHER_DIR, off the default classpath
byte klassbuf[] = InMemoryJavaCompiler.compile("Other",
"public class Other {}");
ClassFileInstaller.writeClassToDisk("Other", klassbuf, OTHER_DIR);
@@ -70,12 +83,10 @@
// Create Context.jar w/ "file:" entry for Other.jar
Manifest mf = new Manifest();
Attributes attrs = mf.getMainAttributes();
attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
- String classPathEntry = "file:" + (IS_WINDOWS ? toUnixPath(OTHER_JAR_PATH.toString())
- : OTHER_JAR_PATH.toString());
attrs.put(Attributes.Name.CLASS_PATH, classPathEntry);
System.out.println("Creating Context.jar with Class-Path: " + classPathEntry);
JarUtils.createJarFile(CONTEXT_JAR_PATH, mf,
Paths.get(TEST_CLASSES),
< prev index next >