GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Jan-2006, 10:05
QED's Avatar
QED QED is offline
Member
 
Join Date: Feb 2005
Location: Hudson Valley, NY
Posts: 231
QED is a jewel in the roughQED is a jewel in the roughQED is a jewel in the rough

Unable to catch exception in native code


Hi all,

I hope this post is within scope for this forum.

I have a Java-based application that uses native C++ libraries (built with g++-4.0 on Debian GNU/Linux Testing) for specialized, computation-intensive routines.

Within the native code, I need to catch exceptions thrown inside called methods and throw a corresponding Java exception back to the JVM. This used to work just fine. But I am performing a rebuild after some time has past, and our platform itself has had some upgrades (to glibc, etc.). Consequently, the desired functionality seems to be broken. The exceptions are not being caught in the new build.

Note: the same code built and tested on MS Windows platforms using Visual C++ .NET 2003 works exactly as expected.

Here is a snippet some of the code that is failing:
CPP / C++ / C Code:
/*
 * Class: informeta_mentys_api_license_FileLicense
 * Method: nativeReadExpiry
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_informeta_mentys_api_license_FileLicense_nativeReadExpiry
(JNIEnv *env, jclass cls)
{
    jlong expiry(0);
    try
    {
        expiry = FileLicense::getInstance().readExpiry();
    }
    catch (LicenseException& e)
    {
        env->ThrowNew(Class_LicenseException, e.getMessage().c_str());
    }
    catch (JNIException&)
    {
        // Do nothing; exception already pending from failed JNI call
    }
    catch (...)
    {
        env->ThrowNew(Class_LicenseException, "unidentified runtime error");
    }
    return expiry;
}

Here is the error message that the system gives:
Code:
terminate called after throwing an instance of 'informeta::mentys::security::LicenseException'

Any input or advice would be terrific.

Matthew
  #2  
Old 25-Jan-2006, 14:12
QED's Avatar
QED QED is offline
Member
 
Join Date: Feb 2005
Location: Hudson Valley, NY
Posts: 231
QED is a jewel in the roughQED is a jewel in the roughQED is a jewel in the rough

Re: Unable to catch exception in native code


Well, I have successfully rebuilt using version 3.4 GNU compiler. Hence, I must conclude for the moment that there is some peculiar bug in the latest gcc packages for Debian testing. Until an update is available that could potentially address such a bug, I'll consider this issue closed.

Thanks to all who may have read this post. If you are using JNI with g++-4.0, you may find this relevant.

Matthew
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Opinion on my code and a c++ class question FlipNode C++ Forum 7 07-Feb-2006 09:15
Guidelines for posting requests for help - UPDATED! WaltP C++ Forum 0 21-Apr-2005 03:44
Problem with int mixed with char,... leitz C++ Forum 17 07-Dec-2004 21:56

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:55.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.