Details
-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b12
-
unknown
-
generic
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2215205 | 7u4 | Dmeetry Degrave | P3 | Closed | Fixed | b02 |
Description
This program:
import java.util.ArrayList;
import java.util.List;
class X {
@SafeVarargs
static void m(List<String>... ls) {
Object[] o = ls; // 2 warning here
o[0] = new ArrayList<Integer>();
System.out.println(o);
}
}
Generates two 'varargs' warnings when compiled with the -Xlint:varargs flag enabled.
OUTPUT:
Test.java:7: warning: [varargs] Varargs method could cause heap pollution from non-reifiable varargs parameter ls
Object[] o = ls; // 2 warning here
^
Test.java:7: warning: [varargs] Varargs method could cause heap pollution from non-reifiable varargs parameter ls
Object[] o = ls; // 2 warning here
^
2 warnings
import java.util.ArrayList;
import java.util.List;
class X {
@SafeVarargs
static void m(List<String>... ls) {
Object[] o = ls; // 2 warning here
o[0] = new ArrayList<Integer>();
System.out.println(o);
}
}
Generates two 'varargs' warnings when compiled with the -Xlint:varargs flag enabled.
OUTPUT:
Test.java:7: warning: [varargs] Varargs method could cause heap pollution from non-reifiable varargs parameter ls
Object[] o = ls; // 2 warning here
^
Test.java:7: warning: [varargs] Varargs method could cause heap pollution from non-reifiable varargs parameter ls
Object[] o = ls; // 2 warning here
^
2 warnings
Attachments
Issue Links
- backported by
-
JDK-2215205 Project Coin: duplicate varargs warnings on method annotated with @SafeVarargs
-
- Closed
-