How the macro runtime searches for a called method
When you add a method call (such as $prp.get('Group Name')$) to a macro script, the Macro Editor does not verify that a called method or constructor exists in the class to which the variable belongs. That check is done by the macro runtime when the call occurs.
The method must be a public method of the underlying Java class.
When the macro runtime searches in the Java class for a method
to match the method that you have called, the macro runtime maps macro
data types (boolean, integer, string, field, double, imported type)
to Java data types as shown in Table 1:
If the method parameter belongs to this macro data type: | Then the macro runtime looks for a Java method with a parameter of this Java data type: |
---|---|
boolean | boolean |
integer | int |
string | String |
field | String |
double | double |
imported type | underlying class of the imported type |
The macro runtime searches for a called method as follows:
- The macro runtime searches for the class specified in the imported type definition (such as java.util.Properties).
- The macro runtime searches in the class for a method with the same method signature (name, number of parameters, and types of parameters) as the called method.
- If the search succeeds, then the macro runtime calls the method.
- If the search fails, then the macro runtime searches in the class
for a method with the same name and number of parameters (disregarding
the types of the parameters) as the called method.
- If the macro runtime finds such a method, it calls the method with the specified parameters.
- If the call returns without an error, the macro runtime assumes that it has called the right method.
- If the call returns with an error, the macro runtime searches for another method.
- The search continues until all methods with the same name and number of parameters have been tried. If none was successful, then the macro runtime generates a runtime error.