Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#66 Unnecessary exception on thread destruction

open
nobody
None
5
2005-08-23
2005-08-23
Dan Muller
No

On Win32 platforms using the Jace DLL,
jace::helper::onThreadDestruction() is called each time
a thread runs down. The first thing this function does
is call getJavaVM().

If the Java VM has not been initialized yet,
getJavaVM() throws an exception. This is caught, logged
to std::cerr, and otherwise ignored by Jace's DllMain.
However, the overhead and stderr noise is unnecessary.
In our application, the Java runtime is initialized
only when (and if) a specific subset of the program's
functionality is first used.

This can be easily fixed by changing the call to
getJavaVM() with javaVM, and returning immediately if
it is NULL.

Discussion

  • Dan Muller
    Dan Muller
    2005-08-24

    Logged In: YES
    user_id=358502

    Let me rephrase the last paragraph:

    This can be easily fixed by testing javaVM, and returning
    immediately if it is NULL. (There's no particular reason to
    use the getJavaVM() accessor once the reference is guarded
    this way, since onThreadDestruction() lives in the same
    module where javaVM is defined.)

    BTW, onThreadDestruction() is in file JNIHelper.cpp.