Class instance creation expression AST node type. For JLS2:
ClassInstanceCreation: [ Expression . ] new Name ( [ Expression { , Expression } ] ) [ AnonymousClassDeclaration ]
For JLS3, type arguments are added and the type name is generalized to a type so that parameterized types can be instantiated:
ClassInstanceCreation: [ Expression . ] new [ < Type { , Type } > ] Type ( [ Expression { , Expression } ] ) [ AnonymousClassDeclaration ]
Not all node arrangements will represent legal Java constructs. In particular, it is nonsense if the type is a primitive type or an array type (primitive types cannot be instantiated, and array creations must be represented with ArrayCreation
nodes). The normal use is when the type is a simple, qualified, or parameterized type.
A type like "A.B" can be represented either of two ways:
-
QualifiedType(SimpleType(SimpleName("A")),SimpleName("B"))
-
SimpleType(QualifiedName(SimpleName("A"),SimpleName("B")))
The first form is preferred when "A" is known to be a type (as opposed to a package). However, a parser cannot always determine this. Clients should be prepared to handle either rather than make assumptions. (Note also that the first form became possible as of JLS3; only the second form existed in JLS2.)
@since 2.0
@noinstantiate This class is not intended to be instantiated by clients.