From 0c28c2aad6bfebf436c13a06db70413166d15d6d Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 15 Nov 2016 17:41:15 +0000 Subject: Update JNI code to load 32 or 64 bit DLL as appropriate. Make the JNI code detect whether it is running on a 32 or 64 bit machine, and change the name of the DLL appropriately. Update Android Makefile to make mupdf_java32 instead of mupdf_java. Update Java Makefile to make mupdf_java32 or mupdf_java64 based on the system it is running on. This choice can be overruled by defining BITS to be "32" or "64" before calling make. Update Windows Solution to make mupdf_java32 or mupdf_java64 as appropriate. --- platform/java/Makefile | 7 +++++-- platform/java/src/com/artifex/mupdf/fitz/Context.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'platform/java') diff --git a/platform/java/Makefile b/platform/java/Makefile index 1762c512..7b4ea380 100644 --- a/platform/java/Makefile +++ b/platform/java/Makefile @@ -1,12 +1,15 @@ OS ?= $(shell uname) ifeq "$(OS)" "Darwin" -MUPDF_JAVA := libmupdf_java.jnilib +MUPDF_JAVA := libmupdf_java64.jnilib JAVA_CFLAGS := \ -I /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/include \ -I /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/include/darwin else -MUPDF_JAVA := libmupdf_java.so + +BITS := $(shell getconf LONG_BIT) + +MUPDF_JAVA := libmupdf_java$(BITS).so JAVA_CFLAGS := \ -I /usr/lib/jvm/java-7-openjdk-i386/include \ -I /usr/lib/jvm/java-7-openjdk-i386/include/linux \ diff --git a/platform/java/src/com/artifex/mupdf/fitz/Context.java b/platform/java/src/com/artifex/mupdf/fitz/Context.java index d8edf378..3ee91822 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/Context.java +++ b/platform/java/src/com/artifex/mupdf/fitz/Context.java @@ -15,12 +15,24 @@ public class Context public static void init() { if (!inited) { inited = true; - System.loadLibrary("mupdf_java"); + System.loadLibrary(getLibraryName()); if (initNative() < 0) throw new RuntimeException("cannot initialize mupdf library"); } } + private static String getLibraryName(void) { + /* Mac OS always uses 64bit DLLs for any JDK 1.7 or above */ + if (System.getProperty("os.name").toLowerCase().contains("mac os")) { + return "mupdf_java64"; + } + String val = System.getProperty("sun.arch.data.model"); + if (val != null && val.equals("32")) { + return "mupdf_java32" + } + return "mupdf_java64"; + } + static { init(); } // FIXME: We should support the store size being changed dynamically. -- cgit v1.2.3