I just noticed the JDK 1.4 documentation for java.util.Hashtable claims
that Hashtable inherits the nested type Entry from Map:
http://java.sun.com/j2se/1.4/docs/api/java/util/Hashtable.html
This would mean that the following program should be legal, and output
"true":
import java.util.*;
class Foo
{
public static void main(String[] args)
{
System.out.println(Hashtable.Entry.class == Map.Entry.class);
}
}
However, it does not compile against Classpath, since the implementation
of Hashtable defines a private nested class named Entry which hides
Map.Entry, and Hashtable.Entry is not accessible (instead of being an
alias for Map.Entry as the documentation claims). See JLS 8.5 for the
specification of nested class hiding.
But perhaps the bug is in Sun's javadoc. Notice that the JDK 1.4
classpath will not allow compilation of the example class either. In
other words, Sun's implementation (without decompiling it to verify)
also seems to have a private nested class Hashtable.Entry which hides
and prevents the inheritance of the public Map.Entry.
So, which do we follow, Sun's behavior or specification? Behavior-wise,
Classpath is correct because it behaves identically to the JDK;
specification-wise, both libraries are in error by not accepting the
above program as legal, and the fix for Classpath would be simply
renaming Hashtable.Entry to something like Hashtable.HashEntry.
I just submitted a bug report to Sun's website on the matter, but it may
be a while before I get a response.
--
This signature intentionally left boring.
Eric Blake [EMAIL PROTECTED]
BYU student, free software programmer
___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath