Bug 301897 - NPE creating a new launching configuration (Simple JUnit test)
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java
index 9b3e066..c599b3a 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaJRETab.java
@@ -257,41 +257,45 @@
source = LauncherMessages.JavaJRETab_4;
}
IPath vmPath = fJREBlock.getPath();
- IVMInstall vm = null;
- if(JavaRuntime.newDefaultJREContainerPath().equals(vmPath)) {
- if(javaProject.isOpen()) {
- try {
- vm = JavaRuntime.getVMInstall(getJavaProject());
- } catch (CoreException e) {
- JDIDebugUIPlugin.log(e);
- return Status.OK_STATUS;
- }
- if(vm == null) {
- vm = JavaRuntime.getVMInstall(vmPath);
- }
- }
- }
- else {
- vm = JavaRuntime.getVMInstall(vmPath);
- }
- String environmentId = JavaRuntime.getExecutionEnvironmentId(vmPath);
- if(vm instanceof AbstractVMInstall) {
- AbstractVMInstall install = (AbstractVMInstall) vm;
- String vmver = install.getJavaVersion();
- if(vmver != null) {
- int val = compliance.compareTo(vmver);
- if(val > 0) {
- String setting = null;
- if (environmentId == null) {
- setting = LauncherMessages.JavaJRETab_2;
- } else {
- setting = LauncherMessages.JavaJRETab_1;
+ if (vmPath != null) {
+ IVMInstall vm = null;
+ if(JavaRuntime.newDefaultJREContainerPath().equals(vmPath)) {
+ if(javaProject.isOpen()) {
+ try {
+ vm = JavaRuntime.getVMInstall(getJavaProject());
+ } catch (CoreException e) {
+ JDIDebugUIPlugin.log(e);
+ return Status.OK_STATUS;
}
- return new Status(IStatus.ERROR, IJavaDebugUIConstants.PLUGIN_ID, IStatus.ERROR, MessageFormat.format(LauncherMessages.JavaJRETab_0, new String[] {setting, source, compliance}), null);
+ if(vm == null) {
+ vm = JavaRuntime.getVMInstall(vmPath);
+ }
}
}
+ else {
+ vm = JavaRuntime.getVMInstall(vmPath);
+ }
+ String environmentId = JavaRuntime.getExecutionEnvironmentId(vmPath);
+ if(vm instanceof AbstractVMInstall) {
+ AbstractVMInstall install = (AbstractVMInstall) vm;
+ String vmver = install.getJavaVersion();
+ if(vmver != null) {
+ int val = compliance.compareTo(vmver);
+ if(val > 0) {
+ String setting = null;
+ if (environmentId == null) {
+ setting = LauncherMessages.JavaJRETab_2;
+ } else {
+ setting = LauncherMessages.JavaJRETab_1;
+ }
+ return new Status(IStatus.ERROR, IJavaDebugUIConstants.PLUGIN_ID, IStatus.ERROR, MessageFormat.format(LauncherMessages.JavaJRETab_0, new String[] {setting, source, compliance}), null);
+ }
+ }
+ }
+ return Status.OK_STATUS;
}
- return Status.OK_STATUS;
+ // when no VM path is specified return the error status from the JRE block
+ return fJREBlock.getStatus();
}
/**
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java
index 36b5dab..00e8374 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -45,6 +45,14 @@
public static String JREsComboBlock_1;
+ public static String JREsComboBlock_10;
+
+ public static String JREsComboBlock_11;
+
+ public static String JREsComboBlock_12;
+
+ public static String JREsComboBlock_13;
+
public static String JREsComboBlock_2;
public static String JREsComboBlock_3;
public static String JREsComboBlock_15;
@@ -171,6 +179,14 @@
public static String JREsComboBlock_14;
+ public static String JREsComboBlock_6;
+
+ public static String JREsComboBlock_7;
+
+ public static String JREsComboBlock_8;
+
+ public static String JREsComboBlock_9;
+
public static String InstalledJREsBlock_19;
public static String LibraryLabelProvider_0;
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties
index eb32e33..26325c0 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2009 IBM Corporation and others.
+# Copyright (c) 2000, 2010 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -36,6 +36,10 @@
InstalledJREsBlock_19={0} (locked)
JREsComboBlock_1=Alternate &JRE:
+JREsComboBlock_10=JRE name not specified for JRE type: {0}
+JREsComboBlock_11=Unable to resolve JRE: {0} ({1})
+JREsComboBlock_12=JRE home directory not specified
+JREsComboBlock_13=JRE home directory does not exist
JREsComboBlock_14=Envir&onments...
JREsComboBlock_15={0} ({1})
JREsComboBlock_16={0} (unbound)
@@ -44,6 +48,10 @@
JREsComboBlock_0=No JREs defined in workspace
JREsComboBlock_4=E&xecution environment:
JREsComboBlock_5=No execution environments defined in workspace
+JREsComboBlock_6=Unknown execution environment specified: {0}
+JREsComboBlock_7=No JREs in workspace compatible with specified execution environment: {0}
+JREsComboBlock_8=JRE type not specified
+JREsComboBlock_9=Unknown JRE type specified: {0}
StandardVMPage_0=Add Standard VM
StandardVMPage_1=JRE Definition
StandardVMPage_2=Specify attributes for a JRE
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java
index 685ff2b..cbf4a82 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/JREsComboBlock.java
@@ -610,12 +610,12 @@
if (environment == null) {
fErrorPath = containerPath;
selectEnvironment(environment);
- setError(MessageFormat.format("Unknown execution environment specified: {0}", new String[]{envId})); //$NON-NLS-1$
+ setError(MessageFormat.format(JREMessages.JREsComboBlock_6, new String[]{envId}));
} else {
selectEnvironment(environment);
IVMInstall[] installs = environment.getCompatibleVMs();
if (installs.length == 0) {
- setError(MessageFormat.format("No JREs in workspace compatible with specified execution environment: {0}", new String[]{environment.getId()})); //$NON-NLS-1$
+ setError(MessageFormat.format(JREMessages.JREsComboBlock_7, new String[]{environment.getId()}));
}
}
} else {
@@ -625,17 +625,17 @@
fErrorPath = containerPath;
String installTypeId = JavaRuntime.getVMInstallTypeId(containerPath);
if (installTypeId == null) {
- setError("JRE type not specified"); //$NON-NLS-1$
+ setError(JREMessages.JREsComboBlock_8);
} else {
IVMInstallType installType = JavaRuntime.getVMInstallType(installTypeId);
if (installType == null) {
- setError(MessageFormat.format("Unknown JRE type specified: {0}", new String[]{installTypeId})); //$NON-NLS-1$
+ setError(MessageFormat.format(JREMessages.JREsComboBlock_9, new String[]{installTypeId}));
} else {
String installName = JavaRuntime.getVMInstallName(containerPath);
if (installName == null) {
- setError(MessageFormat.format("JRE name not specified for JRE type: {0}", new String[]{installType.getName()})); //$NON-NLS-1$
+ setError(MessageFormat.format(JREMessages.JREsComboBlock_10, new String[]{installType.getName()}));
} else {
- setError(MessageFormat.format("Unable to resolve JRE: {0} ({1})", new String[]{installName, installType.getName()})); //$NON-NLS-1$
+ setError(MessageFormat.format(JREMessages.JREsComboBlock_11, new String[]{installName, installType.getName()}));
}
}
}
@@ -643,9 +643,9 @@
selectJRE(install);
File location = install.getInstallLocation();
if (location == null) {
- setError("JRE home directory not specified"); //$NON-NLS-1$
+ setError(JREMessages.JREsComboBlock_12);
} else if (!location.exists()) {
- setError("JRE home directory does not exist"); //$NON-NLS-1$
+ setError(JREMessages.JREsComboBlock_13);
}
}
}