java.util.Pair

Rémi Forax forax at univ-mlv.fr
Wed Mar 31 17:04:23 UTC 2010


Le 31/03/2010 17:34, Kevin Bourrillion a écrit :
> On Wed, Mar 31, 2010 at 12:31 AM, Rémi Forax <forax at univ-mlv.fr 
> <mailto:forax at univ-mlv.fr>> wrote:
>
>     In equals, instanceof Pair should be instanceof Pair<?,?>.
>     Pair is a raw type.
>
>
> Tangent: there are those of us who believe javac is quite mistaken to 
> issue a warning on 'instanceof Pair'.

you're not the only one but I think you're wrong.

>  (And even if it were right in theory (which I don't think it is), 
> weren't warnings supposed to be things that would warn you about 
> possible /bugs/?)

possible bug:
the semantics of instanceof Foo and instanceof Foo<?> is different if 
generics will be reified.

Example:
class Foo<T> { }

instanceof Foo<?> and instanceof Foo are equivalent.

Now suppose I change the definition of Foo to:
class Foo<T extends Number> { }

I recompile the class Foo and forget to recompile that code:
Foo<?> foobar = new Foo<String>();

foobar instanceof Foo is ok
but foobar instanceof Foo<?> must raised an IncompatibleClassChangeError.

>
>
> -- 
> Kevin Bourrillion @ Google
> internal: http://goto/javalibraries
> external: http://guava-libraries.googlecode.com
>

Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20100331/8a50587a/attachment.html>


More information about the core-libs-dev mailing list