mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Switch Boot JDK action: runtime bitness is detected incorrectrly on Windows
This commit is contained in:
@@ -163,8 +163,8 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware {
|
||||
if (selectedBundle == null) {
|
||||
throw new Exception("Invalid JDK bundle!");
|
||||
}
|
||||
if (selectedBundle.getBitness() != (SystemInfo.is64Bit ? Bitness.x64 : Bitness.x32)) {
|
||||
throw new Exception("JDK arch mismatch! Expected: " + SystemInfo.OS_ARCH);
|
||||
if (selectedBundle.getBitness() != JdkBundle.runtimeBitness) {
|
||||
throw new Exception("JDK arch mismatch! Your IDE's arch is " + JdkBundle.runtimeBitness);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,6 +41,10 @@ public class JdkBundle {
|
||||
@NotNull
|
||||
private static final Pattern ARCH_64_BIT_PATTERN = Pattern.compile(".*64-Bit.*", Pattern.MULTILINE);
|
||||
|
||||
@NotNull public static final Bitness runtimeBitness = is64BitJVM(System.getProperty("java.vm.name")) ? Bitness.x64 : Bitness.x32;
|
||||
|
||||
private static boolean is64BitRuntime() { return runtimeBitness == Bitness.x64; }
|
||||
|
||||
@NotNull private File myBundleAsFile;
|
||||
@NotNull private String myBundleName;
|
||||
@Nullable private Pair<Version, Integer> myVersionUpdate;
|
||||
@@ -86,7 +90,7 @@ public class JdkBundle {
|
||||
if (nameArchVersionAndUpdate.first.second == null) {
|
||||
return null; // Skip unknown arch
|
||||
}
|
||||
if (matchArch && nameArchVersionAndUpdate.first.second != SystemInfo.is64Bit) {
|
||||
if (matchArch && nameArchVersionAndUpdate.first.second != is64BitRuntime()) {
|
||||
return null; // Skip incompatible arch
|
||||
}
|
||||
|
||||
@@ -97,7 +101,7 @@ public class JdkBundle {
|
||||
|
||||
JdkBundle bundle = new JdkBundle(jvm, nameArchVersionAndUpdate.first.first, nameArchVersionAndUpdate.second, boot, bundled);
|
||||
// init already computed bitness
|
||||
bundle.bitness = nameArchVersionAndUpdate.first.second == SystemInfo.is64Bit ? Bitness.x64 : Bitness.x32;
|
||||
bundle.bitness = nameArchVersionAndUpdate.first.second ? Bitness.x64 : Bitness.x32;
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@@ -154,7 +158,7 @@ public class JdkBundle {
|
||||
String homeSubPath = SystemInfo.isMac ? "Contents/Home" : "";
|
||||
Pair<Pair<String, Boolean>, Pair<Version, Integer>> nameArchVersionAndUpdate = getJDKNameArchVersionAndUpdate(getAbsoluteLocation(), homeSubPath);
|
||||
assert nameArchVersionAndUpdate.first.second != null;
|
||||
bitness = nameArchVersionAndUpdate.first.second == SystemInfo.is64Bit ? Bitness.x64 : Bitness.x32;
|
||||
bitness = nameArchVersionAndUpdate.first.second ? Bitness.x64 : Bitness.x32;
|
||||
}
|
||||
return bitness;
|
||||
}
|
||||
@@ -212,8 +216,7 @@ public class JdkBundle {
|
||||
versionAndUpdate = VersionUtil.parseVersionAndUpdate(versionLine, VERSION_UPDATE_PATTERNS);
|
||||
displayVersion = versionLine.replaceFirst("\".*\"", "");
|
||||
if (outputLines.size() >= 3) {
|
||||
String archLine = outputLines.get(2);
|
||||
is64Bit = ARCH_64_BIT_PATTERN.matcher(archLine).find();
|
||||
is64Bit = is64BitJVM(outputLines.get(2));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -223,6 +226,10 @@ public class JdkBundle {
|
||||
return Pair.create(Pair.create(displayVersion, is64Bit), versionAndUpdate);
|
||||
}
|
||||
|
||||
private static boolean is64BitJVM(String archLine) {
|
||||
return ARCH_64_BIT_PATTERN.matcher(archLine).find();
|
||||
}
|
||||
|
||||
public boolean isBundled() {
|
||||
return myBundled;
|
||||
}
|
||||
|
||||
@@ -17,5 +17,20 @@ package com.intellij.openapi.util;
|
||||
|
||||
/**
|
||||
* @author egor
|
||||
* @author tav
|
||||
*/
|
||||
public enum Bitness {x32, x64}
|
||||
public enum Bitness {
|
||||
x32("x86"),
|
||||
x64("x64");
|
||||
|
||||
private final String value;
|
||||
|
||||
Bitness(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user