Bug 128418 - [1.5][compiler] eclipse doesn't emit unchecked warning
Summary: [1.5][compiler] eclipse doesn't emit unchecked warning
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
: 106325 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-17 09:59 EST by Nikolay Metchev CLA
Modified: 2006-03-28 06:47 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Metchev CLA 2006-02-17 09:59:33 EST
Tested on 3.2 M4

I think that the eclipse compiler has missed a potential problem. In the code below javac complains where the comment indicates with the following error, eclipse seems to think that the code is fine:
------------------------
TestGenerics.java:17: warning: [unchecked] unchecked generic array creation of type java.lang.Iterable<java.lang.Integer>[] for varargs parameter
      this.<Integer>m3(this.<Integer>m(3,3,3,3,3));
                      ^
1 warning
-------------------------
TestGenerics.java
----------------------
import java.util.Arrays;

public class TestGenerics
{
   public <T> Iterable<T> m(T...ts) 
   {
      return Arrays.asList(ts);
   }
   
   public <T> void m3(Iterable<T> ...ts)
   {
   }
   
   public void m2()
   {
      this.<Integer>m3(this.<Integer>m(3,3,3,3,3)); //javac complains here
   }
}
-----------------------------------------
Comment 1 Philipe Mulet CLA 2006-03-06 03:08:28 EST
Added support for varargs parameter generic array creation.
Will now issue:

WARNING in Test.java (at line 15)
	this.<Integer>m3(this.<Integer>m(3,3,3,3,3)); //javac complains here
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety : A generic array of Iterable<Integer> is created for a varargs parameter


Added GenericTypeTest#test0949-0952.
Fixed
Comment 2 Philipe Mulet CLA 2006-03-06 03:17:57 EST
*** Bug 106325 has been marked as a duplicate of this bug. ***
Comment 3 Philipe Mulet CLA 2006-03-07 12:35:43 EST
There is indeed a minor API addition (a new problem ID = constant). 
There is no way this one can be avoided. 

No one could be dependant upon it, since this problem wasn't detected before, though it should have been.

Mike - would you please cast your vote ?

The addition is a new constant field on IProblem
	/** @since 3.2 */
	int UnsafeGenericArrayForVarargs = MethodRelated + 574;
Comment 4 Mike Wilson CLA 2006-03-08 11:56:20 EST
I don't see how this could be a problem. +1. ok to proceed.
Comment 5 David Audel CLA 2006-03-28 06:47:05 EST
Verified for 3.2 M6 using build I20060328-0010