From de2a7098e02252016136c114afbf8868bdff2452 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Tue, 21 Apr 2020 22:47:42 +0200 Subject: [PATCH] Work around a GraalVM native-image bug. --- src/com/hughes/android/dictionary/engine/Dictionary.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) { -- 2.43.0