Java Reference
In-Depth Information
If the compile-time declaration is void , then the method invocation must be a top level ex-
pression (that is, the Expression in an expression statement (§ 14.8 ) or in the ForInit or
ForUpdate part of a for statement (§ 14.14 ) ), or a compile-time error occurs.
The reason is that such a method invocation produces no value and so must be
used only in a situation where a value is not needed.
A method is signature polymorphic if and only if all of the following conditions hold:
• It is declared in the java.lang.invoke.MethodHandle class.
• It takes a single variable arity parameter (§ 8.4.1 ) whose declared type is Object[] .
• It has a return type of Object .
• It is native .
In Java SE 7, the only signature polymorphic methods are the invoke and invokeExact
methods of the class java.lang.invoke.MethodHandle .
If the compile-time declaration for the method invocation is not a signature polymorphic
method, then the types of its parameters are the types of its formal parameters, and the res-
ult type is its chosen result type.
Otherwise, if the compile-time declaration for the method invocation is a signature poly-
morphic method, then:
• The types of its parameters are the static types of the actual argument expressions.
An argument expression which is the null literal null 3.10.7 ) is treated as having
the static type Void .
• The result type is determined as follows:
♦ If the method invocation expression is an expression statement, the method is
void .
♦ Otherwise, if the method invocation expression is the operand of a cast expres-
sion (§ 15.16 ) , the return type is the erasure (§ 4.6 ) of the type of the cast ex-
pression.
♦ Otherwise, the return type is the method's declared return type, Object .
The following compile-time information is then associated with the method invocation for
use at run time:
• The name of the method.
• The qualifying type of the method invocation (§ 13.1 ).
Search WWH ::




Custom Search