-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
22, 23
-
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.
"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.