From: Reimar Döffinger Date: Tue, 21 Apr 2020 20:47:42 +0000 (+0200) Subject: Work around a GraalVM native-image bug. X-Git-Url: https://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=de2a7098e02252016136c114afbf8868bdff2452 Work around a GraalVM native-image bug. --- diff --git a/src/com/hughes/android/dictionary/engine/Dictionary.java b/src/com/hughes/android/dictionary/engine/Dictionary.java index 6539bc9..b9a46a0 100644 --- a/src/com/hughes/android/dictionary/engine/Dictionary.java +++ b/src/com/hughes/android/dictionary/engine/Dictionary.java @@ -50,6 +50,9 @@ public class Dictionary implements RAFSerializable { public final List htmlData; public final List sources; public final List indices; + // Could be a local variable in constructor, but + // this way avoids a native-image VM bug. + private final MappedByteBuffer wholefile; /** * dictFileVersion 1 adds:
  • links to sources? dictFileVersion 2 adds:
  • @@ -66,10 +69,11 @@ public class Dictionary implements RAFSerializable { htmlData = null; sources = new ArrayList<>(); indices = new ArrayList<>(); + wholefile = null; } public Dictionary(final FileChannel ch) throws IOException { - MappedByteBuffer wholefile = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size()); + wholefile = ch.map(FileChannel.MapMode.READ_ONLY, 0, ch.size()); DataInputBuffer in = new DataInputBuffer(wholefile, 0); dictFileVersion = in.readInt(); if (dictFileVersion < 0 || dictFileVersion > CURRENT_DICT_VERSION) {