Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6362541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:55:18+00:00 2026-05-24T23:55:18+00:00

I have some Java code which invokes C++ code, and the C++ code turns

  • 0

I have some Java code which invokes C++ code, and the C++ code turns around and calls Java, all via JNI. We were getting the notorius “hs_err_pidXXXX.log”, which, strangely enough, was occurring when we invoked JNIEnv_::GetMethodID(myJniEnv->GetObjectClass(anException), "printStackTrace", "()V") on the currently pending exception! So we added:

if ((javaException = getJniEnv()->ExceptionOccurred()) != NULL)
{
   jniEnv->ExceptionDescribe();
   .... <other exception handling code> ...
}

…after each time we call JNI to try and uncover what exception was occurring. The result of ExceptionDescribe() was:

Uncaught exception of type <unknown>

How does this happen? The anException value above came straight from a JNI call to anException = myJniEnv->ExceptionOccurred(), wich should yield a throwable, right? I should be able to print a stack trace on a throwable without JNI crashing, I would think. Anyone ever run across something like this before?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:55:19+00:00Added an answer on May 24, 2026 at 11:55 pm

    This sounds like a memory corruption issue, possibly because of Java local references which have already been cleaned up. Try adding some or all of the following options to your Java command line (or JVM creation arguments in C/C++):

      -verbose:jni
      -verbose:gc
      -Xcheck:jni
    

    Probably the most interesting of these is –Xcheck:jni (See the Command-line docs). This will add a bunch of checks for things like using already-deleted local references, and throw an exception at the point the error is detected, instead of much further down in your program when the memory has already been corrupted. Once you get a java exception at the original source of the error, it should be much easier to use a debugger (like gdb for finding the C++ crash location) or the java stack trace to find exactly where the error happens and hopefully pinpoint the exact object that’s causing the issue.

    I learned this from our resident JNI Warrior at work 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ported some LGPL code from Java to C#, which I plan to
I have some Java code which I'm translating to Scala. The code consists of
I have some Java code that uses curly braces in two ways // Curly
Let's say I have some Java code: public class SomeClass { static { private
I have to ship some groovy code to some users that have only java
I have a standalone Java app that has some licensing code that I want
I have to take over and improve/finish some code that transforms Java objects from
Does anyone have a good solution for integrating some C# code into a java
I have to give a general note to some huge Java project for which
I have a multithreaded Java code in which: several threads read stateful objects from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.