This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

64-bit JNI C++ to JAVA invocation multiple threads classloader problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ALL,

I have a C++ app that invokes Java classes on 64-bit Solaris 10 with 64-bit JVM.

Here is the problem:
The native non-main (not the thread that initializes the JVM) threads would not be able to find any user-define class and run into StackOverflowError.

Here are the symptoms and observations:
1. The "main thread" that instantiates the JVM has no problem finding and loading any class or method
2. But the other threads (non-main threads) would not be able to find the user-defined classes unless the classes were already loaded by the main thread.
3. The non-main threads can find the "standard" java classes with no problem
4. The same app ran fine on 32-bit system.
5. Except for the JVM reference is global, I already have each thread acquired JNIEnv by either GetEnv() or AttachCurrentThread().
6. JNIEnv::ExceptionDescribe() showed the following StackOverflowError:

7. Here is the sample code that reproduces the problem:

Any idea why it is a problem with 64-bit?

I really appreciate it if anyone can provide any help/suggestion.

Regards,

- Triet
 
triet kha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did more testing and found that the observation regarding 32-bit was incorrect. The simple class finding program provided above ran fine in 32-bit, but when I added more complicated operations, such as doing some work with Apache JackRabbit, I would get StackOverflowError as well.
 
triet kha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It turned out that I made a very stupid mistake. I had only focused on tuning the Java stack size and neglected the native thread stack size which was hidden by the internal thread wrapper, which has a default 64k stack size, I used. After changing the stack size to 256k, everything ran just fine.

Thanks to those who have tried to help out. I really appreciate it.
 
Hey cool! They got a blimp! But I have a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!