Community
Participate
Working Groups
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?
*** Bug 162326 has been marked as a duplicate of this bug. ***
*** Bug 171467 has been marked as a duplicate of this bug. ***
*** Bug 171466 has been marked as a duplicate of this bug. ***
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.
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...
Yes. That fixes the problem. Thanks for pointing out the correct API to use.