Skip to content

Commit dfe764e

Browse files
airsquaredAlexey Semenyuk
authored and
Alexey Semenyuk
committedJul 20, 2023
8309032: jpackage does not work for module projects unless --module-path is specified
Reviewed-by: asemenyuk, almatvee
1 parent 61ab270 commit dfe764e

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed
 

‎src/jdk.jpackage/share/classes/jdk/jpackage/internal/LauncherData.java

+8-16
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private LauncherData() {
105105
}
106106

107107
private void verifyIsModular(boolean isModular) {
108-
if ((moduleInfo != null) != isModular) {
108+
if ((moduleInfo == null) == isModular) {
109109
throw new IllegalStateException();
110110
}
111111
}
@@ -266,14 +266,10 @@ private static String getMainModule(Map<String, ? super Object> params) {
266266
private static String getStringParam(Map<String, ? super Object> params,
267267
String paramName) {
268268
Optional<Object> value = Optional.ofNullable(params.get(paramName));
269-
if (value.isPresent()) {
270-
return value.get().toString();
271-
}
272-
return null;
269+
return value.map(Object::toString).orElse(null);
273270
}
274271

275-
private static <T> T getPathParam(Map<String, ? super Object> params,
276-
String paramName, Supplier<T> func) throws ConfigException {
272+
private static <T> T getPathParam(String paramName, Supplier<T> func) throws ConfigException {
277273
try {
278274
return func.get();
279275
} catch (InvalidPathException ex) {
@@ -285,7 +281,7 @@ private static <T> T getPathParam(Map<String, ? super Object> params,
285281

286282
private static Path getPathParam(Map<String, ? super Object> params,
287283
String paramName) throws ConfigException {
288-
return getPathParam(params, paramName, () -> {
284+
return getPathParam(paramName, () -> {
289285
String value = getStringParam(params, paramName);
290286
Path result = null;
291287
if (value != null) {
@@ -304,21 +300,17 @@ private static List<Path> getModulePath(Map<String, ? super Object> params)
304300
runtimePath = runtimePath.resolve("lib");
305301
modulePath = Stream.of(modulePath, List.of(runtimePath))
306302
.flatMap(List::stream)
307-
.collect(Collectors.toUnmodifiableList());
303+
.toList();
308304
}
309305

310306
return modulePath;
311307
}
312308

313309
private static List<Path> getPathListParameter(String paramName,
314310
Map<String, ? super Object> params) throws ConfigException {
315-
return getPathParam(params, paramName, () -> {
316-
String value = (String) params.get(paramName);
317-
return (value == null) ? List.of() :
318-
List.of(value.split(File.pathSeparator)).stream()
319-
.map(Path::of)
320-
.collect(Collectors.toUnmodifiableList());
321-
});
311+
return getPathParam(paramName, () ->
312+
params.get(paramName) instanceof String value ?
313+
Stream.of(value.split(File.pathSeparator)).map(Path::of).toList() : List.of());
322314
}
323315

324316
private String qualifiedClassName;

0 commit comments

Comments
 (0)
Please sign in to comment.