#2 Handle Java Exception in C++ client

closed
5
2002-07-28
2002-07-19
Anonymous
No

I am kind of newbie with JNIPP.
I've read the document that up to
point where it decribes Exception and Thread.

I have some question of how to
handle Exception thrown by Java (JVM) in
C++ client.

Like can C++ client catch a specific
Java exception such as
javax.naming.NamingException ?

Discussion

  • Phillip E. Trewhella

    • labels: 338683 -->
     
  • Phillip E. Trewhella

    Logged In: YES
    user_id=123204

    Yes, it can, however this is not a bug and should not be
    entered as such. Please use the forums or send an e-mail.

     
  • Phillip E. Trewhella

    • labels: --> proxy code generator
    • assigned_to: nobody --> ptrewhella
    • status: open --> closed
     
  • Phillip E. Trewhella

    Logged In: YES
    user_id=123204

    In the 0.4 release, exceptions are thrown as "jthrowable"
    only. Your "catch" statement must look something like this:

    catch(jthrowable thr)
    {
    cerr << "caught java.lang.Throwable -- using proxy class to
    print message and stack trace" << endl;
    ExceptionProxy ex( thr ); // add this to your
    project file
    JStringHelper msg( ex.getMessage() );
    cerr << "Message: " << msg << endl;
    ex.printStackTrace();
    }

    Note that you need to modify the project file to generate code
    for the "Exception" class.

    The 0.5 release will include an option to generate (and throw)
    rich exception classes so you would do something like this
    instead:

    catch(ExceptionProxy& ex)
    {
    ...
    }

    Let me know if you need more help.

    Phil

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks