Le 31/03/2010 17:34, Kevin Bourrillion a écrit :
On Wed, Mar 31, 2010 at 12:31 AM, Rémi Forax <fo...@univ-mlv.fr
<mailto:fo...@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