8196121: runtime/appcds/ClassLoaderTest.java fails silently
Reviewed-by: mseledtsov, jiangli, ccheung
This commit is contained in:
parent
cbaf7f2f81
commit
4c0a72bf60
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -62,15 +62,10 @@ public class ClassLoaderTest {
|
|||||||
|
|
||||||
TestCommon.dump(appJar, appClasses, bootClassPath);
|
TestCommon.dump(appJar, appClasses, bootClassPath);
|
||||||
|
|
||||||
OutputAnalyzer runtimeOutput = TestCommon.execCommon(
|
TestCommon.run(
|
||||||
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
||||||
"-cp", appJar, bootClassPath, "-Xlog:class+load", "HelloWB");
|
"-cp", appJar, bootClassPath, "HelloWB")
|
||||||
|
.assertNormalExit(output -> output.shouldContain("HelloWB.class.getClassLoader() = null"));
|
||||||
if (!TestCommon.isUnableToMap(runtimeOutput)) {
|
|
||||||
runtimeOutput.shouldNotContain(
|
|
||||||
"[class,load] HelloWB source: shared objects file by jdk/internal/misc/ClassLoaders$AppClassLoader");
|
|
||||||
runtimeOutput.shouldContain("[class,load] HelloWB source: shared objects file");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDefiningLoader() throws Exception {
|
public void testDefiningLoader() throws Exception {
|
||||||
@ -84,9 +79,11 @@ public class ClassLoaderTest {
|
|||||||
String bootClassPath = "-Xbootclasspath/a:" + helloJar +
|
String bootClassPath = "-Xbootclasspath/a:" + helloJar +
|
||||||
File.pathSeparator + whiteBoxJar;
|
File.pathSeparator + whiteBoxJar;
|
||||||
|
|
||||||
|
// Archive the "Hello" class from the appended bootclasspath
|
||||||
TestCommon.dump(helloJar, TestCommon.list("Hello"), bootClassPath);
|
TestCommon.dump(helloJar, TestCommon.list("Hello"), bootClassPath);
|
||||||
|
|
||||||
TestCommon.execCommon("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
TestCommon.run("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
||||||
"-cp", appJar, bootClassPath, "-XX:+TraceClassPaths", "ForNameTest");
|
"-cp", appJar, bootClassPath, "-Xlog:class+path=trace", "ForNameTest")
|
||||||
|
.assertNormalExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -27,7 +27,7 @@ import sun.hotspot.WhiteBox;
|
|||||||
public class ForNameTest {
|
public class ForNameTest {
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
// Hello is on the bootclasspath. The defining classloader is
|
// Hello is on the bootclasspath. The defining classloader is
|
||||||
// the NULL classloader. See AppCDSClassLoaderTest.
|
// the NULL classloader. See ../ClassLoaderTest.java
|
||||||
Class c = Class.forName("Hello");
|
Class c = Class.forName("Hello");
|
||||||
ClassLoader cl = c.getClassLoader();
|
ClassLoader cl = c.getClassLoader();
|
||||||
if (cl != null) {
|
if (cl != null) {
|
||||||
@ -36,10 +36,10 @@ public class ForNameTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
WhiteBox wb = WhiteBox.getWhiteBox();
|
||||||
if (!wb.isSharedClass(c)) {
|
if (wb.isSharedClass(c)) {
|
||||||
System.out.println("As expected, Hello.class is not in shared space.");
|
System.out.println("As expected, Hello.class is in shared space.");
|
||||||
} else {
|
} else {
|
||||||
throw new java.lang.RuntimeException("Hello.class shouldn't be in shared space.");
|
throw new java.lang.RuntimeException("Hello.class must be in shared space.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,6 +26,7 @@ import sun.hotspot.WhiteBox;
|
|||||||
|
|
||||||
public class HelloWB {
|
public class HelloWB {
|
||||||
public static void main(String[] args) throws Throwable {
|
public static void main(String[] args) throws Throwable {
|
||||||
|
System.out.println("HelloWB.class.getClassLoader() = " + HelloWB.class.getClassLoader());
|
||||||
|
|
||||||
WhiteBox wb = WhiteBox.getWhiteBox();
|
WhiteBox wb = WhiteBox.getWhiteBox();
|
||||||
if (wb.isSharedClass(HelloWB.class)) {
|
if (wb.isSharedClass(HelloWB.class)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user