|
Hello, Let me apologize ahead of time for the length of this email. I am trying to provide as much detail as possible. I am getting an error in my RPG program that calls a Java method (JNI). I get a "Pointer or parameter error..." When I investigate further I see a few more errors that cause the message that are all something like this: Message . . . . : Space offset X'00827000' or teraspace offset X'0000000000000000' is outside current limit for object QPADEV00R4WADEO 171174. When I display the message details on that error it says that it is happening way down in the JNI code somewhere: >From program . . . . . . . . . : QJVAIPROP From library . . . . . . . . : QSYS From module . . . . . . . . : QJVAIPROP From procedure . . . . . . . : Get_Prop_Info__FRPUsRUi From statement . . . . . . . : 1673 To program . . . . . . . . . . : QJVAIPROP To library . . . . . . . . . : QSYS To module . . . . . . . . . : QJVAIPROP To procedure . . . . . . . . : Get_Prop_Info__FRPUsRUi To statement . . . . . . . . : 1673 The "Pointer or parameter error" happens in my RPG program on the first eval that assigns a string object to my string object field. Here is the code for the program: H DftActGrp(*NO) ActGrp(*CALLER) /Copy QSysInc/QRpgLeSrc,JNI *----------------------------------------------------------------------- - * Declaration for Java object *----------------------------------------------------------------------- - D j_Object S O CLASS(*JAVA: D 'com.foo.bar.long.package.name.+ D ClassName') *--------------------------------------------- * Returned field declaration for method *--------------------------------------------- D j_ReturnVal S O CLASS(*JAVA:'java.lang.String') *----------------------------------------------- * Parameter field declarations for method *----------------------------------------------- D j_Parm1 S O CLASS(*JAVA : 'java.lang.String' ) D j_Parm2 S O CLASS(*JAVA : 'java.lang.String' ) D j_Parm3 S O CLASS(*JAVA : 'java.lang.String' ) D j_Parm4 S O CLASS(*JAVA : 'java.lang.String' ) *------------------------------------------------ * Prototype for constructor *------------------------------------------------ D j_Constructor PR O EXTPROC(*JAVA : D 'com.foo.bar.long.package.name.+ D ClassName' : D *CONSTRUCTOR) D CLASS(*JAVA : D 'com.foo.bar.long.package.name.+ D ClassName') *----------------------------------------------------------------- * Prototype for Java method: * restore in class jhaIFSFile in package com.jha.pinpoint.util *----------------------------------------------------------------- D j_Method PR O EXTPROC(*JAVA : D 'com.foo.bar.long.package.name.+ D ClassName' : D 'restore') D CLASS(*JAVA : 'java.lang.String') D parm1 O CLASS(*JAVA : 'java.lang.String' ) D parm2 O CLASS(*JAVA : 'java.lang.String' ) D parm3 O CLASS(*JAVA : 'java.lang.String' ) D parm4 O CLASS(*JAVA : 'java.lang.String' ) *----------------------------------------------------------------------- *Procedure: newString *Purpose: Create a Java String Object from a character field *----------------------------------------------------------------------- D newString PR O extproc(*JAVA: D 'java.lang.String': D *CONSTRUCTOR) D Class(*JAVA:'java.lang.String') D bytes 50A Const Varying *----------------------------------------------------------------------- *Procedure: getBytes *Purpose: Get bytes from java string to place in char field *----------------------------------------------------------------------- D getBytes PR 7A EXTPROC(*JAVA: D 'java.lang.String': D 'getBytes') VARYING *----------------------------------------------------------------------- * *----------------------------------------------------------------------- ************** *Inline Code * ************** C *entry plist C parm value1 50 C parm value2 50 C parm value3 50 C parm value4 50 C parm r_status 7 C eval j_Parm1 = newString(value1) C eval j_Parm2 = newString(value2) C eval j_Parm3 = newString(value3) C eval j_Parm4 = newString(value4) *-------------------------------------------- * Instantiate object *-------------------------------------------- C IF j_Object = *NULL C EVAL j_Object = j_Constructor C ENDIF *-------------------------------- * Call Java method *-------------------------------- C EVAL j_ReturnVal = C j_Method(j_Object : C j_Parm1 : j_Parm2 : C j_Parm3 : j_Parm4) C eval r_status = getBytes(j_ReturnVal) C eval *inlr = *on It happens on the first eval, right after the parameter list for the program. I don't get it. I have been fighting this for a while now. I do similar things in other programs, and I have another program that is almost identical to this that works. I CAN get this to work, if I go run another one (program that uses JNI to call a java method) first. Some of the other programs were written by a predecessor, and the main different between what I am doing and what is in the other programs is that the contents of QSYSINC/QRPGLESRC,JNI are copied directly into the program rather than using /COPY, and the other programs call static main() methods that don't return anything. I tried putting the contents of the JNI source member in my program, and it didn't help (surprise). I wrote a version that started my JVM manually (using the defaults as shown in the many examples on the web and in the ILE RPG programming reference), and it would get passed the evals, but then it would throw a NoClassDef exception even though my JAR is defined in the system level CLASSPATH environment variable. I am at a loss. This all looks kosher to me, but I guess I am over looking something. I can also get it to run, if I run in it in debug mode. If I run it in debug right after it happens, it may or may not work. If I go in and place my break point on that first eval and then hop around and inspect the values that are passed in, and some of the object pointers, and then step through, it will start working, and will work from then on as long as I don't log out. At first I thought the values weren't getting passed in, but that doesn't seem to be the case. I can see that everything is passed in correctly when I run it in debug. I THINK This is all pointing to some sort of JVM problem, but I am not sure where to look or what to do about it, or if that is indeed the problem. I apologize for the long winded e-mail, but this is really starting to tick me off. I appreciate any help! Dan Feather dfeather@xxxxxxxxxxxxx
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.