Bug 275713 - When JDK Compliance 1.5 and JRE is Java 6, Java 6 only functions are allowed
Summary: When JDK Compliance 1.5 and JRE is Java 6, Java 6 only functions are allowed
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Linux-GTK
: P3 normal with 1 vote (vote)
Target Milestone: 3.5 RC2   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-11 15:00 EDT by Stephen McCants CLA
Modified: 2009-05-22 10:29 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen McCants CLA 2009-05-11 15:00:04 EDT
Build ID: I20090430-2300

Steps To Reproduce:
1. Set you JDK Compliance to 1.5 in the preferences
2. Verify it in the project properties for a Plugin Project
3. Set the "Installed JREs" to a Java 1.6 JRE only in the preferences (no other JREs should be available)
4. In the project, create a class and type "new String().isEmpty();".  This should be flagged as non-compliant with Java 1.5, but won't be as it compiles with Java 1.6.


More information:
I'm not sure if the project must be a plugin project or not.
I'm not sure if this works with other compliance levels and JRE combinations.
I'm not sure if it works with other JREs installed, but not set to default.
Comment 1 Olivier Thomann CLA 2009-05-16 17:54:43 EDT
The compiler is using what is available on the classpath. There is no validation of method, types, fields to check if they match the corresponding compliance.

If you want that check to be done, you can set up your bundle to use API Tooling and active the library usage compatibility.
Comment 2 Bryan Hunt CLA 2009-05-18 15:08:28 EDT
(In reply to comment #1)
> The compiler is using what is available on the classpath. There is no
> validation of method, types, fields to check if they match the corresponding
> compliance.
> 

If that is the case, then what is the JDK Compliance preference for?
Comment 3 Olivier Thomann CLA 2009-05-19 08:58:57 EDT
JDK compliance indicates how the compiler is behaving.
Compliance 1.3 means that the eclipse compiler behaves (name lookup, declaring class for method invocations, ...) like javac 1.3.
Compliance 1.4 => behaves like javac 1.4,
...

In term of library usage, the eclipse compiler is using the libraries on the classpath. In your case you explicitly set the library to be 1.6 libraries even if the compliance is 1.5.

Closing as INVALID as this is working as designed.
Comment 4 Olivier Thomann CLA 2009-05-22 10:29:21 EDT
Verified for 3.5RC2 using I20090521-2000.