From 8e879d7f94a056dc4cbe0e1d276ffd1aa59c11fe Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 6 Sep 2008 22:13:22 +0000 Subject: [PATCH] - A few more patches for JGIR --- jna-3.0.4-structure-handle-null.patch | 40 +++++++++++++++++++++++ jna-3.0.4-structure-reason.patch | 46 +++++++++++++++++++++++++++ jna.spec | 13 ++++++-- 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 jna-3.0.4-structure-handle-null.patch create mode 100644 jna-3.0.4-structure-reason.patch diff --git a/jna-3.0.4-structure-handle-null.patch b/jna-3.0.4-structure-handle-null.patch new file mode 100644 index 0000000..2481d7e --- /dev/null +++ b/jna-3.0.4-structure-handle-null.patch @@ -0,0 +1,40 @@ +diff -ur jna-3.0.4-svn630/src/com/sun/jna/Structure.java jna-3.0.4-svn630.orig/src/com/sun/jna/Structure.java +--- jna-3.0.4-svn630/src/com/sun/jna/Structure.java 2008-09-05 21:49:16.000000000 -0400 ++++ jna-3.0.4-svn630.orig/src/com/sun/jna/Structure.java 2008-09-06 17:43:34.000000000 -0400 +@@ -612,28 +612,28 @@ + + // Set the value at the offset according to its type + if (nativeType == boolean.class || nativeType == Boolean.class) { +- memory.setInt(offset, Boolean.TRUE.equals(value) ? -1 : 0); ++ memory.setInt(offset, (value != null && Boolean.TRUE.equals(value)) ? -1 : 0); + } + else if (nativeType == byte.class || nativeType == Byte.class) { +- memory.setByte(offset, ((Byte)value).byteValue()); ++ memory.setByte(offset, value != null ? ((Byte)value).byteValue() : 0); + } + else if (nativeType == short.class || nativeType == Short.class) { +- memory.setShort(offset, ((Short)value).shortValue()); ++ memory.setShort(offset, value != null ? ((Short)value).shortValue() : 0); + } + else if (nativeType == char.class || nativeType == Character.class) { +- memory.setChar(offset, ((Character)value).charValue()); ++ memory.setChar(offset, value != null ? ((Character)value).charValue() : '\0'); + } + else if (nativeType == int.class || nativeType == Integer.class) { +- memory.setInt(offset, ((Integer)value).intValue()); ++ memory.setInt(offset, value != null ? ((Integer)value).intValue() : 0); + } + else if (nativeType == long.class || nativeType == Long.class) { +- memory.setLong(offset, ((Long)value).longValue()); ++ memory.setLong(offset, value != null ? ((Long)value).longValue() : 0); + } + else if (nativeType == float.class || nativeType == Float.class) { +- memory.setFloat(offset, ((Float)value).floatValue()); ++ memory.setFloat(offset, value != null ? ((Float)value).floatValue() : 0.0f); + } + else if (nativeType == double.class || nativeType == Double.class) { +- memory.setDouble(offset, ((Double)value).doubleValue()); ++ memory.setDouble(offset, value != null ? ((Double)value).doubleValue() : 0.0); + } + else if (nativeType == Pointer.class) { + memory.setPointer(offset, (Pointer)value); diff --git a/jna-3.0.4-structure-reason.patch b/jna-3.0.4-structure-reason.patch new file mode 100644 index 0000000..ed9dbaf --- /dev/null +++ b/jna-3.0.4-structure-reason.patch @@ -0,0 +1,46 @@ +diff -ur jna-3.0.4-svn630/src/com/sun/jna/Structure.java jna-3.0.4-svn630.orig/src/com/sun/jna/Structure.java +--- jna-3.0.4-svn630/src/com/sun/jna/Structure.java 2008-07-31 13:44:21.000000000 -0400 ++++ jna-3.0.4-svn630.orig/src/com/sun/jna/Structure.java 2008-09-05 21:47:51.000000000 -0400 +@@ -126,8 +126,16 @@ + } + + protected Structure(int size, int alignment) { ++ this(size, alignment, null); ++ } ++ ++ protected Structure(TypeMapper mapper) { ++ this(CALCULATE_SIZE, ALIGN_DEFAULT, mapper); ++ } ++ ++ protected Structure(int size, int alignment, TypeMapper mapper) { + setAlignType(alignment); +- setTypeMapper(null); ++ setTypeMapper(mapper); + allocateMemory(size); + } + +@@ -974,7 +982,8 @@ + } + catch(IllegalArgumentException e) { + throw new IllegalArgumentException("The type \"" + type.getName() +- + "\" is not supported as a structure field"); ++ + "\" is not supported as a structure field: " ++ + e.getMessage()); + } + } + +diff -ur jna-3.0.4-svn630/src/com/sun/jna/Union.java jna-3.0.4-svn630.orig/src/com/sun/jna/Union.java +--- jna-3.0.4-svn630/src/com/sun/jna/Union.java 2008-07-31 13:44:21.000000000 -0400 ++++ jna-3.0.4-svn630.orig/src/com/sun/jna/Union.java 2008-09-05 21:47:18.000000000 -0400 +@@ -39,6 +39,11 @@ + protected Union(int size, int alignType) { + super(size, alignType); + } ++ ++ protected Union(TypeMapper mapper) { ++ super(mapper); ++ } ++ + /** Indicates which field will be used to write to native memory. + * @throws IllegalArgumentException if the type does not correspond to + * any declared union field. diff --git a/jna.spec b/jna.spec index b1e08fc..c5a9ee6 100644 --- a/jna.spec +++ b/jna.spec @@ -1,6 +1,6 @@ Name: jna Version: 3.0.4 -Release: 2.svn630%{?dist} +Release: 3.svn630%{?dist} Summary: Pure Java access to native libraries Group: Development/Libraries @@ -18,8 +18,12 @@ Patch1: jna-3.0.2-loadlibrary.patch Patch2: jna-3.0.4-nomixedjar.patch # https://jna.dev.java.net/issues/show_bug.cgi?id=84 Patch3: jna-3.0.4-callbacks-typemappers.patch -# https://jna.dev.java.net/issues/show_bug.cgi?id=XXX +# https://jna.dev.java.net/issues/show_bug.cgi?id=85 Patch4: jna-3.0.4-callbacks-methodname.patch +# https://jna.dev.java.net/issues/show_bug.cgi?id=86 +Patch5: jna-3.0.4-structure-reason.patch +# https://jna.dev.java.net/issues/show_bug.cgi?id=87 +Patch6: jna-3.0.4-structure-handle-null.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: java-devel >= 1.6 ant jpackage-utils ant-nodeps @@ -53,6 +57,8 @@ sed -e 's|@JNIPATH@|%{_libdir}/%{name}|' %{PATCH1} | patch -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 # all java binaries must be removed from the sources find . -name '*.jar' -exec rm -f '{}' \; @@ -109,6 +115,9 @@ rm -rf %{buildroot} %changelog +* Sat Sep 06 2008 Colin Walters - 3.0.4-3.svn630 +- A few more patches for JGIR + * Thu Sep 04 2008 Colin Walters - 3.0.4-2.svn630 - Add two (sent upstream) patches that I need for JGIR