| Summary: | [3.6][compiler][regression] Compiler in 3.6 and 3.6.1 generates bad code | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Claudiu Soroiu <csoroiu+eclipse> | ||||||
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | csoroiu+eclipse, daniel_megert, jarthana, niels, Olivier_Thomann, satyam.kandula, srikanth_sankaran | ||||||
| Version: | 3.6.1 | Flags: | daniel_megert:
pmc_approved+
Olivier_Thomann: review+ |
||||||
| Target Milestone: | 3.6.2 | ||||||||
| Hardware: | PC | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Claudiu Soroiu
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 |