1 /* |
1 /* |
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2019, 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. |
25 /* |
25 /* |
26 * @test |
26 * @test |
27 * @summary AppCDS handling of package. |
27 * @summary AppCDS handling of package. |
28 * @requires vm.cds |
28 * @requires vm.cds |
29 * @library /test/lib |
29 * @library /test/lib |
30 * @modules java.base/jdk.internal.misc |
30 * @modules jdk.jartool/sun.tools.jar |
31 * java.management |
|
32 * @compile test-classes/C1.java |
31 * @compile test-classes/C1.java |
33 * @compile test-classes/C2.java |
32 * @compile test-classes/C2.java |
34 * @compile test-classes/PackageSealingTest.java |
33 * @compile test-classes/PackageSealingTest.java |
|
34 * @compile test-classes/Hello.java |
35 * @run driver PackageSealing |
35 * @run driver PackageSealing |
36 */ |
36 */ |
37 |
37 |
|
38 import java.io.File; |
38 import jdk.test.lib.process.OutputAnalyzer; |
39 import jdk.test.lib.process.OutputAnalyzer; |
39 |
40 |
40 public class PackageSealing { |
41 public class PackageSealing { |
41 public static void main(String args[]) throws Exception { |
42 public static void main(String args[]) throws Exception { |
42 String[] classList = {"sealed/pkg/C1", "pkg/C2", "PackageSealingTest"}; |
43 String[] classList = {"sealed/pkg/C1", "pkg/C2", "PackageSealingTest"}; |
43 String appJar = ClassFileInstaller.writeJar("pkg_seal.jar", |
44 String appJar = ClassFileInstaller.writeJar("pkg_seal.jar", |
44 ClassFileInstaller.Manifest.fromSourceFile("test-classes/package_seal.mf"), |
45 ClassFileInstaller.Manifest.fromSourceFile("test-classes/package_seal.mf"), |
45 "PackageSealingTest", "sealed/pkg/C1", "pkg/C2"); |
46 "PackageSealingTest", "sealed/pkg/C1", "pkg/C2"); |
46 |
47 |
|
48 String helloJar = JarBuilder.getOrCreateHelloJar(); |
|
49 String jars = helloJar + File.pathSeparator + appJar; |
|
50 |
47 // test shared package from -cp path |
51 // test shared package from -cp path |
48 TestCommon.testDump(appJar, TestCommon.list(classList)); |
52 TestCommon.testDump(jars, TestCommon.list(classList)); |
49 OutputAnalyzer output; |
53 OutputAnalyzer output; |
50 output = TestCommon.exec(appJar, "PackageSealingTest"); |
54 output = TestCommon.exec(jars, "PackageSealingTest"); |
51 TestCommon.checkExec(output, "OK"); |
55 TestCommon.checkExec(output, "OK"); |
52 |
56 |
53 // test shared package from -Xbootclasspath/a |
57 // test shared package from -Xbootclasspath/a |
54 TestCommon.dump(appJar, TestCommon.list(classList), |
58 TestCommon.dump(helloJar, TestCommon.list(classList), |
55 "-Xbootclasspath/a:" + appJar); |
59 "-Xbootclasspath/a:" + appJar); |
56 output = TestCommon.exec(appJar, "-Xbootclasspath/a:" + appJar, "PackageSealingTest"); |
60 output = TestCommon.exec(helloJar, "-Xbootclasspath/a:" + appJar, "PackageSealingTest"); |
57 TestCommon.checkExec(output, "OK"); |
61 TestCommon.checkExec(output, "OK"); |
58 } |
62 } |
59 } |
63 } |