Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337795

Summary: [1.7][compiler] Missing unchecked warning at varargs method/ctor declaration site
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, satyam.kandula, stephan.herrmann
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch under test none

Description Srikanth Sankaran CLA 2011-02-22 03:26:32 EST
import java.util.List;
public class X {
   public static void main( String[] args ) {
      String arg = "SUCCESS";
      List<String> ls = Y.asList(arg, arg);
      System.out.println (ls);
   }
}
class Y {
	public static <T> List<T> asList(T ... a) {
		return null;
	}
}


The program above does not elicit any warnings when compiled with
1.5 and 1.6 javac. 1.7 compiler produces the newly mandated warning
as shown below.

C:\jtests>C:\jdk-7-ea-bin-b127-windows-i586-27_jan_2011\jdk7\jdk1.7.0\bin\javac
-Xlint:unchecked -Xlint:rawtypes -Xlint:deprecation -sourcepath c:\jtests X.java

X.java:11: warning: [unchecked] Possible heap pollution from parameterized varar
g type T
        public static <T> List<T> asList(T ... a) {
                                               ^
  where T is a type-variable:
    T extends Object declared in method <T>asList(T...)
1 warning

This warning is missing from eclipse on the same code compiled with
1.7 mode.
Comment 1 Srikanth Sankaran CLA 2011-02-22 03:30:56 EST
I'll follow up on this.
Comment 2 Srikanth Sankaran CLA 2011-02-23 05:57:34 EST
Created attachment 189584 [details]
Patch under test
Comment 3 Srikanth Sankaran CLA 2011-02-23 07:46:48 EST
Fix released in BETA_JAVA7 branch only.
Comment 4 Stephan Herrmann CLA 2011-06-30 09:08:47 EDT
Verified using patch feature 1.0.0-20110623-0900