Closed fredmafu closed 3 months ago
It's my understanding that a Java client program can't catch or handle exceptions thrown by the native code; it would crash the JVM.
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/crashes001.html
That said, you can code defensively by verifying the datapath
, or its content, after setting it to make sure it's valid. Check the documentation for GetAvailableLanguagesAsVector
or GetLoadedLanguagesAsVector
API method.
Seems all methods in the Tesseract library that throw the assert exception by ASSERT_HOST(x) may cause the crash and no fatal error log file generated by JVM...
Hello, After I change "datapath" to a non-existent directory,
run TessAPITest#testTessBaseAPIDetectOrientationScript and JVM crash after output these lines in console
I tried to wrap the method body with try{...}catch(Throwable ex){...} block or call Native.setProtected(true) on the top but neither worked.
This may be a potential risk if I embed the orientation detection code in my project and get "datapath" not properly configured after deployed. May I know how to catch the exception? Thank you so much for your response.