diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-11-14 13:59:31 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-11-22 23:09:51 +0100 |
commit | ca154ac967599ba72d5d9dd98ae68db5d21d99c5 (patch) | |
tree | a3a630e62650ff08f672834f0a0e44fe50e633fa | |
parent | e0ecb56e43727e25c3d9838ff98244d7c47a4c81 (diff) | |
download | mupdf-ca154ac967599ba72d5d9dd98ae68db5d21d99c5.tar.xz |
jni: Clarify initialization order in Context.
Previously the initialization order of init() and the field inited
was not obvious. Move the static block as far up as possible but
make sure that inited is initialized before that. Also add a comment
explaining why.
3 files changed, 12 insertions, 6 deletions
diff --git a/platform/java/src/com/artifex/mupdf/fitz/Context.java b/platform/java/src/com/artifex/mupdf/fitz/Context.java index 5ad384db..681375aa 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/Context.java +++ b/platform/java/src/com/artifex/mupdf/fitz/Context.java @@ -8,7 +8,14 @@ package com.artifex.mupdf.fitz; // function. public class Context { + // Make sure to initialize inited before calling + // init() from the static block below. private static boolean inited = false; + + static { + init(); + } + private static native int initNative(); public static native int gprfSupportedNative(); @@ -29,8 +36,6 @@ public class Context } } - static { init(); } - // FIXME: We should support the store size being changed dynamically. // This requires changes within the MuPDF core. //public native static void setStoreSize(long newSize); diff --git a/platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java b/platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java index 38bb0447..263d8ecf 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java +++ b/platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java @@ -2,12 +2,12 @@ package com.artifex.mupdf.fitz.android; import android.graphics.Bitmap; +import com.artifex.mupdf.fitz.Context; +import com.artifex.mupdf.fitz.Matrix; import com.artifex.mupdf.fitz.NativeDevice; -import com.artifex.mupdf.fitz.RectI; -import com.artifex.mupdf.fitz.Rect; - import com.artifex.mupdf.fitz.Page; -import com.artifex.mupdf.fitz.Matrix; +import com.artifex.mupdf.fitz.Rect; +import com.artifex.mupdf.fitz.RectI; public final class AndroidDrawDevice extends NativeDevice { diff --git a/platform/java/src/com/artifex/mupdf/fitz/android/AndroidImage.java b/platform/java/src/com/artifex/mupdf/fitz/android/AndroidImage.java index 3a6ebb99..505b4efb 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/android/AndroidImage.java +++ b/platform/java/src/com/artifex/mupdf/fitz/android/AndroidImage.java @@ -2,6 +2,7 @@ package com.artifex.mupdf.fitz.android; import android.graphics.Bitmap; +import com.artifex.mupdf.fitz.Context; import com.artifex.mupdf.fitz.Image; public final class AndroidImage extends Image |