Skip to content

Commit fb97d2b

Browse files
committed
GH-7 prevent NPE when using OpenJDK
1 parent 8f517be commit fb97d2b

File tree

1 file changed

+4
-1
lines changed
  • integrations/eclipse/org.eclipse.visualvm.launcher.common/src/org/eclipse/visualvm/launcher/api

1 file changed

+4
-1
lines changed

integrations/eclipse/org.eclipse.visualvm.launcher.common/src/org/eclipse/visualvm/launcher/api/VisualVMHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
import org.eclipse.visualvm.launcher.preferences.PreferenceConstants;
3939

4040
public final class VisualVMHelper {
41+
private static final String JAVA_VERSION_KEY = "java version";
42+
private static final String OPENJDK_VERSION_KEY = "openjdk version";
43+
4144
private static class SpecVersion {
4245
int major, minor;
4346

@@ -114,7 +117,7 @@ private static String getJavaVersion(InputStream is) throws IOException {
114117
try {
115118
String line;
116119
while ((line = br.readLine()) != null) {
117-
if (line.startsWith("java version")) {
120+
if (line.startsWith(JAVA_VERSION_KEY) || line.startsWith(OPENJDK_VERSION_KEY)) {
118121
int start = line.indexOf("\"");
119122
int end = line.lastIndexOf("\"");
120123
if (start > -1 && end > -1) {

0 commit comments

Comments
 (0)