|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
32 | 32 | * @run driver DumpClassList
|
33 | 33 | */
|
34 | 34 |
|
| 35 | +import jdk.test.lib.cds.CDSOptions; |
| 36 | +import jdk.test.lib.cds.CDSTestUtils; |
35 | 37 | import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
36 |
| -import jdk.test.lib.process.OutputAnalyzer; |
37 |
| -import jdk.test.lib.process.ProcessTools; |
38 | 38 |
|
39 | 39 | public class DumpClassList {
|
40 | 40 | public static void main(String[] args) throws Exception {
|
@@ -74,24 +74,27 @@ public static void main(String[] args) throws Exception {
|
74 | 74 | String appendJar = JarBuilder.build("bootappend", "boot/append/Foo");
|
75 | 75 |
|
76 | 76 | // dump class list
|
77 |
| - ProcessBuilder pb = ProcessTools.createTestJvm( |
78 |
| - "-XX:DumpLoadedClassList=" + classList, |
79 |
| - "--patch-module=java.base=" + patchJar, |
80 |
| - "-Xbootclasspath/a:" + appendJar, |
81 |
| - "-cp", |
82 |
| - appJar, |
83 |
| - appClass[0]); |
84 |
| - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); |
85 |
| - TestCommon.checkExecReturn(output, 0, true, |
86 |
| - "hello world", |
87 |
| - "skip writing class java/lang/NewClass") // skip classes outside of jrt image |
88 |
| - .shouldNotContain("skip writing class boot/append/Foo"); // but classes on -Xbootclasspath/a should not be skipped |
| 77 | + CDSTestUtils.dumpClassList(classList, |
| 78 | + "--patch-module=java.base=" + patchJar, |
| 79 | + "-Xbootclasspath/a:" + appendJar, |
| 80 | + "-cp", |
| 81 | + appJar, |
| 82 | + appClass[0]) |
| 83 | + .assertNormalExit(output -> { |
| 84 | + output.shouldContain("hello world"); |
| 85 | + // skip classes outside of jrt image |
| 86 | + output.shouldContain("skip writing class java/lang/NewClass"); |
| 87 | + // but classes on -Xbootclasspath/a should not be skipped |
| 88 | + output.shouldNotContain("skip writing class boot/append/Foo"); |
| 89 | + }); |
89 | 90 |
|
90 |
| - output = TestCommon.createArchive(appJar, appClass, |
91 |
| - "-Xbootclasspath/a:" + appendJar, |
92 |
| - "-Xlog:class+load", |
93 |
| - "-XX:SharedClassListFile=" + classList); |
94 |
| - TestCommon.checkDump(output) |
| 91 | + CDSOptions opts = (new CDSOptions()) |
| 92 | + .setClassList(appClass) |
| 93 | + .addPrefix("-cp", appJar, |
| 94 | + "-Xbootclasspath/a:" + appendJar, |
| 95 | + "-Xlog:class+load", |
| 96 | + "-XX:SharedClassListFile=" + classList); |
| 97 | + CDSTestUtils.createArchiveAndCheck(opts) |
95 | 98 | .shouldNotContain("Preload Warning: Cannot find java/lang/invoke/LambdaForm")
|
96 | 99 | .shouldNotContain("Preload Warning: Cannot find boot/append/Foo")
|
97 | 100 | .shouldContain("[info][class,load] boot.append.Foo");
|
|
0 commit comments