Community
Participate
Working Groups
Created attachment 141358 [details] Screenshot of the offending preference panel Build ID: 20090621-0832 Steps To Reproduce: Context: You have a project that uses @Override on interface implementation methods. This was not allowed in Java 1.5, but is allowed in Java 1.6. You also need to be able to load the resulting classfiles in a Java 1.5 VM. (Example: You are using GWT, and the Java2Javascript compiler is limited to 1.5 classfiles because GWT Hosted Mode is limited to a 32-bit VM, because it uses an older version of SWT on MacOS X that uses the 32-bit Carbon libraries.) 1. Preferences -> Java -> Compiler 2. Set compiler compliance level to 1.6 3. Uncheck "Use default compliance settings" 4. Set "Generated .class files compatibility" to 1.5 5. Note a red error message saying "Classfile compatibility must be greater or equal to source compatibility". The validation that Eclipse is doing here was sensible and relevant when going from Java 1.4 to Java 1.5, because the introduction of Generics in 1.5 required classfile changes that could not load in a Java 1.4 VM. The transition from 1.5 to 1.6, however, need not be this strict. To my knowledge, the only syntactic change in 1.6 was the allowance of @Override on methods that implement an interface. There does not seem to be any corresponding classfile format change that goes along with this. Therefore, in my opinion, this check is too strict. More information:
(In reply to comment #0) > The transition from 1.5 to 1.6, however, need not be this strict. To my > knowledge, the only syntactic change in 1.6 was the allowance of @Override on > methods that implement an interface. There does not seem to be any > corresponding classfile format change that goes along with this. I believe there was still a 50.0 to 51.0 version number change. JDT/Core would know more.
Created attachment 141367 [details] simple test case I have attached a simple test case. From the command line I can compile this code with "javac Test.java -target 1.5" - using the compiler in the 1.6 JDK - and I can run the resulting class using the 1.5 runtime. If I attempt to compile using version 1.5 of javac, on the other hand, it gives the following error: terminator-2:test pohl$ javac Test.java Test.java:8: method does not override a method from its superclass @Override ^ 1 error This proves, to me, that eclipse should be able to accomplish the same that I can do from the command line. It is only the user interface that prevents me from building 1.6 source while targeting a 1.5 class file format.
For the first comment, you need to set the source level to be 1.5 as well. And then you don't get the configuration issue. This is still not enough to fix this issue as we report: ---------- 1. ERROR in D:\tests_sources\X.java (at line 9) public void hello() { ^^^^^^^ The method hello() of type X.MyClass must override a superclass method ---------- I think we need to use the compliance version to report this error instead of the target platform or the source versions.
Created attachment 142695 [details] Proposed fix All tests need to be run.
Kent, please review. It looks like we should use the compliance level instead of the source level to report for @Override being used for implementation of interface methods. I need to run all tests to see if they need to be updated. There is no plan to fix the configuration issue if the source level is not modified. Source cannot be higher than the target version. javac has the same limitation: javac -target 1.5 -source 1.6 X.java fails with: javac: source release 1.6 requires target release 1.6
Released for 3.6M1. Added regression test in: org.eclipse.jdt.core.tests.compiler.regression.Compliance_1_6
Verified for 3.6M1 using I20090803-1800