• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic