Bug 433416

Summary: Launch configurations can default to an unbound execution environment
Product: [Eclipse Project] PDE Reporter: Thomas Raddatz <thomas.raddatz>
Component: UIAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andreas, curtis.windatt.public, daniel_megert, Lars.Vogel
Version: 4.4Keywords: noteworthy
Target Milestone: 4.4 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Thomas Raddatz CLA 2014-04-24 09:39:44 EDT
Eclipse produces a launch configuration with Java 1.8 when launching an Eclipse application for a plug-in, although Java 1.8 is not installed on the PC and hence is not available for Eclipse.

Tested with:

Version: Luna (4.4)
Build id: N20140423-2200
Comment 1 Curtis Windatt CLA 2014-04-24 10:59:55 EDT
Reproduced.

When creating a project, the default EE is based on the default JRE.

// Set default EE based on strict match to default VM
IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
String[] EEChoices = fEEChoice.getItems();
for (int i = 0; i < EEChoices.length; i++) {
if (!EEChoices[i].equals(NO_EXECUTION_ENVIRONMENT)) {
		if (VMUtil.getExecutionEnvironment(EEChoices[i]).isStrictlyCompatible(defaultVM)) {
			fEEChoice.select(i);
			break;
		}
	}
}

When creating the launch configuration, the default EE is based on the highest bundle required execution environment of any bundle in the launch configuration.  As org.eclipse.jdt.annotation has a BREE of 1.8, 1.8 is chosen as the EE.

One solution would be to skip any EE that is unbound, though that could mean setting an EE that doesn't match your plug-ins, so installing a JRE would not fix your launch configuration.  Would be good to see why jdt.annotation has such a high BREE.
Comment 2 Curtis Windatt CLA 2014-04-24 13:08:29 EDT
http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=20701afb2a9094b1fc905d295c9191bb8075a887
Fixed in master

The key was not to break the feature added in Bug 344633, where we look at the plug-in list to guess what the best EE to choose is.  To do this I ignore bundles that have BREEs that match unbound EEs (no compatible JRE installed).  This doesn't guarantee that the launch configuration will run, but choosing an unbound EE will definitely not launch, so this is better than nothing.

This problem would have become much more noticeable in 4.4 as the jdt annotations bundle in the SDK has a 1.8 BREE.  You don't need to the bundle to launch, but PDE has no practical way of knowing that.
Comment 3 Thomas Raddatz CLA 2014-04-25 04:47:38 EDT
Re-tested today with "Version: Luna (4.4) Build id: N20140424-2000".
Works like a charm, now. Thanks.