src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java
branchJDK-8200758-branch
changeset 57314 23da9e6f446f
parent 57291 f2d429260ad4
child 57316 2891b3ae222d
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java	Fri Apr 05 11:24:44 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java	Tue Apr 09 10:57:04 2019 -0400
@@ -167,19 +167,33 @@
                     (s, p) -> s
             );
 
+    static final StandardBundlerParam<File> PREDEFINED_RUNTIME_IMAGE =
+            new StandardBundlerParam<>(
+                    Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId(),
+                    File.class,
+                    params -> null,
+                    (s, p) -> new File(s)
+            );
+
     static final StandardBundlerParam<String> APP_NAME =
             new StandardBundlerParam<>(
                     Arguments.CLIOptions.NAME.getId(),
                     String.class,
                     params -> {
                         String s = MAIN_CLASS.fetchFrom(params);
-                        if (s == null) return null;
-
-                        int idx = s.lastIndexOf(".");
-                        if (idx >= 0) {
-                            return s.substring(idx+1);
+                        if (s != null) {
+                            int idx = s.lastIndexOf(".");
+                            if (idx >= 0) {
+                                return s.substring(idx+1);
+                            }
+                            return s;
+                        } else if (isRuntimeInstaller(params)) {
+                            File f = PREDEFINED_RUNTIME_IMAGE.fetchFrom(params);
+                            if (f != null) {
+                                return f.getName();
+                            }
                         }
-                        return s;
+                        return null;
                     },
                     (s, p) -> s
             );
@@ -343,13 +357,6 @@
             params -> null,
             (s, p) -> new File(s));
 
-    static final StandardBundlerParam<File> PREDEFINED_RUNTIME_IMAGE =
-            new StandardBundlerParam<>(
-            Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId(),
-            File.class,
-            params -> null,
-            (s, p) -> new File(s));
-
     @SuppressWarnings("unchecked")
     static final StandardBundlerParam<List<Map<String, ? super Object>>> ADD_LAUNCHERS =
             new StandardBundlerParam<>(
@@ -718,17 +725,8 @@
             }
             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.
-                }
+                // absolute path for main-jar may fail is not legal
+                // below contains explicit error message.
             } else {
                 List<Path> modulePath = MODULE_PATH.fetchFrom(params);
                 modulePath.removeAll(getDefaultModulePath());