Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338552 - COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS misses raw method argument
Summary: COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS misses raw method argument
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-01 11:11 EST by Markus Keller CLA
Modified: 2020-02-17 18:19 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-03-01 11:11:00 EST
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;
    }
}
Comment 1 Srikanth Sankaran CLA 2011-03-31 02:19:08 EDT
This will have to wait a bit as I am busy
with other Java 7 related deliverables.
Comment 2 Eclipse Genie CLA 2020-02-17 18:19:20 EST
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.