ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Calling JAVA methods with varargs from RPG

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling JAVA methods with varargs from RPG

    Hello All

    I'm trying to call a JAVA method from RPG but keep getting a null pointer exception.

    The JAVA method is defined thus (simplified):

    Code:
    public Object myMethod (Object... objects) {}
    I have defined the input parameter in the corresponding RPG procedure interface as

    Code:
    class(*JAVA:'java.lang.Object') const dim(32767)
    When calling the method I pass a %subarr so as to only pass the number of elements populated with objects, but always get a null pointer exception.

    Does the procedure definition need to be different when dealing with a JAVA method that uses varargs for the input parameters?





  • #2
    Managed to figure this out in the end. I had to add options(*varsize) on the procedure definition parameter:

    Code:
     
     class(*JAVA:'java.lang.Object') const dim(32767) options(*varsize)
    It's likely the use of varargs on the Java method definition was a red herring.

    Comment

    Working...
    X