Water 5-System Interfaces-Water to Java
method get_java_method
Contract
Return typewob
Parameter keyDefault valueType
class_namereq
method_namereq
Parameter kindDefault valueType
Other unkeyed argumentsopt
Water Contract
<method get_java_method
  class_name =req
  method_name=req
  _other_unkeyed=opt=wob=ekind.code="_body"/>

Returns the java method indicated by the arguments. You pass the class of the method, followed by the method name, followed by the class of each of its arguments.
<get_java_method "Bob" "get_java_class_field_value" "String" "String"/>
There are abbreviations for some common classes like String and Integer, but others you must pass by their full name (prefixed with a package).
Details: The first argument is class as a java class, or a string of the class name, or a Java instance from which we extract the class. Warning: If the "instance" that you're passing in as an argument happens to be a string, i.e. you want to get a method on the class java.lang.String, then you should instead pass in exactly "String" . 2nd argument is method name, (a string) , and the _vector_fields of arguments are the class-names of the parameters to the method you want to be returned. Class names in the java.lang package can be abbreviated from "java.lang.Math" to just "Math" if you like. All the java primitives, i.e. int, char, boolean can be spelled "int", "char", "boolean", etc.
<get_java_method "Math" "min" "int" "int"/>
The formal, obscure java "java.lang.Integer.TYPE" also works, but "int" is a lot clearer.
Constructors You can get constructors using the method name of "new".
<get_java_method "java.lang.StringBuffer" "new" "String"/>

Calling Static Java Methods In a Water call, the name of the element is executed to get the method to call. The result of that execution can be either a Water method or a Java method. So for instance we can call the java "min" method like so:
<<get_java_method "Math" "min" "int" "int"/> 89 47 />
47
Note that even though Water has no ints, i.e. all integers are represented as java Integers, you can still call many java methods that take primitives. In the above example 89 and 47 are turned into Integers in Water but when passed to java's min method, they will behave as ints.
Calling Constructors To make an instance of a StringBuffer initialized to "abc" you can do this:
<<get_java_method "java.lang.StringBuffer" "new" "String"/> "abc"/>
Here's an example of creating a java Date object initializing it to March 24th, 1999. (Note the month 2 in Java is March, not February as months are zero based.)
<<get_java_method "java.util.Date" "new" "int" "int" "int"/> 99 2 24/>

Calling Instance Methods If you call a static method, the _subject of the call is ignored. But calling an instance method it isn't, so for example: Create a date and get the year:
<set mydate=<<get_java_method "java.util.Date" "new" "int" "int" "int"/> 99 2 24/> />
mydate.<<get_java_method "java.util.Date" "getYear"/>/>