Bug 171465

Summary: JavaCore.getDefaultOptions returns incorrect compiler compliance level
Product: [Eclipse Project] JDT Reporter: Kathy Chan <kathy>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: CLOSED INVALID QA Contact:
Severity: major    
Priority: P3 CC: eric_jodet, szhou
Version: 3.2.1   
Target Milestone: 3.2.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Kathy Chan CLA 2007-01-23 16:45:49 EST
Driver:  Eclipse 3.2.1

If I start the workbench with JDK 1.5 and create a Java project, the default JDK compliance level as shown by the UI is 1.5.  When I run the code snippet:

IJavaProject javaProject;
projectJdkComplianceLevel = javaProject.getOption ("org.eclipse.jdt.core.compiler.compliance", false);
defaultJdkComplianceLevel = (String)JavaCore.getDefaultOptions().get("org.eclipse.jdt.core.compiler.compliance");

Here's what I got:

projectJdkcomplianceLevel = null (as expected since it's not set for project) 
defaultJdkComplianceLevel = 1.4 (expected 1.5)

If I "enable project specific setting" and explicitely set compliance level to Java 5.0,

projectJdkcomplianceLevel = 1.5 (as expected) 
defaultJdkComplianceLevel = 1.4 (expected 1.5)

If I run the workbench with JDK 1.4, defaultJdkcomplianceLevel is 1.4 as expected.

Would it be possible to have this problem addressed for Eclipse 3.2.2?
Comment 1 Kathy Chan CLA 2007-01-23 16:50:13 EST
*** Bug 162326 has been marked as a duplicate of this bug. ***
Comment 2 Olivier Thomann CLA 2007-01-23 17:09:56 EST
*** Bug 171467 has been marked as a duplicate of this bug. ***
Comment 3 Olivier Thomann CLA 2007-01-23 17:10:16 EST
*** Bug 171466 has been marked as a duplicate of this bug. ***
Comment 4 Olivier Thomann CLA 2007-01-23 17:20:48 EST
The default should always be 1.4.
Why don't you call this line instead:
defaultJdkComplianceLevel =
(String)JavaCore.getOptions().get("org.eclipse.jdt.core.compiler.compliance");
?

JavaCore.getDefaultOptions() should be used to know what are the default options of JavaCore.
JavaCore.getOptions() reflects the current workspace options.
Could you please use JavaCore.getOptions() and tell me if this is fixing your issue?
Thanks.
Comment 5 Frederic Fusier CLA 2007-01-24 04:59:11 EST
I confirm that JavaCore.getOptions() returns the correct value (ie. 1.5). So, using this method instead getDefaultOptions() will solve the initial problem.

So, close as INVALID (getDefaultOptions() returns a correct value) and reopen original bug to change the code to call the right method or continue the investigation...
Comment 6 Kathy Chan CLA 2007-01-24 11:27:12 EST
Yes.  That fixes the problem.  Thanks for pointing out the correct API to use.