author | coleenp |
Mon, 29 Jul 2019 10:34:20 -0400 | |
changeset 57567 | b000362a89a0 |
parent 54927 | test/hotspot/jtreg/runtime/appcds/ProhibitedPackage.java@1512d88b24c6 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
54927 | 2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
48138 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
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 AppCDS handling of prohibited package. |
|
48469
7312ae4465d6
8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents:
48156
diff
changeset
|
28 |
* @requires vm.cds |
48138 | 29 |
* @library /test/lib |
54927 | 30 |
* @modules jdk.jartool/sun.tools.jar |
48138 | 31 |
* @compile test-classes/ProhibitedHelper.java test-classes/Prohibited.jasm |
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
51507
diff
changeset
|
32 |
* @run driver ProhibitedPackage |
48138 | 33 |
*/ |
34 |
||
49162
c200b4700aeb
8195065: runtime/appcds/ProhibitedPackage.java intermittent failure
iklam
parents:
49008
diff
changeset
|
35 |
import jdk.test.lib.cds.CDSOptions; |
48138 | 36 |
import jdk.test.lib.Platform; |
37 |
import jdk.test.lib.process.OutputAnalyzer; |
|
38 |
||
39 |
public class ProhibitedPackage { |
|
40 |
||
41 |
public static void main(String[] args) throws Exception { |
|
42 |
JarBuilder.build("prohibited_pkg", "java/lang/Prohibited", "ProhibitedHelper"); |
|
43 |
||
44 |
String appJar = TestCommon.getTestJar("prohibited_pkg.jar"); |
|
45 |
||
48155
551de50b4ff7
8191927: Enable AppCDS for custom loaders on all 64-bit Linux and AIX
iklam
parents:
48138
diff
changeset
|
46 |
// Test support for customer loaders |
54927 | 47 |
if (Platform.areCustomLoadersSupportedForCDS() && |
48 |
!TestCommon.isDynamicArchive()) { |
|
48138 | 49 |
String classlist[] = new String[] { |
50 |
"java/lang/Object id: 1", |
|
51 |
"java/lang/Prohibited id: 2 super: 1 source: " + appJar |
|
52 |
}; |
|
53 |
||
54 |
// Make sure a class in a prohibited package for a custom loader |
|
55 |
// will be ignored during dumping. |
|
48156
a8f9aac3c2e5
8191747: [TESTBUG] runtime/appcds/DumpClassList.java and ProhibitedPackage.java fail on product bits
iklam
parents:
48155
diff
changeset
|
56 |
TestCommon.dump(appJar, classlist, "-Xlog:cds") |
48138 | 57 |
.shouldContain("Dumping") |
48156
a8f9aac3c2e5
8191747: [TESTBUG] runtime/appcds/DumpClassList.java and ProhibitedPackage.java fail on product bits
iklam
parents:
48155
diff
changeset
|
58 |
.shouldContain("[cds] Prohibited package for non-bootstrap classes: java/lang/Prohibited.class") |
48138 | 59 |
.shouldHaveExitValue(0); |
60 |
} |
|
61 |
||
62 |
||
63 |
// Make sure a class in a prohibited package for a non-custom loader |
|
64 |
// will be ignored during dumping. |
|
65 |
TestCommon.dump(appJar, |
|
66 |
TestCommon.list("java/lang/Prohibited", "ProhibitedHelper"), |
|
48156
a8f9aac3c2e5
8191747: [TESTBUG] runtime/appcds/DumpClassList.java and ProhibitedPackage.java fail on product bits
iklam
parents:
48155
diff
changeset
|
67 |
"-Xlog:class+load") |
48138 | 68 |
.shouldContain("Dumping") |
48156
a8f9aac3c2e5
8191747: [TESTBUG] runtime/appcds/DumpClassList.java and ProhibitedPackage.java fail on product bits
iklam
parents:
48155
diff
changeset
|
69 |
.shouldNotContain("[info][class,load] java.lang.Prohibited source: ") |
48138 | 70 |
.shouldHaveExitValue(0); |
71 |
||
72 |
// Try loading the class in a prohibited package with various -Xshare |
|
73 |
// modes. The class shouldn't be loaded and appropriate exceptions |
|
74 |
// are expected. |
|
75 |
||
76 |
OutputAnalyzer output; |
|
77 |
||
78 |
// -Xshare:on |
|
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
79 |
TestCommon.run( |
48138 | 80 |
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
51507
3e3764f8fe36
8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests
ccheung
parents:
49162
diff
changeset
|
81 |
"-cp", appJar, "ProhibitedHelper") |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48469
diff
changeset
|
82 |
.assertNormalExit("Prohibited package name: java.lang"); |
48138 | 83 |
|
84 |
// -Xshare:auto |
|
85 |
output = TestCommon.execAuto( |
|
86 |
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
|
51507
3e3764f8fe36
8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests
ccheung
parents:
49162
diff
changeset
|
87 |
"-cp", appJar, "ProhibitedHelper"); |
49162
c200b4700aeb
8195065: runtime/appcds/ProhibitedPackage.java intermittent failure
iklam
parents:
49008
diff
changeset
|
88 |
CDSOptions opts = (new CDSOptions()).setXShareMode("auto"); |
c200b4700aeb
8195065: runtime/appcds/ProhibitedPackage.java intermittent failure
iklam
parents:
49008
diff
changeset
|
89 |
TestCommon.checkExec(output, opts, "Prohibited package name: java.lang"); |
48138 | 90 |
|
91 |
// -Xshare:off |
|
92 |
output = TestCommon.execOff( |
|
93 |
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
|
51507
3e3764f8fe36
8207211: [TESTBUG] Remove excessive output from CDS/AppCDS tests
ccheung
parents:
49162
diff
changeset
|
94 |
"-cp", appJar, "ProhibitedHelper"); |
48138 | 95 |
output.shouldContain("Prohibited package name: java.lang"); |
96 |
} |
|
97 |
} |