diff -r 8f9cf6ad59f0 -r db003bfc5bf7 src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java Tue Dec 18 15:10:45 2018 -0500 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java Tue Dec 18 16:57:57 2018 -0500 @@ -290,31 +290,6 @@ (s, p) -> Arrays.asList(s.split("\n\n")) ); - @SuppressWarnings("unchecked") - static final StandardBundlerParam> JVM_PROPERTIES = - new StandardBundlerParam<>( - I18N.getString("param.jvm-system-properties.name"), - I18N.getString("param.jvm-system-properties.description"), - "jvmProperties", - (Class>) (Object) Map.class, - params -> Collections.emptyMap(), - (s, params) -> { - Map map = new HashMap<>(); - try { - Properties p = new Properties(); - p.load(new StringReader(s)); - for (Map.Entry entry : p.entrySet()) { - map.put((String)entry.getKey(), - (String)entry.getValue()); - } - } catch (IOException e) { - e.printStackTrace(); - } - return map; - } - ); - static final StandardBundlerParam TITLE = new StandardBundlerParam<>( I18N.getString("param.title.name"), @@ -852,25 +827,41 @@ } private static RelativeFileSet getMainJar( - String moduleName, Map params) { + String mainJarValue, Map params) { for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(params)) { File appResourcesRoot = rfs.getBaseDirectory(); - File mainJarFile = new File(appResourcesRoot, moduleName); + File mainJarFile = new File(appResourcesRoot, mainJarValue); if (mainJarFile.exists()) { return new RelativeFileSet(appResourcesRoot, new LinkedHashSet<>(Collections.singletonList( mainJarFile))); } - else { + mainJarFile = new File(mainJarValue); + if (mainJarFile.exists()) { + // absolute path for main-jar may fail is only legal if + // path is within the appResourceRoot directory + try { + return new RelativeFileSet(appResourcesRoot, + new LinkedHashSet<>(Collections.singletonList( + mainJarFile))); + } catch (Exception e) { + // if not within, RelativeFileSet constructor throws a + // RuntimeException, but the IllegalArgumentException + // below contains a more explicit error message. + } + } else { List modulePath = MODULE_PATH.fetchFrom(params); - Path modularJarPath = JLinkBundlerHelper.findPathOfModule( - modulePath, moduleName); - - if (modularJarPath != null && Files.exists(modularJarPath)) { - return new RelativeFileSet(appResourcesRoot, - new LinkedHashSet<>(Collections.singletonList( - modularJarPath.toFile()))); + modulePath.removeAll(getDefaultModulePath()); + if (!modulePath.isEmpty()) { + Path modularJarPath = JLinkBundlerHelper.findPathOfModule( + modulePath, mainJarValue); + if (modularJarPath != null && + Files.exists(modularJarPath)) { + return new RelativeFileSet(appResourcesRoot, + new LinkedHashSet<>(Collections.singletonList( + modularJarPath.toFile()))); + } } } } @@ -878,7 +869,7 @@ throw new IllegalArgumentException( new ConfigException(MessageFormat.format(I18N.getString( "error.main-jar-does-not-exist"), - moduleName), I18N.getString( + mainJarValue), I18N.getString( "error.main-jar-does-not-exist.advice"))); }