10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 /*
26 * @test
27 * @summary Tests how CDS works when critical library classes are replaced with JVMTI ClassFileLoadHook
28 * @library /test/lib
29 * @requires vm.cds.write.archived.java.heap
30 * @build jdk.test.whitebox.WhiteBox
31 * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
32 * @run main/othervm/native ReplaceCriticalClassesForSubgraphs
33 */
34
35 public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses {
36 public static void main(String args[]) throws Throwable {
37 ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs();
38 rcc.process(args);
39 }
40
41 public String[] getTests() {
42 String tests[] = {
43 // Try to replace classes that are used by the archived subgraph graphs. (CDS should be disabled)
44 "-early -notshared -subgraph java/lang/module/ResolvedModule jdk.internal.module.ArchivedModuleGraph",
45 "-early -notshared -subgraph java/lang/Integer java.lang.Integer$IntegerCache",
46
47 // CDS should not be disabled -- these critical classes cannot be replaced because
48 // JvmtiExport::early_class_hook_env() is false.
49 "-subgraph java/lang/module/Configuration java.lang.module.Configuration",
50 "-subgraph java/lang/ModuleLayer java.lang.ModuleLayer",
51 "-subgraph java/lang/Integer java.lang.Integer$IntegerCache",
52
53 // Tests for archived full module graph. We cannot use whitebox, which requires appending to bootclasspath.
54 // VM will disable full module graph if bootclasspath is appended.
55 "-nowhitebox -early -notshared -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
56 "-nowhitebox -early -notshared -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
57 "-nowhitebox -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
58 "-nowhitebox -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
59 };
60 return tests;
61 }
62 }
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 /*
26 * @test
27 * @summary Tests how CDS works when critical library classes are replaced with JVMTI ClassFileLoadHook
28 * @library /test/lib
29 * @requires vm.cds.write.archived.java.heap
30 * @modules java.base/jdk.internal.misc
31 * @build jdk.test.whitebox.WhiteBox
32 * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox
33 * @run main/othervm/native ReplaceCriticalClassesForSubgraphs
34 */
35
36 import java.util.ArrayList;
37 import java.util.Arrays;
38 import jdk.internal.misc.PreviewFeatures;
39
40 public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses {
41 public static void main(String args[]) throws Throwable {
42 ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs();
43 rcc.process(args);
44 }
45
46 public String[] getTests() {
47 ArrayList<String> tests = new ArrayList<String>(Arrays.asList(
48 // Try to replace classes that are used by the archived subgraph graphs. (CDS should be disabled)
49 "-early -notshared -subgraph java/lang/module/ResolvedModule jdk.internal.module.ArchivedModuleGraph",
50 "-early -notshared -subgraph java/lang/Integer java.lang.Integer$IntegerCache",
51
52 // CDS should not be disabled -- these critical classes cannot be replaced because
53 // JvmtiExport::early_class_hook_env() is false.
54 "-subgraph java/lang/module/Configuration java.lang.module.Configuration",
55 "-subgraph java/lang/ModuleLayer java.lang.ModuleLayer",
56
57 // Tests for archived full module graph. We cannot use whitebox, which requires appending to bootclasspath.
58 // VM will disable full module graph if bootclasspath is appended.
59 "-nowhitebox -early -notshared -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
60 "-nowhitebox -early -notshared -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer",
61 "-nowhitebox -subgraph java/lang/Module jdk.internal.module.ArchivedBootLayer",
62 "-nowhitebox -subgraph java/lang/ModuleLayer jdk.internal.module.ArchivedBootLayer"));
63
64 // IntegerCache does not exist in preview mode so it should not be expected in the output
65 if (!PreviewFeatures.isEnabled()) {
66 // CDS should not be disabled -- these critical classes cannot be replaced because
67 // JvmtiExport::early_class_hook_env() is false.
68 tests.add("-subgraph java/lang/Integer java.lang.Integer$IntegerCache");
69 }
70
71 return tests.toArray(new String[0]);
72 }
73 }
|