Sponsored Content
Top Forums Programming Problem using Java Native Interface on Debian Post 97009 by QED on Wednesday 25th of January 2006 10:59:24 AM
Old 01-25-2006
Problem using Java Native Interface on Debian

Hi all,

First visit to this forum, hope I've chosen an appropriate place to post this.

I have a Java-based application that uses native C++ libraries (built with g++-4.0) 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 (Debian testing) 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 works just as expected.

Here is a snippet some of the code that is failing:
Code:
/*
 * Class:     informeta_mentys_api_license_FileLicense
 * Method:    nativeReadExpiry
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_informeta_mentys_api_license_FileLicense_nativeRea
(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

P.S. I now realize that this is a poor choice of forum for my question. If it would be more appropriate, could a moderator please move this to Network Computing Topics > C Programming in the UNIX Environment. I see there is a g++-4.0 thread over there. Sorry.

Last edited by QED; 01-25-2006 at 12:20 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

network interface problem

Hi expert, Need some help on network interface issue.. I have added 2 x NIC card onto the Ultra 2 system recently and configured as hme1 and hme2. I have unconfigured the onboard hme0 network interface and it was running fine till few days later, i keep recieving error messages showing hme0... (6 Replies)
Discussion started by: sc2005
6 Replies

2. AIX

Problem with a Network Interface

Hi every body, I have a Fiber Channel interface (fcs2) in AIX 5.2. This interface was fine & up but for some reason I could not return this interface UP again after I set it DOWN. When I tried to set this interface UP I encountered the following error: Method error... (7 Replies)
Discussion started by: aldowsary
7 Replies

3. Debian

Trying to native compile Debian Dialog

Hi, tried to native compile Debian Dialog as ncurses-dev is available. I am trying native compile Debian Dialog using gcc on Linux embedded router. What's wrong, as running than make I get errors. Mayby this line in the log file is an exaplanation to a problem ? " checking if we have... (1 Reply)
Discussion started by: jack2
1 Replies

4. UNIX for Advanced & Expert Users

interface problem

hi all, i have problem with my box, until now i can't investigate the root cause of my issue at my box. here the problem. i have a box as a squid server just forward all request packet from one interface and receive the packet then forward to client at the same interface. but after 5 hours i... (1 Reply)
Discussion started by: tindasz
1 Replies

5. Debian

How to install Java in Debian Lenny

Hi all im trying to install Java in Debian lenny with apt-get install but can find the packages...anyone can help me on this one? thanks (2 Replies)
Discussion started by: ro0t3d
2 Replies

6. Programming

libcurl multi interface problem

Hello, I'm trying to use libcurl multi interface to fetch several data in parallel. I would expect this to be faster than performing repeated fetches using the easy interface, but for some reason I can't obtain any speed up at all: using the multi interface actually turns out to be MUCH slower than... (2 Replies)
Discussion started by: clalfa
2 Replies

7. Debian

Problem with graphical interface

Hi, i have problems with an installation of Debian i386 505 in a pc. The hardware it is a mother soyo with a chipset via. When i install the xorg, the installation it`s succesfull, but when i type startx, the pc don`t respond. I am from Argentina and my English it isn`t good. Sorry. (0 Replies)
Discussion started by: Kritar
0 Replies

8. Solaris

Network interface problem

Hi i have replace a NIC card on solaris 10 when i give the following command ifconfig -a it just show the lo0 (only loop back with inet 127.0.0.1) when i give the following command to config the interface, ifconfig elxl0 plumb ifconfig: plumb: elxl0: no such interface please help... (11 Replies)
Discussion started by: malikshahid85
11 Replies

9. Solaris

Network interface problem

HI, genunix: NOTICE: ce0: xcvr addr:0x01 - link up 100 Mbps half duplex genunix: WARNING: ce0: fault detected external to device; service degraded genunix: WARNING: ce0: xcvr addr:0x01 - link down genunix: NOTICE: ce0: fault cleared external to device; service available genunix: ... (4 Replies)
Discussion started by: sunnybee
4 Replies

10. Programming

can i have an optimal solution for this java code ? Facing Java heap space problem even at 3GB heaps

My desired output is run: for this 1 for this 2 for this 3 for this 4 for this 5 for this 1,2 1->2 for this 2,3 2->3 for this 3,4 3->4 for this 4,5 4->5 for this 1,2,3 1->2,3 (2 Replies)
Discussion started by: vaibhavkorde
2 Replies
ExtUtils::XSpp::Exception(3pm)				User Contributed Perl Documentation			    ExtUtils::XSpp::Exception(3pm)

NAME
ExtUtils::XSpp::Exception - Map C++ exceptions to Perl exceptions DESCRIPTION
This class is both the base class for the different exception handling mechanisms and the container for the global set of exception mappings from C++ exceptions (indicated by a C++ data type to catch) to Perl exceptions. The Perl exceptions are implemented via "croak()". The basic idea is that you can declare the C++ exception types that you want to handle and how you plan to do so by using the %exception directive in your XS++ (or better yet, in the XS++ typemap): // OutOfBoundsException would have been declared // elsewhere as: // // class OutOfBoundsException : public std::exception { // public: // OutOfBoundsException() {} // virtual const char* what() const throw() { // return "You accessed me out of bounds, fool!"; // } // } %exception{outOfBounds}{OutOfBoundsException}{stdmessage}; If you know a function or method may throw "MyOutOfBoundsException"s, you can annotate the declaration in your XS++ as follows: double get_from_array(unsigned int index) %catch{outOfBounds}; When "get_from_array" now throws an "OutOfBoundsException", the user gets a Perl croak with the message "Caught exception of type 'OutOfBoundsException': You accessed me out of bounds, fool!". There may be any number of %catch directives per method. Note: Why do we assign another name ("outOfBounds") to the existing "OutOfBoundsException"? Because you may need to catch exceptions of the same C++ type with different handlers for different methods. You can, in principle, re-use the C++ exception class name for the exception map name, but that may be confusing to posterity. Instead of adding %catch to methods, you may also specify exceptions that you wish to handle for all methods of a class: class Foo %catch{SomeException,AnotherException} { ... }; The %catch{Foo,Bar,...} syntax is shorthand for "%catch{Foo} %catch{Bar} ...". If there are exceptions to be caught both from the class and attached to a method directly, the exceptions that are attached to the method only will be handled first. No single type of exceptions will be handled more than once, therefore it is safe to use this precedence to re-order the class-global exception handling for a single method. If there are no %catch decorators on a method, exceptions derived from "std::exception" will be caught with a generic "stdmessage" handler such as above. Even if there are %catch clauses for the given method, all otherwise uncaught exceptions will be caught with a generic error message for safety. Exception handlers There are different cases of Perl exceptions that are implemented as sub-classes of "ExtUtils::XSpp::Exception": ExtUtils::XSpp::Exception::simple implements the most general case of simply throwing a generic error message that includes the name of the C++ exception type. ExtUtils::XSpp::Exception::stdmessage handles C++ exceptions that are derived from "std::exception" and which provide a "char* what()" method that will provide an error message. The Perl-level error message will include the C++ exception type name and the exception's "what()" message. ExtUtils::XSpp::Exception::code allows the user to supply custom C/C++/XS code that will be included in the exception handler verbatim. The code has access to the exception object as the variable "e". Your user supplied code is expected to propagate the exception to Perl by calling croak(). ExtUtils::XSpp::Exception::object maps C++ exceptions to throwing an instance of some Perl exception class. Syntax: %exception{myClassyException}{CppException}{object}{PerlClass}; Currently, this means just calling "PerlClass->new()" and then die()ing with that object in $@. There is no good way to pass information from the C++ exception object to the Perl object. Will change in future. ExtUtils::XSpp::Exception::unknown is the default exception handler that is added to the list of handlers automatically during code generation. It simply throws an entirely unspecific error and catches the type "..." (meaning anything). There is a special exception handler "nothing" which is always available: int foo() %catch{nothing}; It indicates that the given method (or function) is to handle no exceptions. It squishes any exception handlers that might otherwise be inherited from the method's class. METHODS
new Creates a new "ExtUtils::XSpp::Exception". Calls the "$self->init(@_)" method after construction. "init()" must be overridden in subclasses. handler_code Unimplemented in this base class, but must be implemented in all actual exception classes. Generates the "catch(){}" block of code for inclusion in the XS output. First (optional) argument is an integer indicating the number of spaces to use for the first indentation level. indent_code Given a piece of code and a number of spaces to use for global indentation, indents the code and returns it. cpp_type Fetches the C++ type of the exception from the "type" attribute and returns it. ACCESSORS
name Returns the name of the exception. This is the "myException" in %exception{myException}{char*}{handler}. type Returns the ExtUtils::XSpp::Node::Type C++ type that is used for this exception. This is the "char*" in %exception{myException}{char*}{handler}. CLASS METHODS
add_exception Given an "ExtUtils::XSpp::Exception" object, adds this object to the global registry, potentially overwriting an exception map of the same name that was in effect before. get_exception_for_name Given the XS++ name of the exception map, fetches the corresponding "ExtUtils::XSpp::Exception" object from the global registry and returns it. Croaks on error. perl v5.14.2 2011-12-20 ExtUtils::XSpp::Exception(3pm)
All times are GMT -4. The time now is 05:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy