X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FDictionary.java;h=cb7371442e3bd380cfafe31d32690d02e70546ca;hb=5f7b259669237dad4cbfdec8536537815846979b;hp=6539bc9b0f0a52afce3eae135fa681bf527ddc53;hpb=2a18ab8b97ba0254a0655d595f05c492eb0eecd4;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/engine/Dictionary.java b/src/com/hughes/android/dictionary/engine/Dictionary.java index 6539bc9..cb73714 100644 --- a/src/com/hughes/android/dictionary/engine/Dictionary.java +++ b/src/com/hughes/android/dictionary/engine/Dictionary.java @@ -31,9 +31,8 @@ import com.hughes.util.CachingList; import com.hughes.util.DataInputBuffer; import com.hughes.util.raf.RAFList; import com.hughes.util.raf.RAFListSerializer; -import com.hughes.util.raf.RAFSerializable; -public class Dictionary implements RAFSerializable { +public class Dictionary { private static final int CACHE_SIZE = 5000; @@ -50,6 +49,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 +68,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) { @@ -115,7 +118,6 @@ public class Dictionary implements RAFSerializable { } } - @Override public void write(DataOutput out) throws IOException { RandomAccessFile raf = (RandomAccessFile)out; if (dictFileVersion < 7) throw new RuntimeException("write function cannot write formats older than v7!");