Handling fatal error thrown by JNA methods
<p>I've a Java web application that makes use of OCR functionality. It uses <a href="http://tess4j.sourceforge.net/" rel="nofollow">Tess4j</a> - a JNA wrapper for Tesseract OCR Engine. This functionality is optional and a custom exception should be thrown if any issue happens with the native code.</p>

<p>The following is the extract from my code:</p>

<pre><code>try{
    //Tess4j method call
}catch(Throwable th){
    throw new CustomException("OCR engine failed to initialize.");
}
</code></pre>

<p>I've caught <code>java.lang.Throwable</code>(assuming both errors and exceptions in native implementation will be caught and thrown as CustomException). </p>

<p>However, it doesn't work as per my assumption. The web application server stops with below fatal error message containing some C code(pointers).</p>

<blockquote>
  <p>A fatal error has been detected by the Java Runtime Environment:</p>
  
  <p>SIGSEGV (0xb) at pc=0x00007f07205fc33a, pid=15040,
  tid=0x00007f0723101700</p>
  
  <p>JRE version: Java(TM) SE Runtime Environment (8.0_101-b13) (build
  1.8.0_101-b13) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode linux-amd64 compressed oops) Problematic frame: C 
  [libtesseract.so.3.0.3+0x22533a]  ERRCODE::error(char const*,
  TessErrorLogCode, char const*, ...) const+0x16a</p>
  
  <p>Failed to write core dump. Core dumps have been disabled. To enable
  core dumping, try "ulimit -c unlimited" before starting Java again The
  crash happened outside the Java Virtual Machine in native code. See
  problematic frame for where to report the bug.</p>
</blockquote>

<p>What could be the possible reason and how to fix this?</p>