Will cni be the sane native interface to c++ in openjdk U gcj?
ter
et@ihear.com
Wed Dec 26 00:03:00 GMT 2007
On Tue, 2007年12月25日 at 15:57 -0500, Glenn Chambers wrote:
> On Tue, 2007年12月25日 at 16:49 +0000, Andrew Haley wrote:
>> > Mmm, I think you are right. C++ code either throws Java exceptions or
> > C++ exceptions, but not both. I failed proprtly to read what you
> > wrote.
>> The most interesting question to me isn't what it throws, but what
> it can catch.
>> If I can write this in a Java CNI implementation function, then I'm
> happy:
>> void myJavaClass::NativeMethod(int parameter)
> {
> try {
> nativeCPPLibrary::globalFunction();
> } catch (nativeCPPLibrary::myException x) {
> throw new myJavaException(x.failCode);
> }
> }
>> In the 3.0 version I was playing with, this code was illegal. In fact,
> referring to both C++ exceptions and Java exceptions in the same object
> file failed.
>>swig (using >= 1.3.31) provides this with a java proxy wrapping
nativeCPPLibrary::myException as myJavaException subclassed from
java.lang.Exception, and jni code to do just the above. This is very
much one of the complex contortions in using jni.
More information about the Java
mailing list