Community
Participate
Working Groups
I was trying to understand when the Eclipse compiler generates warnings about raw types. In this example I think all casts to (List)/(Map)should produce a warning, but some don't... package org.example; import java.util.List; import java.util.Map; public class Warning { public static void main(String[] args) { Object object = null; List list = (List)object; // foo((List)object); // This should produce a raw type warning, right? foo((List<?>)object); foo((List<Object>)object); // foo((List<? extends Object>)object); foo((Map)object); // This should produce a raw type warning, right? foo((Map<?, ?>)object); foo((Map<Object, ?>)object); foo((Map<?, Object>)object); foo((Map<Object, Object>)object); // foo((Map<? extends Object, Object>)object); foo((Map<? extends Object, ? extends Object>)object); } public static void foo(List<?> list) { System.out.println("###" + list); } public static void foo(Map<?, ?> map) { System.out.println("###" + map); } } I've marked this as "major" because we are trying to eliminate all warnings in the EMF code and more importantly in the generated code EMF produces so I want to be sure that the current set of warnings are complete that we don't suddenly get new ones when oversights in where to produce warnings are fixed.
Fix is simple, but I remember we actually explicitly disabled the raw type check in cast expression. Due to cast semantics, there would be situations where we would recommend parameterization, and then hit some unchecked cast... Need to investigate if this is still the case nowadays.
Created attachment 54347 [details] Proposed patch
Released for 3.3M4. Fixed Tuned existing tests.
Verified for 3.3M4 with I20061211-1119. 4 raw type warnings are reported.