Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4505328

stddoclet: javadoc incorrectly lists hidden nested classes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: tools
    • Labels:

      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jhosunw Jamie Ho (Inactive)
              Reporter:
              bstrathesunw Bill Strathearn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: