Incorrectly specifying the method parameters in the RPG prototype
When coding the prototype for a Java™ method, if you do not specify the types of the return value and parameters correctly, the RPG compiler will build the method signature incorrectly. When the program is run, either the wrong method will be called, or the call will fail with a NoSuchMethodError Java exception.
If the call fails with a NoSuchMethodError Java exception, the RPG error message will indicate the signature that was used for the method call. The following table shows the mappings between Java types and method signature values. Refer to Table 1 to see the mapping between Java types and RPG types.
| Java type | Signature |
|---|---|
| boolean | Z |
| byte | B |
| char | C |
| short | S |
| int | I |
| long | J |
| float | F |
| double | D |
| any object | Lclass; |
| any array | [type |
To see the list of valid signatures for the methods in the Java class, use the QSH command
javap -s classname
where classname is
specified with the package, for example java.lang.String. If the class
is not in the standard classpath, you can specify a classpath option
for javap: javap -s classname -classpath classlocation
By
comparing the valid signatures for the method with the signature being
used by RPG for your method call, and working from the mapping tables,
you should be able to determine the error in your prototype.