8228402: chdir() and write() errors are not handled in jpackage JDK-8200758-branch
authorherrick
Thu, 25 Jul 2019 08:13:44 -0400
branchJDK-8200758-branch
changeset 57531 d24019d561da
parent 57530 9063613e9bb1
child 57532 eb0bd96672f4
8228402: chdir() and write() errors are not handled in jpackage Reviewed-by: almatvee
src/jdk.jpackage/linux/native/libapplauncher/LinuxPlatform.cpp
src/jdk.jpackage/linux/native/libapplauncher/LinuxPlatform.h
src/jdk.jpackage/macosx/native/libapplauncher/MacPlatform.h
src/jdk.jpackage/macosx/native/libapplauncher/MacPlatform.mm
src/jdk.jpackage/share/native/libapplauncher/Platform.h
src/jdk.jpackage/unix/native/libapplauncher/PosixPlatform.cpp
src/jdk.jpackage/unix/native/libapplauncher/PosixPlatform.h
src/jdk.jpackage/windows/native/libapplauncher/WindowsPlatform.cpp
src/jdk.jpackage/windows/native/libapplauncher/WindowsPlatform.h
--- a/src/jdk.jpackage/linux/native/libapplauncher/LinuxPlatform.cpp	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/linux/native/libapplauncher/LinuxPlatform.cpp	Thu Jul 25 08:13:44 2019 -0400
@@ -126,10 +126,6 @@
     return result;
 }
 
-void LinuxPlatform::SetCurrentDirectory(TString Value) {
-    chdir(PlatformString(Value).toPlatformString());
-}
-
 TString LinuxPlatform::GetPackageRootDirectory() {
     TString result;
     TString filename = GetModuleFileName();
--- a/src/jdk.jpackage/linux/native/libapplauncher/LinuxPlatform.h	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/linux/native/libapplauncher/LinuxPlatform.h	Thu Jul 25 08:13:44 2019 -0400
@@ -56,7 +56,6 @@
     virtual TCHAR* ConvertFileSystemStringToString(
             TCHAR* Source, bool &release);
 
-    virtual void SetCurrentDirectory(TString Value);
     virtual TString GetPackageRootDirectory();
     virtual TString GetAppDataDirectory();
     virtual TString GetAppName();
--- a/src/jdk.jpackage/macosx/native/libapplauncher/MacPlatform.h	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/macosx/native/libapplauncher/MacPlatform.h	Thu Jul 25 08:13:44 2019 -0400
@@ -49,7 +49,6 @@
     virtual TCHAR* ConvertFileSystemStringToString(
             TCHAR* Source, bool &release);
 
-    virtual void SetCurrentDirectory(TString Value);
     virtual TString GetPackageRootDirectory();
     virtual TString GetAppDataDirectory();
     virtual TString GetBundledJavaLibraryFileName(TString RuntimePath);
--- a/src/jdk.jpackage/macosx/native/libapplauncher/MacPlatform.mm	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/macosx/native/libapplauncher/MacPlatform.mm	Thu Jul 25 08:13:44 2019 -0400
@@ -198,10 +198,6 @@
     return result;
 }
 
-void MacPlatform::SetCurrentDirectory(TString Value) {
-    chdir(PlatformString(Value).toPlatformString());
-}
-
 TString MacPlatform::GetPackageRootDirectory() {
     NSBundle *mainBundle = [NSBundle mainBundle];
     NSString *mainBundlePath = [mainBundle bundlePath];
--- a/src/jdk.jpackage/share/native/libapplauncher/Platform.h	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/share/native/libapplauncher/Platform.h	Thu Jul 25 08:13:44 2019 -0400
@@ -176,8 +176,6 @@
     virtual MessageResponse ShowResponseMessage(TString title,
            TString description) = 0;
 
-    virtual void SetCurrentDirectory(TString Value) = 0;
-
     // Caller must free result using delete[].
     virtual TCHAR* ConvertStringToFileSystemString(TCHAR* Source,
             bool &release) = 0;
--- a/src/jdk.jpackage/unix/native/libapplauncher/PosixPlatform.cpp	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/unix/native/libapplauncher/PosixPlatform.cpp	Thu Jul 25 08:13:44 2019 -0400
@@ -94,10 +94,6 @@
     return result;
 }
 
-void PosixPlatform::SetCurrentDirectory(TString Value) {
-    chdir(StringToFileSystemString(Value));
-}
-
 Module PosixPlatform::LoadLibrary(TString FileName) {
     return dlopen(StringToFileSystemString(FileName), RTLD_LAZY);
 }
@@ -310,7 +306,9 @@
 
 void PosixProcess::SetInput(TString Value) {
     if (FInputHandle != 0) {
-        write(FInputHandle, Value.data(), Value.size());
+        if (write(FInputHandle, Value.data(), Value.size()) < 0) {
+            throw Exception(_T("Internal Error - write failed"));
+        }
     }
 }
 
--- a/src/jdk.jpackage/unix/native/libapplauncher/PosixPlatform.h	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/unix/native/libapplauncher/PosixPlatform.h	Thu Jul 25 08:13:44 2019 -0400
@@ -44,8 +44,6 @@
     virtual MessageResponse ShowResponseMessage(TString title,
             TString description);
 
-    virtual void SetCurrentDirectory(TString Value);
-
     virtual Module LoadLibrary(TString FileName);
     virtual void FreeLibrary(Module AModule);
     virtual Procedure GetProcAddress(Module AModule, std::string MethodName);
--- a/src/jdk.jpackage/windows/native/libapplauncher/WindowsPlatform.cpp	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/windows/native/libapplauncher/WindowsPlatform.cpp	Thu Jul 25 08:13:44 2019 -0400
@@ -171,10 +171,6 @@
     return NULL;
 }
 
-void WindowsPlatform::SetCurrentDirectory(TString Value) {
-    _wchdir(Value.data());
-}
-
 TString WindowsPlatform::GetPackageRootDirectory() {
     TString result;
     TString filename = GetModuleFileName();
--- a/src/jdk.jpackage/windows/native/libapplauncher/WindowsPlatform.h	Thu Jul 25 08:00:51 2019 -0400
+++ b/src/jdk.jpackage/windows/native/libapplauncher/WindowsPlatform.h	Thu Jul 25 08:13:44 2019 -0400
@@ -47,7 +47,6 @@
     virtual MessageResponse ShowResponseMessage(TString title,
             TString description);
 
-    virtual void SetCurrentDirectory(TString Value);
     virtual TString GetPackageRootDirectory();
     virtual TString GetAppDataDirectory();
     virtual TString GetAppName();