Bug 338011

Summary: COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS wrongly suppresses constructor parameter type
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr
Version: 3.7   
Target Milestone: 3.7 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch under consideration none

Description Markus Keller CLA 2011-02-23 14:01:08 EST
HEAD

COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS wrongly suppresses problems for raw constructor parameter types. Even if a super constructor needs a raw type, a subclass can still parametrize its constructor.

Here's an example to play with:

package p;
import java.util.Map;
public class A {
    public A(Map m) { }
}

package p;
import java.util.*;
public class C extends A {
    public C(Map m) {
        super(m);
        m.put("one", 1);
    }
    
    public C(Map<String, String> m, boolean b) {
        super(m); // shows that parametrizing the parameter type is no problem 
        new A(m);
        m.put("one", 1);
    }
}
Comment 1 Markus Keller CLA 2011-02-28 13:00:36 EST
The example had an unrelated compile error and didn't tell what was expected. Here's the fixed version:

package p;
import java.util.*;
public class C extends A {
    public C(Map m) { // should warn about raw type m
        super(m);
        m.put("one", 1); // warns about raw method invocation (good)
    }

    public C(Map<String, Integer> m, boolean b) {
        super(m); // shows that parametrizing the parameter type is no problem 
        new A(m);
        m.put("one", 1);
    }
}
Comment 2 Srikanth Sankaran CLA 2011-03-15 05:13:37 EDT
Created attachment 191198 [details]
Patch under consideration
Comment 3 Srikanth Sankaran CLA 2011-03-15 07:40:25 EDT
Released in HEAD for 3.7 M7
Comment 4 Ayushman Jain CLA 2011-04-26 07:12:37 EDT
Verified for 3.7M7 using build I20110425-1800
Comment 5 Ayushman Jain CLA 2011-05-03 07:13:12 EDT
Verified for 3.7RC0 using build I201104028-0848