Bug 165223 - Starting SDK with a 1.6 VM doesn't set the compiler preferences to 6.0
Summary: Starting SDK with a 1.6 VM doesn't set the compiler preferences to 6.0
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M4   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 180944 (view as bug list)
Depends on: 165954
Blocks:
  Show dependency tree
 
Reported: 2006-11-20 16:20 EST by Olivier Thomann CLA
Modified: 2007-04-07 14:17 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2006-11-20 16:20:40 EST
Using HEAD, if I start Eclipse with a 1.5 VM, the compiler preferences defaults are automatically set to 5.0 (compliance, source and target).
If I start with a 1.6 VM, I get a compliance 1.4.
I don't think this is expected.
Comment 1 Martin Aeschlimann CLA 2006-11-21 11:04:45 EST
Darin, you are doing this on startup, no?
Comment 2 Darin Wright CLA 2006-11-21 12:29:27 EST
Martin, we only set 1.5 defaults currently. Should the default settings be similar to those in 1.5, except use the JavaCore.VERSION_1_6 constant? As follows:

options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6);
options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6);
options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6);
options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
Comment 3 Martin Aeschlimann CLA 2006-11-21 13:10:36 EST
That look good to me. Olivier? Maybe jdt.core could add a helper that sets the options for a given compliance. We have this knowledge currently in JavaModelUtil.

	public static void setCompilanceOptions(Map map, String compliance) {
		if (JavaCore.VERSION_1_6.equals(compliance)) {
			map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6);
			map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6);
			map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6);
			map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
			map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
		} else if (JavaCore.VERSION_1_5.equals(compliance)) {
			map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
			map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
			map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
			map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
			map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
		} else if (JavaCore.VERSION_1_4.equals(compliance)) {
			map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
			map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
			map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
			map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING);
			map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING);
		} else if (JavaCore.VERSION_1_3.equals(compliance)) {
			map.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3);
			map.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
			map.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1);
			map.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE);
			map.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE);
		} else {
			throw new IllegalArgumentException("Unsupported compliance: " + compliance); //$NON-NLS-1$
		}
	}
Comment 4 Olivier Thomann CLA 2006-11-21 13:15:39 EST
(In reply to comment #2)
> options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6);
> options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6);
> options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6);
> options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
> options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR);
Yes, these are the right settings.
Comment 5 Olivier Thomann CLA 2006-11-21 13:16:29 EST
(In reply to comment #3)
> That look good to me. Olivier? Maybe jdt.core could add a helper that sets the
> options for a given compliance. We have this knowledge currently in
> JavaModelUtil.
Where would you see this API? JavaCore ?
Comment 6 Martin Aeschlimann CLA 2006-11-21 13:21:55 EST
Yes, JavaCore seems like a good place for this.
Comment 7 Philipe Mulet CLA 2006-11-22 06:24:07 EST
+1 for having an API in JDTCore for configuring on compliance basis.
It could be #setDefaults(complianceLevel)  but, this would only modify the workspace defaults.

What about project specific settings ?

Maybe something rather like:
JavaCore#getDefaultOptions(complianceLevel) ?

This would acknowledge the fact that defaults may vary based on compliance.
Comment 8 Martin Aeschlimann CLA 2006-11-22 06:34:15 EST
We often work with maps, so a map modifying API would be the best to have
   setCompilanceOptions(String compliance, Map map)

or getComplianceOptions(String compliance) would be fine too
-> map.putAll(JavaCore.getComplianceOptions(compliance))

But make sure that the API name makes it clear that this only the 'compliance settings'
setDefault is not clear.

Comment 9 Olivier Thomann CLA 2006-11-26 21:34:38 EST
Darin, any preference?
Comment 10 Darin Wright CLA 2006-11-27 09:06:06 EST
I think the modifying API would work OK:

   setCompilanceOptions(String compliance, Map map)
Comment 11 Olivier Thomann CLA 2006-11-27 14:39:46 EST
Added bug 165954 to take care of the API addition.
A patch is available in bug 165954.
Comment 12 Darin Wright CLA 2006-12-01 17:14:38 EST
Fixed in JavaRuntime.
Comment 13 Darin Wright CLA 2006-12-01 17:14:55 EST
Please verify, Mike.
Comment 14 Michael Rennie CLA 2006-12-04 10:46:10 EST
verified
Comment 15 Frank Cornelissen CLA 2007-02-12 07:19:48 EST
Darin, is there any chance that this gets backported to 3.2.2? 
Comment 16 Darin Wright CLA 2007-04-04 13:15:07 EDT
*** Bug 180944 has been marked as a duplicate of this bug. ***
Comment 17 Philipe Mulet CLA 2007-04-05 05:32:13 EDT
Also feels like something to backport to 3.2 maintenance (without new JDT/Core API there).