JDK-4473462 : stddoclet: Javadoc fails to document private inner class methods & members
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 1.3.1,1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8,windows_2000
  • CPU: x86,sparc
  • Submitted: 2001-06-22
  • Updated: 2014-05-05
  • Resolved: 2001-06-22
Related Reports
Duplicate :  
Description

Name: bsC130419			Date: 06/22/2001


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)


If an inner class is private, Javadoc won't produce documentation for any of its
methods or data members when using the -private command-line switch. It -will-
produce a page that contains the class description. Declaring the inner class
static doesn't make a difference, either. There is nothing in the Javadoc
documentation that mentions this, so I'm assuming that it's a bug (and not a
feature request. Here's a sample source file that exhibits the bug when using
the command line
	javadoc -private Man.java

*** start source ***

/**
 * <p>A class with class.</p>
 */
public
class Man {
  public static
  void
  main( String[] argv ) {
    Man man = new Man();
    Man.Bar bar = new Man.Bar();

    man.walkInto( bar );
    man.duck( bar );

  } // end main()

  /**
   * <p>Avoid the specified {@link Man.Bar}.</p>
   */
  public void duck( final Bar bar ) { }
  
  /**
   * <p>Walk into the specified {@link Man.Bar}.</p>
   */
  public void walkInto( final Bar bar ) { }
  

  /**
   * <p>An inner class of {@link Man}.</p>
   */
  private static class Bar {
    /**
     * <p>Construct a {@link Man.Bar}.</p>
     */
    public Bar() { }

    /**
     * <p>Do something.</p>
     */
    public void doSomething() { }
  
    /**
     * <p>Do something else.</p>
     */
    public void doSomethingElse() {
  
    } // end doSomethingElse()

  } // end Bar inner class

} // end Man class

*** end source ***

The text-only version of the page that's produced looks like this:

Class Man.Bar

java.lang.Object
  |
  +--Man.Bar

Enclosing class:
      Man



private static class Man.Bar
extends java.lang.Object

An inner class of Man.



 Methods inherited from class java.lang.Object
 , clone, equals, finalize, getClass, hashCode, notify, notifyAll,
registerNatives, toString,
 wait, wait, wait
(Review ID: 125433) 
======================================================================

Name: bsC130419			Date: 06/22/2001


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


javadoc -private displays private fields and methods of an outer class
and of nested non-private inner classes, but not of nested private inner
classes.  I think it should display everything.

Here's an outer class with three inner classes: one private, one protected,
one public.   Run javadoc -private JavadocBug.java and look at the results.
The protected and public inner classes work as I expect, but the private
gets displayed without its methods and fields.

/**
 *  An outer class.
 *
 * @author Jutta Degener
 * @created June 20, 2001
 */
public class JavadocBug {

    private int              privateMember;
    protected int            protectedMember;
    public int               publicMember;

    /** A public inner class.  With -private, all its three fields and
     *  three methods will be shown.   Good.
     */
    public class PublicInnerClass
    {
        public int     publicInnerMember     = 0;
        protected int  protectedInnerMember  = 0;
        private int    privateInnerMember    = 0;

        public void    publicInnerMethod()    {}
        protected void protectedInnerMethod() {}
        private void   privateInnerMethod()   {}
    }

    /** A protected inner class.  With -private, it is listed like
     *  the public one.  Good.
     */
    protected class ProtectedInnerClass
    {
        public int     publicInnerMember     = 0;
        protected int  protectedInnerMember  = 0;
        private int    privateInnerMember    = 0;

        public void    publicInnerMethod()     {}
        protected void protectedInnerMethod()  {}
        private void   privateInnerMethod()    {}
    }

    /** A private inner class.  It will be listed, but not
     *  its fields or methods, even with javadoc -private.  Bad.
     */
    private class PrivateInnerClass
    {
        /** None of these will show up. Why not? */

        public int     publicInnerMember     = 0;
        protected int  protectedInnerMember  = 0;
        private int    privateInnerMember    = 0;

        public void    publicInnerMethod()     {}
        protected void protectedInnerMethod()  {}
        private void   privateInnerMethod()    {}
    }
}
(Review ID: 127047)
======================================================================

Comments
WORK AROUND Name: bsC130419 Date: 06/22/2001 Declaring the inner class public will cause all of the desired documentation to be produced, but obviously this changes the semantics of the inner class--if I'd wanted it to be public, I'd have declared it so in the first place. ======================================================================
11-06-2004

EVALUATION The API seems to be properly returning the information, so I suspect this is a standard doclet problem. neal.gafter@Eng 2001-06-22 This is a duplicate of 4456112, which has been fixed and integrated. jamie.ho@Eng 2001-06-22
22-06-2001

PUBLIC COMMENTS I have tested this example and I am positive that this bug is not present in the latest version of the standard doclet. This is a duplicate of 4456112. jamie.ho@Eng 2001-06-22
22-06-2001