473,480 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Throwing C++ exception in JNI

I am wondering of anyone knows the answer to the following. I have a C++
library that is loaded in the VM by JNI. The library throws C++ exceptions.
This work fine on Windows, but on Solaris there are problems. This was
related to the fact that the C++ runtime was not initialized by the JVM
since the JVM is written in C. Does anyone know if this has been fixed in
more recent JVMs or is there some sort of a compiler trick that can be
applied to force the proper initialization to occur when the JVM starts up.
Jul 17 '05 #1
4 4939
On Tue, 07 Sep 2004 13:13:50 GMT, Boris Tabenkin wrote:
I am wondering of anyone knows the answer to the following. I have a
C++ library that is loaded in the VM by JNI. The library throws C++
exceptions. This work fine on Windows, but on Solaris there are
problems. This was related to the fact that the C++ runtime was not
initialized by the JVM since the JVM is written in C.


Why don't you do the necessary initialization in JNI_OnLoad()?

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Jul 17 '05 #2
Gordon Beaton wrote:
On Tue, 07 Sep 2004 13:13:50 GMT, Boris Tabenkin wrote:
I am wondering of anyone knows the answer to the following. I have a
C++ library that is loaded in the VM by JNI. The library throws C++
exceptions. This work fine on Windows, but on Solaris there are
problems. This was related to the fact that the C++ runtime was not
initialized by the JVM since the JVM is written in C.

Why don't you do the necessary initialization in JNI_OnLoad()?

/gordon

I am confused, is this a function that I implement in my own DLL? How
does that get called since the JNI code doesn't happen till something
happens in Java. The C++ runtime is something that is typically
initialized by the JVM runner, not a client dll.
Jul 17 '05 #3
Gordon Beaton wrote:
On Tue, 07 Sep 2004 13:13:50 GMT, Boris Tabenkin wrote:
I am wondering of anyone knows the answer to the following. I have a
C++ library that is loaded in the VM by JNI. The library throws C++
exceptions. This work fine on Windows, but on Solaris there are
problems. This was related to the fact that the C++ runtime was not
initialized by the JVM since the JVM is written in C.

Why don't you do the necessary initialization in JNI_OnLoad()?

/gordon

I am confused, is this a function that I implement in my own DLL? How
does that get called since the JNI code doesn't happen till something
happens in Java. The C++ runtime is something that is typically
initialized by the JVM runner, not a client dll.
Jul 17 '05 #4
On Wed, 08 Sep 2004 12:27:18 GMT, Joe Blow wrote:
Gordon Beaton wrote:
Why don't you do the necessary initialization in JNI_OnLoad()?


I am confused, is this a function that I implement in my own DLL? How
does that get called since the JNI code doesn't happen till something
happens in Java. The C++ runtime is something that is typically
initialized by the JVM runner, not a client dll.


Is it not possible to do the necessary initialization manually?

You implement JNI_OnLoad() in your DLL, and the JVM will invoke it
when it loads the library.

I can't see how the the fact that the JVM was written in C should make
any difference here. It is normally possible to link C and C++ object
files without any problems.

I am a C (not C++) programmer, and don't know how the C++ runtime is
normally initialized, so maybe I just don't fully understand the
problem.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
7216
by: Stephan | last post by:
why does the following code not work???? after compiling and running it will just say killed after all my memory filled up any suggestions? #include <iostream> using namespace std; void...
1
1638
by: Farooq Khan | last post by:
i'm writing a class library having following code snippet. i want this class to report an error (by throwing an Exception) to the application using this class library. the problem is that within...
40
13464
by: Kevin Yu | last post by:
is it a bad programming design to throw exception in the try block then catch it??
9
1496
by: Mark Rae | last post by:
Hi, Can anyone please tell me if there is any difference in throwing an exception with or without parentheses, e.g. try { /* code */
5
1998
by: KJ | last post by:
This is kind of hard to explain but I have a The controls are created with CreateChildControls(). Now let say I click a button and an error occurs in the control. If I throw it up it goes back...
7
5079
by: Sek | last post by:
Hi Folks! I was pondering over a code and noticed that exception handlers were present in the private, protected as well as public methods. And, ofcourse, public methods were calling priv/prot...
5
1949
by: nospam_news | last post by:
When language changes make old code uncompilable, that's not what is called protection of investment. New compilers (g++ 3.2.3) reject classes where methods throw the class they belong to. gcc...
1
3249
by: usenet | last post by:
I wrote some sample code (see below) for nested exception throwing i.e. my catch blocks are throwing exceptions of their own (for simplicity I used standard exceptions). I am getting some...
4
1934
by: Jay Dee | last post by:
I have a query about throwing exceptions. To throw an exception I type something like: try { // do somthing } catch (ArgumentOutOfRangeException) {
21
1683
by: Chris M. Thomasson | last post by:
Is it every appropriate to throw in a dtor? I am thinking about a simple example of a wrapper around a POSIX file... ________________________________________________________________________ class...
0
7051
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6915
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7097
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6750
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3003
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.