Parameters to Java Exceptions from C/C++ shared library So far, i can fill only one string to ThrowNew but my derived exception class in Java could accept 2 [int] and 2 [String].
Created May 4, 2012
you should use the Throw
method instead of the ThrowNew
method. You will need to construct the exception instance yourself, including the arguments, because there is no tidy convenience method that takes C-Strings as input.
As an alternative, you might want to consider using our JunC++ion product, which, in the body of a native method, allows you to write code like:
{ if( bConditionMet ) throw MyException( 1, 2, "str1", "str2" ); }
JunC++ion is a tool that, among other things, generates C++ proxy classes for Java classes. A generated native method wrapper will translate your throw
statement into the appropriate Java exception and throw it into the JVM.
You can find out more about JunC++ion at http://www.codemesh.com.
Good luck,
Alex
DISCLAIMER: I am a principal at Codemesh, Inc.