Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

throwing Exception having multiple arguments in constructor

843829Mar 24 2007 — edited Mar 25 2007
hi,
I am trying to implement exception handling for a JAVA + C++ module.
In which C++ exception is caught by a Java module.

The c++ code is as follows,

try
{
///////////===========
} catch (Exception1 &e) {
jclass clazz = jenv->FindClass("test/Exception1Java");
if(clazz)
jenv->ThrowNew(clazz,e.getErrMsg().c_str());
return 0;
} catch (Exception2 &e) {
jclass clazz = jenv->FindClass("test/Exception2");
if(clazz)
jenv->ThrowNew(clazz,e.getErrMsg().c_str());
return 0;
}
This works perfectly fine.

But I want to pass one more argument as int while throwing the java exception.

jenv->ThrowNew(clazz,e.getErrId(),e.getErrMsg().c_str());

As the jenv->ThrowNew function only take two arguments I am unable to send the error id( int ) to the message.

Is there any alternate to this function or some other approach to throw the java exceptions.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 22 2007
Added on Mar 24 2007
1 comment
253 views