1
1
/*
2
- * Copyright (c) 2015, 2018 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2024 , 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
@@ -125,27 +125,28 @@ public void testAllModulePath() throws Throwable {
125
125
}
126
126
127
127
/*
128
- * Since ALL-MODULE-PATH does not allow --limit-modules. Add a test that
129
- * includes just a single module from the module path. This is just for
130
- * completeness and shows the intended replacement.
128
+ * --add-modules ALL-MODULE-PATH with --limit-modules is an error
131
129
*/
132
130
@ Test
133
- public void testSubsetModules () throws Throwable {
131
+ public void testLimitModules () throws Throwable {
134
132
if (isExplodedJDKImage ()) {
135
133
return ;
136
134
}
137
-
138
- // create custom image
139
- Path image = HELPER .createNewImageDir ("image1" );
140
- // Instead of --add-modules ALL-MODULE-PATH [...] --limit-modules m1 do:
141
- List <String > opts = List .of ("--module-path" , MODS .toString (),
142
- "--output" , image .toString (),
143
- "--add-modules" , "m1" );
144
- createImage (image , opts , true /* success */ );
145
-
146
- checkModules (image , Set .of ("m1" , "java.base" ));
135
+ Path targetPath = HELPER .createNewImageDir ("all-mods-limit-mods" );
136
+ String moduleName = "com.baz.runtime" ;
137
+ Result result = HELPER .generateDefaultJModule (moduleName , "jdk.jfr" );
138
+ Path customModulePath = result .getFile ().getParent ();
139
+ List <String > allArgs = List .of ("--add-modules" , "ALL-MODULE-PATH" ,
140
+ "--limit-modules" , "jdk.jfr" ,
141
+ "--module-path" , customModulePath .toString (),
142
+ "--output" , targetPath .toString ());
143
+ JlinkOutput allOut = createImage (targetPath , allArgs , false /* success */ );
144
+ String actual = allOut .stdout .trim ();
145
+ String expected = "Error: --limit-modules not allowed with --add-modules ALL-MODULE-PATH" ;
146
+ assertEquals (actual , expected );
147
147
}
148
148
149
+
149
150
/*
150
151
* --add-modules *includes* ALL-MODULE-PATH with an existing module path
151
152
*/
@@ -159,7 +160,7 @@ public void testAddModules() throws Throwable {
159
160
Path image = HELPER .createNewImageDir ("image2" );
160
161
List <String > opts = List .of ("--module-path" , MODS .toString (),
161
162
"--output" , image .toString (),
162
- "--add-modules" , "m1,test " ,
163
+ "--add-modules" , "m1" ,
163
164
"--add-modules" , "ALL-MODULE-PATH" );
164
165
createImage (image , opts , true /* success */ );
165
166
@@ -206,28 +207,6 @@ public void modulePathEmpty() throws IOException {
206
207
assertTrue (actual .contains (strNotExists ));
207
208
}
208
209
209
- /*
210
- * --add-modules ALL-MODULE-PATH with --limit-modules is an error
211
- */
212
- @ Test
213
- public void testLimitModules () throws Exception {
214
- if (isExplodedJDKImage ()) {
215
- return ;
216
- }
217
- Path targetPath = HELPER .createNewImageDir ("all-mods-limit-mods" );
218
- String moduleName = "com.baz.runtime" ;
219
- Result result = HELPER .generateDefaultJModule (moduleName , "jdk.jfr" );
220
- Path customModulePath = result .getFile ().getParent ();
221
- List <String > allArgs = List .of ("--add-modules" , "ALL-MODULE-PATH" ,
222
- "--limit-modules" , "jdk.jfr" ,
223
- "--module-path" , customModulePath .toString (),
224
- "--output" , targetPath .toString ());
225
- JlinkOutput allOut = createImage (targetPath , allArgs , false /* success */ );
226
- String actual = allOut .stdout .trim ();
227
- String expected = "Error: --limit-modules not allowed with --add-modules ALL-MODULE-PATH" ;
228
- assertEquals (actual , expected );
229
- }
230
-
231
210
/*
232
211
* check the modules linked in the image using m1/p.ListModules
233
212
*/
0 commit comments