Bug 355838 - [compiler] ecj compiles the code that javac6 rejects
Summary: [compiler] ecj compiles the code that javac6 rejects
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-25 09:58 EDT by Satyam Kandula CLA
Modified: 2011-10-24 02:25 EDT (History)
4 users (show)

See Also:
srikanth_sankaran: review+


Attachments
proposed fix v1.0 (2.13 KB, patch)
2011-08-26 06:45 EDT, Ayushman Jain CLA
no flags Details | Diff
fix + tests (6.71 KB, patch)
2011-09-29 02:28 EDT, Ayushman Jain CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Satyam Kandula CLA 2011-08-25 09:58:39 EDT
This is a FUP of bug 317719. This is the test that Ayush mentioned in bug 317719 comment 36. I have modified the code to use the function too
###########
package p;
import java.util.ArrayList;
import java.util.List;

public class ErasureBug {       

    public String output(List<String> integers) {
        System.out.println("In List<String>");
        return "";   
    }      

    public void output(List doubles) {  
         System.out.println("In List#RawType");
        return; 
    } 
    public static void main(String[] args) {
        new ErasureBug().output(new ArrayList());
    } 
}
########
javac6 gives an error here, but ecj doesn't complain when the project compliance is 1.6.Not giving an error is ok, but in this example, the runtime differ from what is expected otherwise and hence we should better fix it.
If the compiler doesn't report an error, I will expect the call to output which takes the rawtype, but with ecj the call is going to List<String>.
Comment 1 Ayushman Jain CLA 2011-08-26 06:45:33 EDT
Created attachment 202217 [details]
proposed fix v1.0

I believe all's not well with the way we compare erasure of one method against the signature of another. This is because what we actually want to check is that if one method is foo(List<String>), and another is foo(List). erasure of first is foo(List), same as the second foo. But with the current approach when we compare params[index].erasure != params[index] , we actually end up comparing List<E> with List.

This patch tries to fix that. Passes all tests apart from one, which is a dup of the reported case here.
Srikanth, what do you think?
Comment 2 Srikanth Sankaran CLA 2011-09-05 02:30:25 EDT
(In reply to comment #1)
> Created attachment 202217 [details]
> proposed fix v1.0
> 
> I believe all's not well with the way we compare erasure of one method against
> the signature of another. This is because what we actually want to check is
> that if one method is foo(List<String>), and another is foo(List). erasure of
> first is foo(List), same as the second foo. But with the current approach when
> we compare params[index].erasure != params[index] , we actually end up
> comparing List<E> with List.
> 
> This patch tries to fix that. Passes all tests apart from one, which is a dup
> of the reported case here.
> Srikanth, what do you think?

(1) Can you please check whether the unrestored part of code from
https://bugs.eclipse.org/bugs/attachment.cgi?id=146981 (essentially
the changes to MethodBinding.java as others have been restored over
two passes) has any effect on this bug without your patch ? 

(2) Can you check what was eclipse's behavior on this before Kent's
original changes went in ? If things matched javac, why and how ? 
If things didn't match javac, then did it match HEAD without your
patch ?
Comment 3 Ayushman Jain CLA 2011-09-22 13:02:41 EDT
(In reply to comment #2)
> (1) Can you please check whether the unrestored part of code from
> https://bugs.eclipse.org/bugs/attachment.cgi?id=146981 (essentially
> the changes to MethodBinding.java as others have been restored over
> two passes) has any effect on this bug without your patch ? 
No. I tried, but those changes don't have any effect.

> (2) Can you check what was eclipse's behavior on this before Kent's
> original changes went in ? If things matched javac, why and how ? 
> If things didn't match javac, then did it match HEAD without your
> patch ?

I tried 3.5.2 and he behaviour matches the current HEAD behaviour i.e. both are incompatible with javac6.

I still stand by my analysis in comment 1.
Comment 4 Srikanth Sankaran CLA 2011-09-26 05:27:42 EDT
Patch looks ok to me.
Comment 5 Ayushman Jain CLA 2011-09-29 02:28:26 EDT
Created attachment 204248 [details]
fix + tests

Added regression test and updated a previous test to the new behavior (matches javac6 now)
Comment 6 Ayushman Jain CLA 2011-09-29 02:29:19 EDT
Released commit 7cddbfa7d184b903e6606f21236d46be8958fe44 into HEAD for 3.8M3
Comment 7 Srikanth Sankaran CLA 2011-10-24 02:25:06 EDT
Verified for 3.8 M3 using build id: N20111022-2000