1

Friends, our project uses hunspell to get suggestion for words, below is the git hub link of the hunspell library.

https://github.com/dren-dk/HunspellJNA/blob/master/src/dk/dren/hunspell/HunspellLibrary.java

Each word is iterated to get sugggestion using hunspell library for which below method ('Hunspell_suggest ' method in above URL).

public int Hunspell_suggest(Pointer pHunspell, PointerByReference slst, byte[] word);

When there are certain special UTF-8 characters the method "Hunspell_suggest" throws run time error & which causes Java run time throws fatal error and brings server down (JVM error below). Since this is third party library we may need to upgrade the library to support & trying to get help from them as well. Before throwing run time error Hunspell is sending below message which indicates its limited support for UTF-8 support & requires library up-gradation.

This UTF-8 encoding can't convert to UTF-16:ð?‘?   <= this message indicates hunspell limitation on certain UTF-8 conversion

However I am looking for help & suggestion to twist the logic & also as a best practice what can we do to safe guard our application getting terminated & avoid throwing error like below when dealing with such third party library since we have limited insight on limitation & when the library will throw runtime error.

**JVM ERROR**

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000000321d3bf, pid=32624, tid=0x0000000000009698
#
# JRE version: Java(TM) SE Runtime Environment (8.0_221-b11) (build 1.8.0_221-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.221-b11 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [jna3287959182198759444.hunspell-win-x86-64.dll+0x2d3bf]
user593029
  • 511
  • 7
  • 18
  • The easiest way to avoid crashes like that in third-party libraries to use only pure Java libraries. This kind of crash only happens when native code (via JNI/JNA) is involved. – Joachim Sauer Jun 24 '20 at 17:20
  • What language dictionary are you using? Is it English? You may need to ensure that the value of [System] property named **file.encoding** is `UTF-8`. – Abra Jun 24 '20 at 18:04
  • @JoachimSauer if I remember correctly, _Hunspell_ is written in C++ and the available java library is merely a wrapper that calls the C++ functions. Hence it has to use either JNI or JNA. Do you know of a pure java spell-checker library? – Abra Jun 24 '20 at 18:07
  • Thanks Joachim & Abra, you guessed it correct it uses JNA & is written in windows native library .dll file because of which I am facing this issue, we need to rewrite & revisit the implementation & find better alternative as you said in Java version. By the time if you have any suggestion that we can handle in Java to avoid this issue do let me know. – user593029 Jun 24 '20 at 20:18

0 Answers0