Jump to content
Excelsior Forums

Basic function call problem.

Recommended Posts

Greetings Folks...

I'm new to JNI and C to me is a foriegn language that to me justifies the existance of Java ;-).  I'm in the processes of working with an evaluation of xFunction for a commercial project.  Real money is likely to be handed over if I can get this to work.

I've a c-function that is part of another comercial API (Quick Address Pro), that is documented as follows ...


       INTRET QAPro_AddrLine      (LONGVAL vlItem,

                   INTVAL viLine,

                   STRVAL vsPrem,

                   STRREF rsBuffer,

                   INTVAL viLength);

I've made an attempt to map the parameters with the following Java coded function call with xFunction.  This, when I run it, causes the VM to abend/dump, so something is very much amiss.

       xFunction addrFunction = new xFunction(DLL_NAME, "int QAPro_AddrLine(long, int, CSTRING, CSTRING*, int)");

       Argument arg1 = new Argument(0L);

       Argument arg2 = new Argument(11);

       Argument arg3 = new Argument("", Argument.CSTRING);

       Pointer arg4 = Pointer.create("CSTRING*");

       Argument arg5 = new Argument(0);

       Object o = addrFunction.invoke(arg1, arg2, arg3, arg4, arg5);

Other function calls work okay to the same API (different function), though this is the first one that includes a data type 'STRREF'.  This appears to me to imply the use of a pointer hence the use of 'Pointer.create("CSTRING*");'.  Can anyone enlighten me to the correct mechanism I need to use to handle the data types a C pointer necessitates.

Any help in advance will be very graciously received.

Steven Crowe

Share this post

Link to post
Share on other sites

Fixed this one myself.  I was incorrectly specifying a type of 'long' in the signature for the xFunction object.

Come on chaps, should that really barf the whole VM !?!?!?!


Steven Crowe.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now