Community
Participate
Working Groups
Build Identifier: 20100917-0705 Compiler in Eclipse 3.6 and 3.6.1 (tested also with ecj apckage separately) generates bad bytecode for the attached sources. As a side note, the offered source code can be incorporated inside a regression test suite for the compiler. Reproducible: Always Steps to Reproduce: 1. Compile the sources in the attached jar using either ecj 3.6 or ecj 3.6.1 2. run ro.derbederos.eclipse36xfailure.Main 3. you will see that sun jvm 6 b21 (haven't tested with other jvm version) throws the exception: Exception in thread "main" java.lang.NoSuchMethodError: ro.derbederos.ecj36xfailure.AbstractFilterChain.addFirst(Ljava/lang/String;Lro/derbederos/ecj36xfailure/IMessageFilter;)V at ro.derbederos.ecj36xfailure.FilterChainImpl.addFirst(FilterChainImpl.java:1) at ro.derbederos.ecj36xfailure.Main.main(Main.java:7) by running same code compiled with ecj 3.5.1 and 3.5.2 everything is fine (I haven't tested with older versions, but i was using ecj 3.5.1 and 3.5.2 before upgrading to 3.6)
Created attachment 179689 [details] test case to reproduce the problem
i was able to reproduce the bug on windows and linux.
I'll investigate.
The difference with javac is that the addFirst bridge method in FilterChainImpl is not calling the right method: // Method descriptor #96 (Ljava/lang/String;Lp/IMessageFilter;)V // Stack: 3, Locals: 3 public bridge synthetic void addFirst(String arg0, IMessageFilter arg1); 0 aload_0 [this] 1 aload_1 [arg0] 2 aload_2 [arg1] 3 invokespecial AbstractFilterChain.addFirst(String, IMessageFilter) : void [111] 6 return Line numbers: [pc: 0, line: 1] where javac is generating: // Method descriptor #62 (Ljava/lang/String;Lp/IMessageFilter;)V // Stack: 3, Locals: 3 public bridge synthetic void addFirst(String arg0, IMessageFilter arg1); 0 aload_0 [this] 1 aload_1 [arg0] 2 aload_2 [arg1] 3 invokespecial AbstractFilterChain.addFirst(String, Object) : void [25] 6 return Line numbers: [pc: 0, line: 5] AbstractFilterChain is only defining: ` // Method descriptor #75 (Ljava/lang/String;Ljava/lang/Object;)V // Signature: (Ljava/lang/String;TT;)V // Stack: 4, Locals: 3 public void addFirst(String arg0, Object arg1); 0 aload_0 [this] 1 aload_1 [arg0] 2 invokespecial AbstractFilterChain.checkFilter(String) : void [26] 5 aload_0 [this] 6 aload_0 [this] 7 getfield AbstractFilterChain.head : AbstractFilterChain.Node [5] 10 aload_1 [arg0] 11 aload_2 [arg1] 12 invokespecial AbstractFilterChain.registerFilter(AbstractFilterChain$Node, String, Object) : void [28] 15 return Line numbers: [pc: 0, line: 96] [pc: 5, line: 97] [pc: 15, line: 98] so we must generate the resolve signature to point to addFirst(Ljava/lang/String;Ljava/lang/Object;)V.
Reduced single file test case: public class X extends Y<I> implements I { public static void main(String[] args) { ((I) new X()).foo(null); } } interface I { public void foo(I i); } abstract class Y<T> { public void foo(T t) {} } ----------------- Under investigation.
Interestingly, both the original test case and the abbreviated test case pass alright on 1.5 compliance and fail only with 1.6 mode.
Likely a side effect of bug 288658. See that the problem goes away if AbstractFilterChain is public instead of being package private.
Created attachment 181378 [details] Patch under test This patch fixes the problem. Under test. Basically the target of the bridge method introduced by the fix for bug 288658 is incorrect in case of the inherited method using type parameters and such. We should be bridging to the "original" method in this case.
All tests pass. Olivier, please review. Do you want this for 3.6.2 ?
Released in HEAD for 3.7 M3 Will decide about 3.6.2 after code review.
(In reply to comment #9) > All tests pass. Olivier, please review. Do you want this for 3.6.2 ? Patch looks good and since there is no good workaround and the code doesn't run with it, yes I would be tempted to release into 3.6.2. Daniel ?
Released in 3.6.x maintenance stream for 3.6.2
Verified for 3.7M3 using build I20101025-0901
Verified for 3.6.2 RC2 using build M20110119-0834