Consider end-user type-safe kind-based conversion methods

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: core-libs
    • None

      For a variety of design constrains, instanceof checking of javax.lang.model types isn't necessarily a reliable idiom, as described in the specification:

      "To implement operations based on the class of an Element object, either use a visitor or use the result of the getKind() method. Using instanceof is not necessarily a reliable idiom for determining the effective class of an object in this modeling hierarchy since an implementation may choose to have a single object implement multiple Element subinterfaces."

      "To implement operations based on the class of an TypeMirror object, either use a visitor or use the result of the getKind() method. Using instanceof is not necessarily a reliable idiom for determining the effective class of an object in this modeling hierarchy since an implementation may choose to have a single object implement multiple TypeMirror subinterfaces."

      However, getting the effective of a kind-based base is either not known to be type safe (risky) or verbose to write, via a visitor.

      A library-based solution that would encapsulation any static type-unsafely would be an aid to javax.lang.model users.

            Assignee:
            Joe Darcy
            Reporter:
            Laird Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: