Java Platform, Standard Edition Troubleshooting Guide
Contents    Previous    Next

7.4 Handle Exceptions using Java HotSpot VM

The HotSpot VM installs a top-level exception handler during initialization using the SetUnhandledExceptionFilter API for 32-bit systems, or the AddVectoredExceptionHandler API for 64-bit systems.

It also installs the win32 SEH using a __try /__except block in C++ around the thread (internal) start function call for each thread created.

Finally, it installs an exception handler around JNI functions.

If an application must handle structured exceptions in JNI code, it can use __try /__except statements in C++. However, if it must use the vectored exception handler in JNI code then the handler must return EXCEPTION_CONTINUE_SEARCH to continue to the VM's exception handler.

In general, there are two categories of situations in which exceptions arise:

  • When exceptions are expected and handled. Examples include the implicit null handling cited above where accessing a null causes an EXCEPTION_ACCESS_VIOLATION, which is handled.

  • Unexpected exceptions. An example is an EXCEPTION_ACCESS_VIOLATION when executing in VM code, or in JNI code, or in native code. In these cases the signal is unexpected, and fatal error handling is invoked to create the error log and terminate the process.

Contents    Previous    Next

Copyright © 1993, 2017, Oracle and/or its affiliates. All rights reserved.