diff --git a/DevGuide.md b/DevGuide.md
index a1e95bbd9b..4242a01da2 100644
--- a/DevGuide.md
+++ b/DevGuide.md
@@ -6,7 +6,7 @@ The following is a list of dependencies, in no particular order.
This guide includes instructions for obtaining many of these at the relevant step(s).
You may not need all of these, depending on which portions you are building or developing.
-* Java JDK 11 - Free long term support (LTS) versions of JDK 11 are provided by:
+* Java JDK 11 (64-bit) - Free long term support (LTS) versions of JDK 11 are provided by:
- AdoptOpenJDK
- https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=hotspot
- Amazon Corretto
diff --git a/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java b/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java
index 9748fae528..f4ad7e4252 100644
--- a/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java
+++ b/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java
@@ -224,10 +224,11 @@ public class LaunchSupport {
javaRange = min + "-" + max;
}
- System.out.println("*******************************************************");
+ System.out.println("******************************************************************");
System.out.println(
- javaName + " " + javaRange + " could not be found and must be manually chosen!");
- System.out.println("*******************************************************");
+ javaName + " " + javaRange + " (" + javaConfig.getSupportedArchitecture() +
+ "-bit) could not be found and must be manually chosen!");
+ System.out.println("******************************************************************");
File javaHomeDir = null;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
@@ -259,7 +260,7 @@ public class LaunchSupport {
}
System.out.println(
"Java version " + javaVersion + " is outside of supported range: [" +
- javaRange + "]");
+ javaRange + " " + javaConfig.getSupportedArchitecture() + "-bit]");
}
catch (FileNotFoundException e) {
System.out.println(
diff --git a/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaConfig.java b/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaConfig.java
index 1919075a43..c6ebc5791c 100644
--- a/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaConfig.java
+++ b/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaConfig.java
@@ -84,6 +84,16 @@ public class JavaConfig {
return maxSupportedJava;
}
+ /**
+ * Gets the Java configuration's supported Java architecture. All supported Java
+ * configurations must have an architecture of 64.
+ *
+ * @return The Java configuration's supported Java architecture (64).
+ */
+ public int getSupportedArchitecture() {
+ return 64;
+ }
+
/**
* Gets the Java configuration's compiler compliance level that was used to build the
* associated installation.
@@ -161,6 +171,10 @@ public class JavaConfig {
* @return True if the given Java version is supported by this Java launch configuration.
*/
public boolean isJavaVersionSupported(JavaVersion javaVersion) {
+ if (javaVersion.getArchitecture() != getSupportedArchitecture()) {
+ return false;
+ }
+
int major = javaVersion.getMajor();
return major >= minSupportedJava &&
(maxSupportedJava == 0 || major <= maxSupportedJava);
@@ -229,29 +243,34 @@ public class JavaConfig {
*/
private JavaVersion runAndGetJavaVersion(File javaExecutable)
throws ParseException, IOException {
- Runtime rt = Runtime.getRuntime();
- Process proc = rt.exec(new String[] { javaExecutable.getAbsolutePath(), "-version" });
+ String version = "";
+ String arch = "";
+ Process proc = Runtime.getRuntime().exec(new String[] { javaExecutable.getAbsolutePath(),
+ "-XshowSettings:properties", "-version" });
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(proc.getErrorStream()))) {
String line;
- while ((line = reader.readLine()) != null) {
+ while ((version.isEmpty() || arch.isEmpty()) && (line = reader.readLine()) != null) {
line = line.trim();
-
- // If the _JAVA_OPTIONS or JAVA_TOOL_OPTIONS environment variables are set, STDERR
- // will start with "Picked up..." lines that need to be ignored so we can get to the
- // java version line.
- if (line.startsWith("Picked up")) {
- continue;
- }
- String[] parts = line.split("\\s");
- if (parts.length < 3) {
- throw new ParseException("Failed to parse version: " + line, 0);
+ String searchString = "java.version = ";
+ if (line.startsWith(searchString)) {
+ version = line.substring(searchString.length());
+ }
+
+ searchString = "sun.arch.data.model = ";
+ if (line.startsWith(searchString)) {
+ arch = line.substring(searchString.length());
}
- return new JavaVersion(parts[2]);
}
+ }
+ if (version.isEmpty()) {
throw new ParseException("Failed to find Java version", 0);
}
+ if (arch.isEmpty()) {
+ throw new ParseException("Failed to find Java architecture", 0);
+ }
+ return new JavaVersion(version, arch);
}
/**
diff --git a/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaVersion.java b/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaVersion.java
index 69149ef57e..98efaa4f9f 100644
--- a/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaVersion.java
+++ b/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/JavaVersion.java
@@ -19,22 +19,29 @@ import java.text.ParseException;
/**
* Class to more conveniently represent a Java version string.
+ *
+ * Note: this class has a natural ordering that is inconsistent with equals
+ * (the architecture part of the version is disregarded in the
+ * {@link #compareTo(JavaVersion)} method).
*/
public class JavaVersion implements Comparable