| Summary: | COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS wrongly suppresses "Unchecked cast" | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> |
| Component: | Core | Assignee: | Markus Keller <markus.kell.r> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | amj87.iitr, anchakrk, daniel_megert, jarthana, john.arthorne, manoj.palat, markus.kell.r, srikanth_sankaran, stephan.herrmann |
| Version: | 3.7 | ||
| Target Milestone: | 4.4 M1 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
This will have to wait a bit as I am busy with other Java 7 related deliverables. (In reply to comment #0) > All casts to E[] and E generate "Type safety: Unchecked cast ..." problems, > and all these problems should stay even if unavoidable problems are > suppressed. These problems cannot be solved by generifying anything. I didn't quite follow your reasoning. You say this class of problems cannot be solved by generifying, but they should not be suppressed as "unavoidable problems". To me "cannot be solved" and "unavoidable" sound like the same thing. Maybe I am just misunderstanding what you are proposing here. (In reply to comment #3) When re-reading the documentation for this option, I found that it misses the important restriction "unavoidable *due to raw APIs*". Filed bug 414033 to explain the reasoning and to fix the docs. That explains it, thanks. Unavoidable really means "unavoidable because I am referring to an API that does not use generics". Note that the latest commit left a dangling
TESTS_NAMES = new String[] { "test338350" };
=> most of the tests are disabled.
I've fixed this via bug 413958 :)
Verified for eclipse-SDK-I20130730-0800. (In reply to comment #7) > Verified for eclipse-SDK-I20130730-0800. which is Eclipse Luna 4.4M1 (In reply to comment #6) > => most of the tests are disabled. Thanks for cleaning up! The tests still ran in the build, since the static initializer in RunComparableTests resets the TestCase.TESTS_* global variables. |
COMPILER_PB_UNAVOIDABLE_GENERIC_TYPE_PROBLEMS wrongly suppresses "Unchecked cast" problems: package xy; import java.lang.reflect.Array; import java.util.List; public class Try<E> { void fooObj() { takeObj((E) Bar.getObject()); takeObj((E) Bar.getArray()); takeObj((E) Array.newInstance(Integer.class, 2)); } void takeObj(E obj) { } void fooArray() { takeArray((E[]) Bar.getArray()); takeArray((E[]) Array.newInstance(Integer.class, 2)); } void takeArray(E[] array) { } <L> void foo(List<L> list) { list.toArray((L[]) Bar.getArray()); list.toArray((L[]) Array.newInstance(Integer.class, 2)); } } package xy; import java.lang.reflect.Array; public class Bar { public static Object getObject() { return new Object(); } public static Object[] getArray() { return (Object[]) Array.newInstance(Integer.class, 2); } } All casts to E[] and E generate "Type safety: Unchecked cast ..." problems, and all these problems should stay even if unavoidable problems are suppressed. These problems cannot be solved by generifying anything.