Parameters to Java Exceptions from C/C++ shared library
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Monday, April 9, 2001 02:59 AM

So far, i can fill only one string to ThrowNew but my derived exception class in Java could accept 2 [int] and 2 [String]. Of course in C/C++ i could use my one string but i hope there is an easier and faster way to meet my requirements (directly fill the 4 parameters of my java class from within the C/C++ code).Thank you

Re: Parameters to Java Exceptions from C/C++ shared library

Posted By:   Alexander_Krapf  
Posted On:   Tuesday, April 10, 2001 10:30 AM

Hi Francois,

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,


DISCLAIMER: I am a principal at Codemesh, Inc.

About | Sitemap | Contact