Skip to content

Commit da4cf05

Browse files
author
Andy Herrick
committed
8258755: jpackage: Invalid 32-bit exe when building app-image
Reviewed-by: asemenyuk, almatvee, kizune
1 parent c3bdbf9 commit da4cf05

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/jdk.jpackage/share/native/applauncher/JvmLauncher.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
#include "Toolbox.h"
3434
#include "ErrorHandling.h"
3535

36+
#if defined(_WIN32) && !defined(_WIN64)
37+
#define LAUNCH_FUNC "_JLI_Launch@56"
38+
#else
39+
#define LAUNCH_FUNC "JLI_Launch"
40+
#endif
3641

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

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

207-
DllFunction<LaunchFuncType> func(Dll(jvmPath), "JLI_Launch");
212+
DllFunction<LaunchFuncType> func(Dll(jvmPath), LAUNCH_FUNC);
208213
int exitStatus = func(argc, argv.data(),
209214
0, 0,
210215
0, 0,

src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixPipeline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private Path compile(WixSource wixSource) throws IOException {
112112
"-nologo",
113113
adjustPath.apply(wixSource.source).toString(),
114114
"-ext", "WixUtilExtension",
115-
"-arch", "x64",
115+
"-arch", WixSourcesBuilder.is64Bit() ? "x64" : "x86",
116116
"-out", wixObj.toAbsolutePath().toString()
117117
));
118118

src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixSourcesBuilder.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ void logWixFeatures() {
157157
}
158158
}
159159

160+
static boolean is64Bit() {
161+
return !("x86".equals(System.getProperty("os.arch")));
162+
}
163+
160164
private void normalizeFileAssociation(FileAssociation fa) {
161165
fa.launcherPath = addExeSuffixToPath(
162166
installedAppImage.launchersDirectory().resolve(fa.launcherPath));
@@ -301,7 +305,7 @@ boolean isFile() {
301305
static void startElement(XMLStreamWriter xml, String componentId,
302306
String componentGuid) throws XMLStreamException, IOException {
303307
xml.writeStartElement("Component");
304-
xml.writeAttribute("Win64", "yes");
308+
xml.writeAttribute("Win64", is64Bit() ? "yes" : "no");
305309
xml.writeAttribute("Id", componentId);
306310
xml.writeAttribute("Guid", componentGuid);
307311
}
@@ -823,7 +827,8 @@ Path getPath(WixSourcesBuilder outer) {
823827

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

826-
private final static Path PROGRAM_FILES = TARGETDIR.resolve("ProgramFiles64Folder");
830+
private final static Path PROGRAM_FILES = TARGETDIR.resolve(
831+
is64Bit() ? "ProgramFiles64Folder" : "ProgramFilesFolder");
827832

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

0 commit comments

Comments
 (0)