Java Reference
In-Depth Information
• If the class instance creation expression uses “ <> ” to elide class type arguments, a
list of methods m 1 ... m n is defined for the purpose of overload resolution and type
argument inference.
Let c 1 ... c n be the constructors of class C . Let #m be an automatically generated
name that is distinct from all constructor and method names in C . For all j (1 ≤ j
n ), m j is defined in terms of c j as follows:
♦ A substitution θ j is first defined to instantiate the types in c j .
Let F 1 ... F p be the type parameters of C , and let G 1 ... G q be the type parameters
(if any) of c j . Let X 1 ... X p and Y 1 ... Y q be type variables with distinct names that
are not in scope in the body of C .
θ j is [ F 1 := X 1 , ..., F p := X p , G 1 := Y 1 , ..., G q := Y q ] .
♦ The modifiers of m j are those of c j .
♦ The type parameters of m j are X 1 ... X p , Y 1 ... Y q . The bound of each parameter, if
any, is θ j applied to the corresponding parameter bound in C or c j .
♦ The return type of m j is θ j applied to C < F 1 ,..., F p > .
♦ The name of m j is #m .
♦ The (possibly empty) list of argument types of m j is θ j applied to the argument
types of c j .
♦ The (possibly empty) list of thrown types of m j is θ j applied to the thrown
types of c j .
♦ The body of m j is irrelevant.
To choose a constructor, we temporarily consider m 1 ... m n to be members of C .
Then one of m 1 ... m n is selected, as determined by the class instance creation's ar-
gument expressions, using the process described in § 15.12.2 .
It is a compile-time error if there is no unique most-specific method that is both
applicable and accessible.
Otherwise, where m j is the selected method, c j is the chosen constructor. The result
type and throws clause of c j are the same as the return type and throws clause de-
termined for m j 15.12.2.6 ).
• Otherwise, the class instance creation expression does not use “ <> ” to elide class
type arguments.
Search WWH ::




Custom Search