View previous topic :: View next topic
|
Author |
Message |
Majid Hussain
New User
Joined: 18 Aug 2007 Posts: 20 Location: Bangalore
|
|
|
|
Hi all
I am calling a Java program from a COBOL program. In an attempt to return multiple strings, I am returning an Array of Objects to the calling method.
Code: |
public class TestClass {
public static void main(String[] args)
{
.
}
public TestClass1[] execMethod(byte[] inString) {
.
.
TestClass1[] test = new TestClass1[];
.
.
return TestClass1
}
} |
When called from the Cobol program, I am getting no exceptions and also seems to get the length of the array correctly.
Code: |
INVOKE Test-Class-obj 'execMethod'
USING BY VALUE ws-jbyteArray-obj
RETURNING test-class1-obj-array
Call GetArrayLength
using by value JNIEnvPtr
test-class1-obj-array
returning test-class1-len |
But when I try to get any element from the Array, it returns NULLs. Could someone please let me know if they have come any such error?
Code: |
Perform varying I from 0 by 1 until I = test-class1-len
Call GetObjectArrayElement
using by value JNIEnvPtr test-class1-obj-array I
returning test-class1-array-element
Perform JavaExceptionCheck
if test-class1-array-element = null
then
display "Null object returned"
end-if
End-Perform
|
test-class1-array-element is always NULL. No matter what reference I use in working-storage section. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Inter-language issues are usually difficult to figure out. Have you successfully gotten a single variable to transfer between Java and COBOL? If not, why not start with that and get the interface working there before complicating the interface with arrays? If you have, what is different between the single variable and the array code? |
|
Back to top |
|
|
Majid Hussain
New User
Joined: 18 Aug 2007 Posts: 20 Location: Bangalore
|
|
|
|
Yes. I have already got a String or ByteArray back from java program. |
|
Back to top |
|
|
|