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. |
53 |
53 |
54 BootClassPathMismatch test = new BootClassPathMismatch(); |
54 BootClassPathMismatch test = new BootClassPathMismatch(); |
55 test.testBootClassPathMismatch(); |
55 test.testBootClassPathMismatch(); |
56 test.testBootClassPathMismatchWithAppClass(); |
56 test.testBootClassPathMismatchWithAppClass(); |
57 test.testBootClassPathMismatchWithBadPath(); |
57 test.testBootClassPathMismatchWithBadPath(); |
58 test.testBootClassPathMatchWithAppend(); |
58 if (!TestCommon.isDynamicArchive()) { |
|
59 // this test is not applicable to dynamic archive since |
|
60 // there is no class to be archived in the top archive |
|
61 test.testBootClassPathMatchWithAppend(); |
|
62 } |
59 test.testBootClassPathMatch(); |
63 test.testBootClassPathMatch(); |
60 } |
64 } |
61 |
65 |
62 /* Archive contains boot classes only, with Hello class on -Xbootclasspath/a path. |
66 /* Archive contains boot classes only, with Hello class on -Xbootclasspath/a path. |
63 * |
67 * |
75 String testDir = TestCommon.getTestDir("newdir"); |
79 String testDir = TestCommon.getTestDir("newdir"); |
76 String otherJar = testDir + File.separator + "hello.jar"; |
80 String otherJar = testDir + File.separator + "hello.jar"; |
77 |
81 |
78 TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar); |
82 TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar); |
79 TestCommon.run( |
83 TestCommon.run( |
|
84 "-Xlog:cds", |
80 "-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello") |
85 "-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello") |
81 .assertAbnormalExit(mismatchMessage); |
86 .assertAbnormalExit(mismatchMessage); |
82 |
87 |
83 TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + otherJar); |
88 TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + otherJar); |
84 TestCommon.run( |
89 TestCommon.run( |
|
90 "-Xlog:cds", |
85 "-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello") |
91 "-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello") |
86 .assertAbnormalExit(mismatchMessage); |
92 .assertAbnormalExit(mismatchMessage); |
87 } |
93 } |
88 |
94 |
89 /* Archive contains boot classes only. |
95 /* Archive contains boot classes only. |
98 String appJar = testDir + File.separator + "hello.jar"; |
104 String appJar = testDir + File.separator + "hello.jar"; |
99 String otherJar = testDir + File.separator + "hello.jar1"; |
105 String otherJar = testDir + File.separator + "hello.jar1"; |
100 |
106 |
101 TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar); |
107 TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar); |
102 TestCommon.run( |
108 TestCommon.run( |
|
109 "-Xlog:cds", |
103 "-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello") |
110 "-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello") |
104 .assertAbnormalExit(mismatchMessage); |
111 .assertAbnormalExit(mismatchMessage); |
105 } |
112 } |
106 |
113 |
107 /* Archive contains boot classes only, with Hello loaded from -Xbootclasspath/a at dump time. |
114 /* Archive contains boot classes only, with Hello loaded from -Xbootclasspath/a at dump time. |
146 public void testBootClassPathMismatchWithAppClass() throws Exception { |
153 public void testBootClassPathMismatchWithAppClass() throws Exception { |
147 String appJar = JarBuilder.getOrCreateHelloJar(); |
154 String appJar = JarBuilder.getOrCreateHelloJar(); |
148 String appClasses[] = {"Hello"}; |
155 String appClasses[] = {"Hello"}; |
149 TestCommon.dump(appJar, appClasses); |
156 TestCommon.dump(appJar, appClasses); |
150 TestCommon.run( |
157 TestCommon.run( |
|
158 "-Xlog:cds", |
151 "-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello") |
159 "-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello") |
152 .assertAbnormalExit(mismatchMessage); |
160 .assertAbnormalExit(mismatchMessage); |
153 } |
161 } |
154 |
162 |
155 private static void copyHelloToNewDir() throws Exception { |
163 private static void copyHelloToNewDir() throws Exception { |