8226904: current working directory wrong running jpackage app JDK-8200758-branch
authorherrick
Sat, 29 Jun 2019 09:11:19 -0400
branchJDK-8200758-branch
changeset 57445 405ddd80496e
parent 57444 91e9d4691e5e
child 57446 5a5b85f00a63
8226904: current working directory wrong running jpackage app Reviewed-by: asemenyuk, almatvee
src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java
src/jdk.jpackage/share/native/libapplauncher/main.cpp
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherBase.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageArgumentsBase.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageBase.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageIconTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsBase.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsEqualsTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassAttributeTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassErrorTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageModuleMainClassErrorTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageNoNameTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageResourceTest.java
test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageRuntimeBase.java
test/jdk/tools/jpackage/createappimage/macosx/JPackageCreateAppImageBundleIdentifierTest.java
test/jdk/tools/jpackage/createappimage/macosx/JPackageCreateAppImageBundleNameTest.java
test/jdk/tools/jpackage/helpers/JPackagePath.java
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java	Sat Jun 29 09:11:19 2019 -0400
@@ -221,7 +221,7 @@
             Path modsDir = getAppModsDir();
             if (modsDir != null && modsDir.toFile().exists()) {
                 out.println("--module-path");
-                out.println(getAppDir().relativize(modsDir));
+                out.println("$APPDIR/app/" + getAppDir().relativize(modsDir));
             }
 
             out.println();
--- a/src/jdk.jpackage/share/native/libapplauncher/main.cpp	Fri Jun 28 16:50:51 2019 -0400
+++ b/src/jdk.jpackage/share/native/libapplauncher/main.cpp	Sat Jun 29 09:11:19 2019 -0400
@@ -87,7 +87,6 @@
             Package& package = Package::GetInstance();
             Macros::Initialize();
             package.SetCommandLineArguments(argc, argv);
