Community
Participate
Working Groups
For this code. % cat Test.java public abstract class Test { public abstract Object getProperty(final Object src, final String name); public <T> T getTheProperty(final Object src, final String name) { final T val = (T) getProperty(src, name); // this gives erroneous cast warning return val; } } <<< The marked line gives. Severity Description Resource In Folder Location Creation Time 1 Unnecessary cast from Object to T Test.java line 78 November 17, 2004 3:26:30 PM Now clearly the cast is required here - because the type is unknown.
Same issue as bug 78591, different symptoms. Added GenericTypeTest#test444 *** This bug has been marked as a duplicate of 78591 ***
Note: If unchecked/unsafe type operation warnings are enabled, you will now get a warning when casting to a type parameter: Type safety: The cast from Object to T is actually checking against the erased type Object
Test is actually: test445.