1 /* |
1 /* |
2 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
60 String bootClassPath = "-Xbootclasspath/a:" + appJar + |
60 String bootClassPath = "-Xbootclasspath/a:" + appJar + |
61 File.pathSeparator + whiteBoxJar; |
61 File.pathSeparator + whiteBoxJar; |
62 |
62 |
63 TestCommon.dump(appJar, appClasses, bootClassPath); |
63 TestCommon.dump(appJar, appClasses, bootClassPath); |
64 |
64 |
65 OutputAnalyzer runtimeOutput = TestCommon.execCommon( |
65 TestCommon.run( |
66 "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
66 "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
67 "-cp", appJar, bootClassPath, "-Xlog:class+load", "HelloWB"); |
67 "-cp", appJar, bootClassPath, "HelloWB") |
68 |
68 .assertNormalExit(output -> output.shouldContain("HelloWB.class.getClassLoader() = null")); |
69 if (!TestCommon.isUnableToMap(runtimeOutput)) { |
|
70 runtimeOutput.shouldNotContain( |
|
71 "[class,load] HelloWB source: shared objects file by jdk/internal/misc/ClassLoaders$AppClassLoader"); |
|
72 runtimeOutput.shouldContain("[class,load] HelloWB source: shared objects file"); |
|
73 } |
|
74 } |
69 } |
75 |
70 |
76 public void testDefiningLoader() throws Exception { |
71 public void testDefiningLoader() throws Exception { |
77 // The boot loader should be used to load the class when it's |
72 // The boot loader should be used to load the class when it's |
78 // on the bootclasspath, regardless who is the initiating classloader. |
73 // on the bootclasspath, regardless who is the initiating classloader. |
82 TestCommon.getTestJar("ClassLoaderTest-ForName.jar"); |
77 TestCommon.getTestJar("ClassLoaderTest-ForName.jar"); |
83 String whiteBoxJar = TestCommon.getTestJar("ClassLoaderTest-WhiteBox.jar"); |
78 String whiteBoxJar = TestCommon.getTestJar("ClassLoaderTest-WhiteBox.jar"); |
84 String bootClassPath = "-Xbootclasspath/a:" + helloJar + |
79 String bootClassPath = "-Xbootclasspath/a:" + helloJar + |
85 File.pathSeparator + whiteBoxJar; |
80 File.pathSeparator + whiteBoxJar; |
86 |
81 |
|
82 // Archive the "Hello" class from the appended bootclasspath |
87 TestCommon.dump(helloJar, TestCommon.list("Hello"), bootClassPath); |
83 TestCommon.dump(helloJar, TestCommon.list("Hello"), bootClassPath); |
88 |
84 |
89 TestCommon.execCommon("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
85 TestCommon.run("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
90 "-cp", appJar, bootClassPath, "-XX:+TraceClassPaths", "ForNameTest"); |
86 "-cp", appJar, bootClassPath, "-Xlog:class+path=trace", "ForNameTest") |
|
87 .assertNormalExit(); |
91 } |
88 } |
92 } |
89 } |