-            platform.SetCurrentDirectory(package.GetPackageAppDirectory());
 
             switch (platform.GetAppCDSState()) {
                 case cdsDisabled:
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherBase.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherBase.java	Sat Jun 29 09:11:19 2019 -0400
@@ -32,7 +32,6 @@
 public class JPackageCreateAppImageAddLauncherBase {
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     // Note: quotes in argument for add launcher is not support by test
     private static final String ARGUMENT1 = "argument 1";
@@ -50,7 +49,7 @@
 
     private static void validateResult(List<String> args, List<String> vmArgs)
             throws Exception {
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageArgumentsBase.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageArgumentsBase.java	Sat Jun 29 09:11:19 2019 -0400
@@ -30,7 +30,6 @@
 
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static final String ARGUMENT1 = "argument";
     private static final String ARGUMENT2 = "Some Arguments";
@@ -96,7 +95,7 @@
                     + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageBase.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageBase.java	Sat Jun 29 09:11:19 2019 -0400
@@ -26,7 +26,6 @@
 
 public abstract class JPackageCreateAppImageBase {
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static void validateResult(String[] result) throws Exception {
         if (result.length != 2) {
@@ -44,7 +43,7 @@
     }
 
     public static void validate(String app) throws Exception {
-        Path outPath = Path.of(appWorkingDir, appOutput);
+        Path outPath = Path.of(appOutput);
         int retVal = JPackageHelper.execute(null, app);
 
         if (outPath.toFile().exists()) {
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageIconTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageIconTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -37,7 +37,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static final String[] CMD = {
         "--input", "input",
@@ -69,7 +68,7 @@
                    "Test application exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsBase.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsBase.java	Sat Jun 29 09:11:19 2019 -0400
@@ -30,7 +30,6 @@
 
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static final String ARGUMENT1 = "-Dparam1=Some Param 1";
     private static final String ARGUMENT2 = "-Dparam2=Some \"Param\" 2";
@@ -113,7 +112,7 @@
                     + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsEqualsTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageJavaOptionsEqualsTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -37,7 +37,6 @@
 public class JPackageCreateAppImageJavaOptionsEqualsTest {
 
     private static final String app = JPackagePath.getApp();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static final String OUTPUT = "output";
 
@@ -57,7 +56,7 @@
     };
 
     private static void validate() throws Exception {
-        File outfile = new File(appWorkingDir + File.separator + "app.out");
+        File outfile = new File("app.out");
 
         int retVal = JPackageHelper.execute(outfile, app);
         if (retVal != 0) {
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassAttributeTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassAttributeTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -37,7 +37,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static final String[] CMD = {
         "--input", "input",
@@ -67,7 +66,7 @@
                    "Test application exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassErrorTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageMainClassErrorTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -37,7 +37,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static final String[] CMD = {
         "--input", "input",
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageModuleMainClassErrorTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageModuleMainClassErrorTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -37,7 +37,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static final String [] CMD1 = {
         "--output", OUTPUT,
@@ -53,7 +52,7 @@
 
     private static void validate(String buildOutput) throws Exception {
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         int retVal = JPackageHelper.execute(outfile, app);
         if (retVal != 0) {
             throw new AssertionError(
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageNoNameTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageNoNameTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -37,8 +37,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp("Hello");
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir =
-            JPackagePath.getAppWorkingDir("Hello");
 
     private static final String[] CMD = {
         "--input", "input",
@@ -69,7 +67,7 @@
                    "Test application exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageResourceTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageResourceTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -38,8 +38,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp("icon");
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir =
-            JPackagePath.getAppWorkingDir("icon");
     private static final String resourceDir = 
             JPackagePath.getTestSrcRoot() + File.separator + "resources";
 
@@ -73,7 +71,7 @@
                    "Test application exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageRuntimeBase.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageRuntimeBase.java	Sat Jun 29 09:11:19 2019 -0400
@@ -26,7 +26,6 @@
 
  public class JPackageCreateAppImageRuntimeBase {
     private static final String app = JPackagePath.getApp();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
     private static final String runtimeJava = JPackagePath.getRuntimeJava();
     private static final String runtimeJavaOutput = "javaOutput.txt";
     private static final String appOutput = JPackagePath.getAppOutputFile();
@@ -51,7 +50,7 @@
             throw new AssertionError("Test application exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
@@ -84,13 +83,17 @@
     }
 
     public static void testCreateAppImage(String [] cmd) throws Exception {
+System.out.println("----- current dir = " + System.getProperty("user.dir"));
         JPackageHelper.executeCLI(true, cmd);
+System.out.println("----- current dir = " + System.getProperty("user.dir"));
         validate();
         validateRuntime();
     }
 
     public static void testCreateAppImageToolProvider(String [] cmd) throws Exception {
+System.out.println("----- ToolProvider current dir = " + System.getProperty("user.dir"));
         JPackageHelper.executeToolProvider(true, cmd);
+System.out.println("----- ToolProvider current dir = " + System.getProperty("user.dir"));
         validate();
         validateRuntime();
     }
--- a/test/jdk/tools/jpackage/createappimage/macosx/JPackageCreateAppImageBundleIdentifierTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/macosx/JPackageCreateAppImageBundleIdentifierTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -44,7 +44,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
     private static final String MAC_BUNDLE_IDENTIFIER = "TestBundleIdentifier";
     private static final String APP_NAME = "test";
     private static final String MAIN_CLASS = "Hello";
@@ -88,7 +87,7 @@
                    "Test application exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/createappimage/macosx/JPackageCreateAppImageBundleNameTest.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/createappimage/macosx/JPackageCreateAppImageBundleNameTest.java	Sat Jun 29 09:11:19 2019 -0400
@@ -44,7 +44,6 @@
     private static final String OUTPUT = "output";
     private static final String app = JPackagePath.getApp();
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
     private static final String MAC_BUNDLE_NAME = "TestBundleName";
     private static final String APP_NAME = "test";
 
@@ -87,7 +86,7 @@
                    "Test application exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
+        File outfile = new File(appOutput);
         if (!outfile.exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
--- a/test/jdk/tools/jpackage/helpers/JPackagePath.java	Fri Jun 28 16:50:51 2019 -0400
+++ b/test/jdk/tools/jpackage/helpers/JPackagePath.java	Sat Jun 29 09:11:19 2019 -0400
@@ -106,25 +106,6 @@
         }
     }
 
-    // Returns path to app working directory
-    // (where test application generates its output)
-    public static String getAppWorkingDir() {
-        return getAppWorkingDir("test");
-    }
-
-    public static String getAppWorkingDir(String name) {
-         if (JPackageHelper.isWindows()) {
-            return Path.of("output", name, "app").toString();
-        } else if (JPackageHelper.isOSX()) {
-            return Path.of("output", name + ".app",
-                    "Contents", "Java").toString();
-        } else if (JPackageHelper.isLinux()) {
-            return Path.of("output", name, "app").toString();
-        } else {
-            throw new AssertionError("Cannot detect platform");
-        }
-    }
-
     // Returns path to test application cfg file
     public static String getAppCfg() {
         return getAppCfg("test");