Posted by Frank Hale on 2000-07-12
I'm writing a JNI binding to a C library which is heavy in pointers, structures, and custom data types. I am able to pass some pointers over to java and store them inside ints, and longs. Then I call my wrapper functions with these values and cast them back to there appropriate type. This works very well for some things. The problem I am encountering is that I have one data type that is 96 bits in size. I've tried passing a reference to java inside an int or long and then passing it back through my wrapper functions and casting it back to what ever type it is and this is causing extreme problems. Basically its crashing the VM everytime. Can somebody clue me in on how to get at this data type from Java? What I am hoping to do is create a pretty much one to one binding from C into Java of a legacy C library. For instance say I have the following C typedef and function: typedef long foo_type; void foobar( foo_type abc ); I would map this to java like so: public native void foobar( long abc ); I then pass foo_type as its original type long to java and convert it back if I call another function which needs foo_type. This works as expected until I have a type which doesn't map well because of its size. How do I map arbitrary sized types to java types? Can I pass a reference and cast it back? If so how? Thanks, Frank --- ICQ# 7205161 http://sapphire.sourceforge.net - Yet Another X11 Window Manager Send FREE Greetings for Father's Day--or any day! Click here: http://www.whowhere.lycos.com/redirects/fathers_day.rdct
Previous post | Next post | Timeline | Home