diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java index d9586c8ff6..5ba4a39a39 100644 --- a/src/com/sun/jna/Native.java +++ b/src/com/sun/jna/Native.java @@ -124,6 +124,7 @@ public void uncaughtException(Callback c, Throwable e) { private static final int TYPE_WCHAR_T = 2; private static final int TYPE_SIZE_T = 3; + static final int MAX_ALIGNMENT; static final int MAX_PADDING; static { @@ -153,10 +154,12 @@ public void uncaughtException(Callback c, Throwable e) { + " - set jna.boot.library.path to include the path to the version of the " + LS + " jnidispatch library included with the JNA jar file you are using" + LS); } - MAX_PADDING = Platform.isSPARC() || Platform.isWindows() || Platform.isARM() - || Platform.isAIX() || Platform.isAndroid() - || Platform.isPPC() + MAX_ALIGNMENT = Platform.isSPARC() || Platform.isWindows() + || (Platform.isLinux() && (Platform.isARM() || Platform.isPPC())) + || Platform.isAIX() + || Platform.isAndroid() ? 8 : LONG_SIZE; + MAX_PADDING = (Platform.isMac() && Platform.isPPC()) ? 8 : MAX_ALIGNMENT; } /** Force a dispose when this class is GC'd. */ diff --git a/src/com/sun/jna/Structure.java b/src/com/sun/jna/Structure.java index d20329342a..64df23deb5 100644 --- a/src/com/sun/jna/Structure.java +++ b/src/com/sun/jna/Structure.java @@ -1301,7 +1301,7 @@ else if (actualAlignType == ALIGN_GNUC) { // NOTE this is published ABI for 32-bit gcc/linux/x86, osx/x86, // and osx/ppc. osx/ppc special-cases the first element if (!isFirstElement || !(Platform.isMac() && Platform.isPPC())) { - alignment = Math.min(Native.MAX_PADDING, alignment); + alignment = Math.min(Native.MAX_ALIGNMENT, alignment); } if (!isFirstElement && Platform.isAIX() && (type == double.class || type == Double.class)) { alignment = 4; diff --git a/test/com/sun/jna/StructureTest.java b/test/com/sun/jna/StructureTest.java index 98df121d8d..fedaea192c 100644 --- a/test/com/sun/jna/StructureTest.java +++ b/test/com/sun/jna/StructureTest.java @@ -158,7 +158,7 @@ protected List getFieldOrder() { } Structure s = new TestStructure(); s.setAlignType(Structure.ALIGN_GNUC); - final int SIZE = Native.MAX_PADDING == 8 ? 32 : 28; + final int SIZE = Native.MAX_ALIGNMENT == 8 ? 32 : 28; assertEquals("Wrong structure size", SIZE, s.size()); }