Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.beans.Statement
Constructor Summary | |
Method Summary | |
void |
|
Object[] |
|
String |
|
Object |
|
String |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public Statement(Object target, String methodName, Object[] arguments)
Constructs a statement representing the invocation of object.methodName(arg[0], arg[1], ...);If the argument array is null it is replaced with an array of zero length.
- Parameters:
target
- The object to invoke the method on.methodName
- The object method to invoke.arguments
- An array of arguments to pass to the method.
public void execute() throws Exception
Execute the statement.Finds the specified method in the target object and calls it with the arguments given in the constructor.
The most specific method according to the JLS(15.11) is used when there are multiple methods with the same name.
Execute performs some special handling for methods and parameters:
- Static methods can be executed by providing the class as a target.
- The method name new is reserved to call the constructor new() will construct an object and return it. Not useful unless an expression :-)
- If the target is an array, get and set as defined in java.util.List are recognized as valid methods and mapped to the methods of the same name in java.lang.reflect.Array.
- The native datatype wrappers Boolean, Byte, Character, Double, Float, Integer, Long, and Short will map to methods that have native datatypes as parameters, in the same way as Method.invoke. However, these wrappers also select methods that actually take the wrapper type as an argument.
The Sun spec doesn't deal with overloading between int and Integer carefully. If there are two methods, one that takes an Integer and the other taking an int, the method chosen is not specified, and can depend on the order in which the methods are declared in the source file.
- Throws:
Exception
- if an exception occurs while locating or invoking the method.