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

com.sun.source.tree.ModifiersTree.getFlags() should return class type

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 7
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b112
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Description

      A DESCRIPTION OF THE REQUEST :
      com.sun.source.tree.ClassTree claims to represent "A tree node for a class, interface, enum, or annotation type declaration" yet it does not expose a way to detect whether its type is a interface, enum or annotation type (that is, the type is always a "class").

      ClassTree.getModifiers() returns ModifiersTree which in turn has a method getFlags() but this method will never return an interface, enum or annotation type.

      The source code for Modifier.java contains this comment:

      // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.

      so it looks as if this omission was by design. If you investigate further you will find that Pretty.java (used to pretty-print Trees) uses internal methods to detect the class type but there doesn't seem to be a way to do the same using public methods.

      Please clarify how to detect a class, inteface, enum or annotation type using the Tree API using the public methods.

      JUSTIFICATION :
      The Tree API is incomplete without the ability to detect the class type.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jjg Jonathan Gibbons
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: