JDK-4505328 : stddoclet: javadoc incorrectly lists hidden nested classes
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-09-20
  • Updated: 2014-05-05
  • Resolved: 2002-05-19
Related Reports
Duplicate :  
Description
Name: bsT130419			Date: 09/20/2001

java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)

Javadoc does not take into account the hiding of nested classes.  For an example
of this, look at the documentation for Hashtable:

http://java.sun.com/j2se/1.4/docs/api/java/util/Hashtable.html

Notice that the documentation claims that Hashtable inherits Map.Entry, the nested type Entry from interface Map.  However, according to javap -private,
Hashtable defines its own private nested type Entry which implements Map.Entry.
Therefore, Hashtable.Entry hides Map.Entry, and Hashtable does not inherit the
type Map.Entry after all.

As proof, try compiling this program.  If the javadoc were correct, this should
be legal, and print "true":

import java.util.*;
class Foo {
  public static void main(String[] args) {
    System.out.println(Hashtable.Entry.class == Map.Entry.class);
  }
}

But the result of javadoc is wrong, and the class doesn't even compile:
$ javac Foo.java
Foo.java:4: java.util.Hashtable.Entry has private access in java.util.Hashtable
    System.out.println(Hashtable.Entry.class == Map.Entry.class);
                                ^
1 error

On the other hand, you may decide that this is a library bug, and that Hashtable
should not define a nested class named Entry because it would hide the
(non-canonical) name Hashtable.Entry as being an alias for Map.Entry.
(Review ID: 132013) 
======================================================================

Comments
WORK AROUND Name: bsT130419 Date: 09/20/2001 Use canonical classnames, rather than relying on javadoc output. In other words, don't expect Hashtable.Entry to be an alias for Map.Entry, even if the javadoc claims it is so. ======================================================================
11-06-2004

EVALUATION I think this is a doclet bug as javadoc does not expose anything about which entities are inherited. ###@###.### This seems closely related to bug 4492178 javadoc incorrectly lists hidden fields ###@###.### 2001-12-08 This is the exact same bug as 4492178. Both bugs show that doclets requires more information from Javadoc to detect member hiding. I will mark this bug as a duplicate.
08-12-2001