Thomas said:
{shudder} What they've done IMO is tantamount to saying:
ArrayList of Object<|--- ArrayList of Point <|--- ArrayList of Point3D
I don't like it much myself, but I don't think it's really as bad as all that.
Ugly, yes, but not quite unforgivable.
For one thing it has a practical purpose: without the looser-than-expected
rules, it would not be possible to provide generic array operations like
java.util.Arrays.sort(Object[]).
For another thing, the fact that you -- an experienced Java programmer --
didn't know that this blemish existed is evidence that it doesn't in fact cause
significant problems. And the lack of regular/incessant discussion on the
point in this ng is stronger evidence for the same thing. (Compare the cases
of java.io.InputStream.read(byte[]) and available(), which /do/ cause
problems -- to the point of tedium.)
Perhaps you would find it less bothersome if you didn't gloss it as a subclass
relationship, but took the Java spec's language seriously: Point3D[] is /not/
a subclass of Point[] in any sense, however the rules about substitutability
have been extended to allow some cases that are not covered by subclass
relationships. The effect is that Java's type system doesn't exactly coincide
with the inheritance tree -- but then it wouldn't do so even without this
special-case (consider private methods for instance). Type ~= class. not even
in Java.
-- chris