@@ -49,8 +49,8 @@ static String getMain() {
49
49
String sts = """
50
50
public class Main {
51
51
public static void main(String[] args) throws Exception {
52
- System.out.println(Class.forName(\" Foo\ " ));
53
- System.out.println(Class.forName(\" Bar\ " ));
52
+ System.out.println(Class.forName("pkg1. Foo"));
53
+ System.out.println(Class.forName("pkg2. Bar"));
54
54
}
55
55
}
56
56
""" ;
@@ -59,6 +59,7 @@ public static void main(String[] args) throws Exception {
59
59
60
60
static String getFoo () {
61
61
String sts = """
62
+ package pkg1;
62
63
class Foo {
63
64
static {
64
65
System.out.println("Hello from Foo old version");
@@ -70,6 +71,7 @@ class Foo {
70
71
71
72
static String getFooNewVersion () {
72
73
String sts = """
74
+ package pkg1;
73
75
class Foo {
74
76
static {
75
77
System.out.println("Hello from Foo new version");
@@ -81,6 +83,7 @@ class Foo {
81
83
82
84
static String getBar () {
83
85
String sts = """
86
+ package pkg2;
84
87
class Bar {
85
88
static {
86
89
System.out.println("Hello from Bar");
@@ -107,13 +110,17 @@ static void writeFile(File file, String... contents) throws Exception {
107
110
/* version.jar entries and files:
108
111
* META-INF/
109
112
* META-INF/MANIFEST.MF
110
- * Bar.class
111
113
* Main.class
114
+ * pkg2/
115
+ * pkg2/Bar.class
112
116
* META-INF/versions/9/
113
- * META-INF/versions/9/Bar.class
114
- * META-INF/versions/9/Foo.class
117
+ * META-INF/versions/9/pkg1
118
+ * META-INF/versions/9/pkg1/Foo.class
119
+ * META-INF/versions/9/pkg2
120
+ * META-INF/versions/9/pkg2/Bar.class
115
121
* META-INF/versions/24/
116
- * META-INF/versions/24/Foo.class
122
+ * META-INF/versions/24/pkg1
123
+ * META-INF/versions/24/pkg1Foo.class
117
124
*/
118
125
static void createClassFilesAndJar () throws Exception {
119
126
String tempDir = CDSTestUtils .getOutputDir ();
@@ -163,25 +170,25 @@ public static void main(String... args) throws Exception {
163
170
164
171
String mainClass = "Main" ;
165
172
String appJar = TestCommon .getTestJar ("multi-version.jar" );
166
- String appClasses [] = {"Foo" , "Bar" };
173
+ String appClasses [] = {"pkg1/ Foo" , "pkg2/ Bar" };
167
174
168
175
OutputAnalyzer output = TestCommon .dump (appJar , appClasses );
169
176
output .shouldContain ("Loading classes to share: done." )
170
177
.shouldHaveExitValue (0 );
171
178
172
- String agentCmdArg = "-agentlib:SimpleClassFileLoadHook=Foo,Hello,HELLO" ;
179
+ String agentCmdArg = "-agentlib:SimpleClassFileLoadHook=pkg1/ Foo,Hello,HELLO" ;
173
180
output = TestCommon .execAuto ("-cp" , appJar ,
174
181
"-Xlog:cds=info,class+load" ,
175
182
agentCmdArg ,
176
183
mainClass );
177
184
178
- output .shouldMatch (".*Foo.source:.*multi-version.jar" )
185
+ output .shouldMatch (".*pkg1. Foo.source:.*multi-version.jar" )
179
186
// New version of Foo is loaded from jar since it was modified by CFLH
180
187
.shouldContain ("HELLO from Foo new version" ) // CFLH changed "Hello" to "HELLO"
181
- .shouldContain ("class Foo" ) // output from Main
188
+ .shouldContain ("class pkg1. Foo" ) // output from Main
182
189
// Bar is loaded from archive
183
190
.shouldContain ("Bar source: shared objects file" )
184
191
.shouldContain ("Hello from Bar" )
185
- .shouldContain ("class Bar" ); // output from Main
192
+ .shouldContain ("class pkg2. Bar" ); // output from Main
186
193
}
187
194
}
0 commit comments