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

javadoc tool: Mistakenly throws error for static innerclass & field in interface

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • tools
    • beta
    • generic, x86
    • generic, linux, windows_nt
    • Verified

      Name: boT120536 Date: 01/03/2001


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

      With the source code below, calling

        javadoc NotStaticProtected.java

      results in a contradictious error message though javac accepts the source code.
      First, javadoc complains that the anonymous inner class for the static field
      "op" can only be static in an interface or top-level class. But it is a
      static field in an interface. Second, javadoc does not want the field to be
      private or protected although it is public.

      --NotStaticProtected.java--
      import java.util.Comparator;

      public
      interface NotStaticProtected {
          public static final Comparator op = new Comparator() {
              public int compare(Object x, Object y) {
               return 0;
              }
          };
      }
      --End of NotStaticProtected.java--

      Javadoc will print the following error messages
      -------
      Loading source file NotStaticProtected.java...
      NotStaticProtected.java:5: The type nested type NotStaticProtected. 1 can't be
      static. Static members can only occur in interfaces and top-level classes.
          public static final Comparator op = new Comparator() {
                                                  ^
      NotStaticProtected.java:5: Interface fields can't be private or protected:
      nested type NotStaticProtected. 1
          public static final Comparator op = new Comparator() {
                                                  ^
      2 errors
      -------
      (Review ID: 108742)
      ======================================================================

            gafter Neal Gafter (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: