--- old/src/jdk.jpackage/share/native/libapplauncher/Platform.h 2019-02-14 18:09:02.568938600 -0800 +++ new/src/jdk.jpackage/share/native/libapplauncher/Platform.h 2019-02-14 18:09:00.623744100 -0800 @@ -26,7 +26,10 @@ #ifndef PLATFORM_H #define PLATFORM_H +#include "PlatformDefs.h" +#include "Properties.h" #include "OrderedMap.h" +#include "Library.h" #include #include @@ -35,85 +38,9 @@ #include #include #include +#include - -#ifdef WIN32 -#ifndef WINDOWS -#define WINDOWS -#endif -#endif //WIN32 - -#ifdef __APPLE__ -#define MAC -#define POSIX -#endif //__APPLE__ - - -#ifdef __linux -#ifndef LINUX -#define LINUX -#endif -#endif //__linux - -#ifdef LINUX -#define POSIX -#endif //LINUX - - - -#ifdef WINDOWS -// Define Windows compatibility requirements XP or later -#define WINVER 0x0600 -#define _WIN32_WINNT 0x0600 - -#include -#include -#include -#include -#include -#include - -typedef std::wstring TString; -#define StringLength wcslen - -#define TRAILING_PATHSEPARATOR '\\' -#define BAD_TRAILING_PATHSEPARATOR '/' -#define PATH_SEPARATOR ';' -#define BAD_PATH_SEPARATOR ':' - -typedef ULONGLONG TPlatformNumber; -typedef DWORD TProcessID; - -#endif //WINDOWS - - -#ifdef POSIX -#include -#include -#include -#include -#include - -#define _T(x) x - -typedef char TCHAR; -typedef std::string TString; -#define StringLength strlen - -typedef unsigned long DWORD; - -#define TRAILING_PATHSEPARATOR '/' -#define BAD_TRAILING_PATHSEPARATOR '\\' -#define PATH_SEPARATOR ':' -#define BAD_PATH_SEPARATOR ';' -#define MAX_PATH 1000 - -typedef long TPlatformNumber; -typedef pid_t TProcessID; - -#define HMODULE void* -#endif //POSIX - +using namespace std; // Config file sections #define CONFIG_SECTION_APPLICATION _T("CONFIG_SECTION_APPLICATION") @@ -140,132 +67,20 @@ #define JVM_RUNTIME_KEY _T("JVM_RUNTIME_KEY") #define JPACKAGE_APP_DATA_DIR _T("CONFIG_APP_IDENTIFIER") +struct WideString { + size_t length; + wchar_t* data; - -typedef void* Module; -typedef void* Procedure; - - -template -class Property { -private: - ObjectType* FObject; - -public: - Property() { - FObject = NULL; - } - - void SetInstance(ObjectType* Value) { - FObject = Value; - } - - // To set the value using the set method. - ValueType operator =(const ValueType& Value) { - assert(FObject != NULL); - (FObject->*setter)(Value); - return Value; - } - - // The Property class is treated as the internal type. - operator ValueType() { - assert(FObject != NULL); - return (FObject->*getter)(); - } -}; - -template -class ReadProperty { -private: - ObjectType* FObject; - -public: - ReadProperty() { - FObject = NULL; - } - - void SetInstance(ObjectType* Value) { - FObject = Value; - } - - // The Property class is treated as the internal type. - operator ValueType() { - assert(FObject != NULL); - return (FObject->*getter)(); - } -}; - -template -class WriteProperty { -private: - ObjectType* FObject; - -public: - WriteProperty() { - FObject = NULL; - } - - void SetInstance(ObjectType* Value) { - FObject = Value; - } - - // To set the value using the set method. - ValueType operator =(const ValueType& Value) { - assert(FObject != NULL); - (FObject->*setter)(Value); - return Value; - } -}; - -template -class StaticProperty { -public: - StaticProperty() { - } - - // To set the value using the set method. - ValueType operator =(const ValueType& Value) { - (*getter)(Value); - return Value; - } - - // The Property class is treated as the internal type which is the getter. - operator ValueType() { - return (*setter)(); - } -}; - -template -class StaticReadProperty { -public: - StaticReadProperty() { - } - - // The Property class is treated as the internal type which is the getter. - operator ValueType() { - return (*getter)(); - } + WideString() { length = 0; data = NULL; } }; -template -class StaticWriteProperty { -public: - StaticWriteProperty() { - } +struct MultibyteString { + size_t length; + char* data; - // To set the value using the set method. - ValueType operator =(const ValueType& Value) { - (*setter)(Value); - return Value; - } + MultibyteString() { length = 0; data = NULL; } }; - class Process { protected: std::list FOutput; @@ -335,47 +150,6 @@ } }; - -class IPropertyContainer { -public: - IPropertyContainer(void) {} - virtual ~IPropertyContainer(void) {} - - virtual bool GetValue(const TString Key, TString& Value) = 0; - virtual size_t GetCount() = 0; -}; - -class ISectionalPropertyContainer { -public: - ISectionalPropertyContainer(void) {} - virtual ~ISectionalPropertyContainer(void) {} - - virtual bool GetValue(const TString SectionName, - const TString Key, TString& Value) = 0; - virtual bool ContainsSection(const TString SectionName) = 0; - virtual bool GetSection(const TString SectionName, - OrderedMap &Data) = 0; -}; - -class Environment { -private: - Environment() { - } - -public: - static TString GetNewLine() { -#ifdef WINDOWS - return _T("\r\n"); -#endif //WINDOWS -#ifdef POSIX - return _T("\n"); -#endif //POSIX - } - - static StaticReadProperty NewLine; -}; - - enum DebugState {dsNone, dsNative, dsJava}; enum MessageResponse {mrOK, mrCancel}; enum AppCDSState {cdsUninitialized, cdsDisabled, @@ -424,7 +198,7 @@ virtual TString GetPackageRuntimeBinDirectory() = 0; virtual TString GetAppName() = 0; - virtual TString GetConfigFileName() = 0; + virtual TString GetConfigFileName(); virtual TString GetBundledJVMLibraryFileName(TString RuntimePath) = 0; @@ -437,9 +211,6 @@ virtual Module LoadLibrary(TString FileName) = 0; virtual void FreeLibrary(Module Module) = 0; virtual Procedure GetProcAddress(Module Module, std::string MethodName) = 0; - virtual std::vector GetLibraryImports(const TString FileName) = 0; - virtual std::vector FilterOutRuntimeDependenciesForPlatform( - std::vector Imports) = 0; // Caller must free result. virtual Process* CreateProcess() = 0; @@ -449,54 +220,37 @@ // Returns megabytes. virtual TPlatformNumber GetMemorySize() = 0; - virtual std::map GetKeys() = 0; + virtual std::map GetKeys(); - virtual std::list LoadFromFile(TString FileName) = 0; + virtual void InitStreamLocale(wios *stream) = 0; + virtual std::list LoadFromFile(TString FileName); virtual void SaveToFile(TString FileName, - std::list Contents, bool ownerOnly) = 0; + std::list Contents, bool ownerOnly); virtual TString GetTempDirectory() = 0; -#ifdef DEBUG - virtual DebugState GetDebugState() = 0; - virtual int GetProcessID() = 0; - virtual bool IsNativeDebuggerPresent() = 0; -#endif //DEBUG -}; - - -class Library { -private: - std::vector *FDependentLibraryNames; - std::vector *FDependenciesLibraries; - Module FModule; - std::string fname; - - void Initialize(); - void InitializeDependencies(); - void LoadDependencies(); - void UnloadDependencies(); - -public: - void* GetProcAddress(const std::string& MethodName) const; + virtual void addPlatformDependencies(JavaLibrary *pJavaLibrary) = 0; public: - Library(); - Library(const TString &FileName); - ~Library(); + // String helpers + // Caller must free result using delete[]. + static void CopyString(char *Destination, + size_t NumberOfElements, const char *Source); - bool Load(const TString &FileName); - bool Unload(); + // Caller must free result using delete[]. + static void CopyString(wchar_t *Destination, + size_t NumberOfElements, const wchar_t *Source); - const std::string& GetName() const { - return fname; - } + static WideString MultibyteStringToWideString(const char* value); + static MultibyteString WideStringToMultibyteString(const wchar_t* value); - void AddDependency(const TString &FileName); - void AddDependencies(const std::vector &Dependencies); +#ifdef DEBUG + virtual DebugState GetDebugState() = 0; + virtual int GetProcessID() = 0; + virtual bool IsNativeDebuggerPresent() = 0; +#endif //DEBUG }; - class Exception: public std::exception { private: TString FMessage; @@ -516,9 +270,4 @@ TString GetMessage() { return FMessage; } }; -class FileNotFoundException: public Exception { -public: - explicit FileNotFoundException(const TString Message) : Exception(Message) {} -}; - #endif // PLATFORM_H