From 43fd6a498c0f5f5d297a299e4fa8644a0322de65 Mon Sep 17 00:00:00 2001 From: BugsBeGone <43810556+BugsBeGone@users.noreply.github.com> Date: Sat, 30 Mar 2019 15:55:30 +0000 Subject: [PATCH] Fix maximum structure alignment on Android i386 Fixes https://github.com/java-native-access/jna/issues/1079 --- src/com/sun/jna/Native.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java index b55b5bc404..0a9cbd6f16 100644 --- a/src/com/sun/jna/Native.java +++ b/src/com/sun/jna/Native.java @@ -223,11 +223,16 @@ static boolean isCompatibleVersion(String expectedVersion, String nativeVersion) if (Boolean.getBoolean("jna.protected")) { setProtected(true); } - MAX_ALIGNMENT = Platform.isSPARC() || Platform.isWindows() - || (Platform.isLinux() && (Platform.isARM() || Platform.isPPC() || Platform.isMIPS())) - || Platform.isAIX() - || Platform.isAndroid() - ? 8 : LONG_SIZE; + // Check for GNUC i386. If not Windows, it must be GNUC. + if (!Platform.isWindows() && Platform.isIntel() && !Platform.is64Bit()) { + MAX_ALIGNMENT = 4; + } else { + MAX_ALIGNMENT = Platform.isSPARC() || Platform.isWindows() + || (Platform.isLinux() && (Platform.isARM() || Platform.isPPC() || Platform.isMIPS())) + || Platform.isAIX() + || Platform.isAndroid() + ? 8 : LONG_SIZE; + } MAX_PADDING = (Platform.isMac() && Platform.isPPC()) ? 8 : MAX_ALIGNMENT; System.setProperty("jna.loaded", "true"); }