JDK-6383755 : JCArrayTypeTree.getType() should return JCTree
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2006-02-09
  • Updated: 2024-04-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
com.sun.source.tree.ArrayTypeTree.getType() returns Tree.  However, JCArrayTypeTree has a JCExpression for its elemtype.  The ArrayTypeTree.getType() return value should probably be ExpressionTree to match it.

Comments
The type-related tree kinds that extend JCExpression but don't implement ExpressionTree are: JCArrayTypeTree, JCPrimitiveTypeTree, JCTypeApply, JCTypeUnion, JCTypeIntersection and JCWildcard. Changing these to not extends JCExpression appears to be laborious, but the following JCArrayTypeTree and JCPrimitiveTypeTree appear to be extraordinary difficult. In the case of these, there are cases where instances of these are returned as instances of ExpressionTree from the API. It is therefore not possible to only change the internal implementation to stop extend JCExpression. The cases are: -both "int.class" and "Object[].class" are valid Java expressions, and are modelled by c.s.s.t.MemberSelectTree. The MemberSelectTree.getExpression method returns an ExpressionTree, but also returns instances of JCPrimitiveTypeTree and JCArrayTypeTree in the above cases. -JCAnnotatedType has method getUnderlyingType(), returning ExpressionTree, which may return instances of JCArrayTypeTree, e.g. Object @TA [] - the underlying type is a JCArrayTypeTree.
26-05-2014

EVALUATION ArrayTypeTree is a type but doesn't implement ExpressionTree. This was a deliberate choice as, for example, String[] is not an expression. However, the internals of javac should probably be cleaned up to follow the same convention.
14-02-2006