Community
Participate
Working Groups
HEAD, follow-up to bug 322817 The JavaCore.COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS option misses raw method arguments for a method that has parameterized types as arguments: package problems.unchecked; import java.util.*; public class MyASTNode { List fragments() { return Collections.emptyList(); } } package problems.unchecked; import java.lang.reflect.Array; import java.util.*; public class UncheckedProblem { // no warnings: Integer[] m1(List<Integer> list) { return toArray(list, Integer.class); } Integer[] m2(List list) { // good warning return toArray(list, Integer.class); // good warning } Integer[] m3(MyASTNode node) { // TODO: compiler option should hide this warning: return toArray(node.fragments(), Integer.class); // unavoidable warning } /** * Returns an array containing all of the elements in the given collection. * This is a compile-time type-safe version of * {@link Collection#toArray(Object[])}. * * @param c the source collection * @param clazz the type of the array elements * @param <A> the type of the array elements * @return an array of type <code>A</code> containing all of the elements * in the given collection */ public static <A> A[] toArray(Collection<? extends A> c, Class<A> clazz) { Object array= Array.newInstance(clazz, c.size()); @SuppressWarnings("unchecked") A[] typedArray = c.toArray((A[]) array); return typedArray; } }
This will have to wait a bit as I am busy with other Java 7 related deliverables.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.