Skip to content

Commit

Permalink
8258755: jpackage: Invalid 32-bit exe when building app-image
Browse files Browse the repository at this point in the history
Reviewed-by: asemenyuk, almatvee, kizune
  • Loading branch information
Andy Herrick committed Jan 16, 2021
1 parent c3bdbf9 commit da4cf05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/jdk.jpackage/share/native/applauncher/JvmLauncher.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#include "Toolbox.h" #include "Toolbox.h"
#include "ErrorHandling.h" #include "ErrorHandling.h"


#if defined(_WIN32) && !defined(_WIN64)
#define LAUNCH_FUNC "_JLI_Launch@56"
#else
#define LAUNCH_FUNC "JLI_Launch"
#endif


Jvm& Jvm::initFromConfigFile(const CfgFile& cfgFile) { Jvm& Jvm::initFromConfigFile(const CfgFile& cfgFile) {
const CfgFile::Properties& appOptions = cfgFile.getProperties( const CfgFile::Properties& appOptions = cfgFile.getProperties(
Expand Down Expand Up @@ -204,7 +209,7 @@ void Jvm::launch() {


LOG_TRACE(tstrings::any() << "JVM library: \"" << jvmPath << "\""); LOG_TRACE(tstrings::any() << "JVM library: \"" << jvmPath << "\"");


DllFunction<LaunchFuncType> func(Dll(jvmPath), "JLI_Launch"); DllFunction<LaunchFuncType> func(Dll(jvmPath), LAUNCH_FUNC);
int exitStatus = func(argc, argv.data(), int exitStatus = func(argc, argv.data(),
0, 0, 0, 0,
0, 0, 0, 0,
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private Path compile(WixSource wixSource) throws IOException {
"-nologo", "-nologo",
adjustPath.apply(wixSource.source).toString(), adjustPath.apply(wixSource.source).toString(),
"-ext", "WixUtilExtension", "-ext", "WixUtilExtension",
"-arch", "x64", "-arch", WixSourcesBuilder.is64Bit() ? "x64" : "x86",
"-out", wixObj.toAbsolutePath().toString() "-out", wixObj.toAbsolutePath().toString()
)); ));


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ void logWixFeatures() {
} }
} }


static boolean is64Bit() {
return !("x86".equals(System.getProperty("os.arch")));
}

private void normalizeFileAssociation(FileAssociation fa) { private void normalizeFileAssociation(FileAssociation fa) {
fa.launcherPath = addExeSuffixToPath( fa.launcherPath = addExeSuffixToPath(
installedAppImage.launchersDirectory().resolve(fa.launcherPath)); installedAppImage.launchersDirectory().resolve(fa.launcherPath));
Expand Down Expand Up @@ -301,7 +305,7 @@ boolean isFile() {
static void startElement(XMLStreamWriter xml, String componentId, static void startElement(XMLStreamWriter xml, String componentId,
String componentGuid) throws XMLStreamException, IOException { String componentGuid) throws XMLStreamException, IOException {
xml.writeStartElement("Component"); xml.writeStartElement("Component");
xml.writeAttribute("Win64", "yes"); xml.writeAttribute("Win64", is64Bit() ? "yes" : "no");
xml.writeAttribute("Id", componentId); xml.writeAttribute("Id", componentId);
xml.writeAttribute("Guid", componentGuid); xml.writeAttribute("Guid", componentGuid);
} }
Expand Down Expand Up @@ -823,7 +827,8 @@ Path getPath(WixSourcesBuilder outer) {


private final static Path DESKTOP_PATH = TARGETDIR.resolve("DesktopFolder"); private final static Path DESKTOP_PATH = TARGETDIR.resolve("DesktopFolder");


private final static Path PROGRAM_FILES = TARGETDIR.resolve("ProgramFiles64Folder"); private final static Path PROGRAM_FILES = TARGETDIR.resolve(
is64Bit() ? "ProgramFiles64Folder" : "ProgramFilesFolder");


private final static Path LOCAL_PROGRAM_FILES = TARGETDIR.resolve("LocalAppDataFolder"); private final static Path LOCAL_PROGRAM_FILES = TARGETDIR.resolve("LocalAppDataFolder");


Expand Down

1 comment on commit da4cf05

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.