raw types warnings and instanceof

Rémi Forax forax at univ-mlv.fr
Mon Nov 3 02:37:03 PST 2008


Martin Buchholz a écrit :
> Hi javac maintainers,
>
> This is a bug report, sort of.
>
> Thanks for adding the raw types warnings, but...
>
> they currently warn about
> x instanceof RAW-TYPE
> when they probably should not.
>
> It is very common to do
>
> void f (Foo<T> x) {
>   if (x instanceof Bar) {
>     Bar<T> y = (Bar<T>) x;
>     ....
>
> The workaround is to do:
>
> void f (Foo<T> x) {
>   if (x instanceof Bar<?>) {
>     Bar<T> y = (Bar<T>) x;
>     ....
>
> but the addition of <?> adds noise without providing any safety.
>   
+1.
> Martin
>   
Rémi



More information about the compiler-dev mailing list