update to 3.2.4

This commit is contained in:
Levente Farkas 2009-11-23 18:36:40 +00:00
parent 4b8cd86d43
commit 5ab5507b39
9 changed files with 204 additions and 133 deletions

View File

@ -1 +1 @@
jna-3.0.4.svn729.tar.bz2
jna-3.2.4.tar.bz2

View File

@ -1 +1,2 @@
jna-3_0_4-10_svn729_fc10:EL-5:jna-3.0.4-10.svn729.fc10.src.rpm:1226331400
jna-3_2_4-1_el5:EL-5:jna-3.2.4-1.el5.src.rpm:1259001372

View File

@ -1,11 +0,0 @@
--- jna-3.0.2.default/src/com/sun/jna/Native.java 2008-02-11 16:04:47.000000000 -0500
+++ jna-3.0.2/src/com/sun/jna/Native.java 2008-04-03 23:30:03.000000000 -0400
@@ -85,7 +85,7 @@
public static final int WCHAR_SIZE;
static {
try {
- System.loadLibrary("jnidispatch");
+ System.load("@JNIPATH@/" + System.mapLibraryName("jnidispatch"));
}
catch(UnsatisfiedLinkError e) {
loadNativeLibrary();

View File

@ -1,73 +0,0 @@
diff -ur jna-3.0.4-svn729/src/com/sun/jna/Function.java jna-3.0.4-svn729.orig/src/com/sun/jna/Function.java
--- jna-3.0.4-svn729/src/com/sun/jna/Function.java 2008-09-12 10:05:07.000000000 -0400
+++ jna-3.0.4-svn729.orig/src/com/sun/jna/Function.java 2008-10-01 23:23:38.000000000 -0400
@@ -12,6 +12,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Array;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -351,16 +352,41 @@
}
return result;
}
+
+ private Class primitiveFromBoxed(Class boxedClass) {
+ if (boxedClass.isPrimitive())
+ return boxedClass;
+ if (boxedClass == Boolean.class)
+ return Boolean.TYPE;
+ if (boxedClass == Byte.class)
+ return Byte.TYPE;
+ if (boxedClass == Character.class)
+ return Character.TYPE;
+ if (boxedClass == Short.class)
+ return Short.TYPE;
+ if (boxedClass == Integer.class)
+ return Integer.TYPE;
+ if (boxedClass == Long.class)
+ return Long.TYPE;
+ if (boxedClass == Float.class)
+ return Float.TYPE;
+ if (boxedClass == Double.class)
+ return Double.TYPE;
+ return boxedClass;
+ }
private Object convertArgument(Object[] args, int index, Method invokingMethod, TypeMapper mapper) {
Object arg = args[index];
if (arg != null) {
Class type = arg.getClass();
ToNativeConverter converter = null;
+ boolean isArray = false;
if (NativeMapped.class.isAssignableFrom(type)) {
converter = NativeMappedConverter.getInstance(type);
- }
- else if (mapper != null) {
+ } else if (NativeMapped[].class.isAssignableFrom(type)) {
+ isArray = true;
+ converter = NativeMappedConverter.getInstance(type.getComponentType());
+ } else if (mapper != null) {
converter = mapper.getToNativeConverter(type);
}
if (converter != null) {
@@ -371,7 +397,15 @@
else {
context = new FunctionParameterContext(this, args, index);
}
- arg = converter.toNative(arg, context);
+ if (isArray) {
+ NativeMapped[] nativeArg = (NativeMapped[]) arg;
+ /* Reassign arg here to a new array */
+ arg = Array.newInstance(primitiveFromBoxed(converter.nativeType()), nativeArg.length);
+ for (int i = 0; i < nativeArg.length; i++)
+ Array.set(arg, i, converter.toNative(nativeArg[i], context));
+ } else {
+ arg = converter.toNative(arg, context);
+ }
}
}
if (arg == null || isPrimitiveArray(arg.getClass())) {
Only in jna-3.0.4-svn729.orig/src/com/sun/jna: Function.java~

142
jna-3.2.4-loadlibrary.patch Normal file
View File

@ -0,0 +1,142 @@
diff -up ./src/com/sun/jna/Native.java.loadlib ./src/com/sun/jna/Native.java
--- ./src/com/sun/jna/Native.java.loadlib 2009-11-09 10:23:05.000000000 +0100
+++ ./src/com/sun/jna/Native.java 2009-11-09 10:30:41.000000000 +0100
@@ -630,131 +630,19 @@ public final class Native {
}
/**
- * Loads the JNA stub library. It will first attempt to load this library
- * from the directories specified in jna.boot.library.path. If that fails,
- * it will fallback to loading from the system library paths. Finally it will
- * attempt to extract the stub library from from the JNA jar file, and load it.
- * <p>
- * The jna.boot.library.path property is mainly to support jna.jar being
- * included in -Xbootclasspath, where java.library.path and LD_LIBRARY_PATH
- * are ignored. It might also be useful in other situations.
- * </p>
+ * Loads the JNA stub library.
+ *
+ ** MODIFIED FROM UPSTREAM - we rip out all sorts of gunk here that is
+ ** unnecessary when JNA is properly installed with the OS.
*/
private static void loadNativeLibrary() {
- String libName = "jnidispatch";
- String bootPath = System.getProperty("jna.boot.library.path");
- if (bootPath != null) {
- String[] dirs = bootPath.split(File.pathSeparator);
- for (int i = 0; i < dirs.length; ++i) {
- String path = new File(new File(dirs[i]), System.mapLibraryName(libName)).getAbsolutePath();
- try {
- System.load(path);
- nativeLibraryPath = path;
- return;
- } catch (UnsatisfiedLinkError ex) {
- }
- if (Platform.isMac()) {
- String orig, ext;
- if (path.endsWith("dylib")) {
- orig = "dylib";
- ext = "jnilib";
- } else {
- orig = "jnilib";
- ext = "dylib";
- }
- try {
- path = path.substring(0, path.lastIndexOf(orig)) + ext;
- System.load(path);
- nativeLibraryPath = path;
- return;
- } catch (UnsatisfiedLinkError ex) {
- }
- }
- }
- }
try {
- System.loadLibrary(libName);
- nativeLibraryPath = libName;
+ System.load("@JNIPATH@/" + System.mapLibraryName("jnidispatch"));
+ nativeLibraryPath = "@JNIPATH@/" + System.mapLibraryName("jnidispatch");
}
catch(UnsatisfiedLinkError e) {
- loadNativeLibraryFromJar();
- }
- }
-
- /**
- * Attempts to load the native library resource from the filesystem,
- * extracting the JNA stub library from jna.jar if not already available.
- */
- private static void loadNativeLibraryFromJar() {
- String libname = System.mapLibraryName("jnidispatch");
- String arch = System.getProperty("os.arch");
- String name = System.getProperty("os.name");
- String resourceName = getNativeLibraryResourcePath(Platform.getOSType(), arch, name) + "/" + libname;
- URL url = Native.class.getResource(resourceName);
-
- // Add an ugly hack for OpenJDK (soylatte) - JNI libs use the usual
- // .dylib extension
- if (url == null && Platform.isMac()
- && resourceName.endsWith(".dylib")) {
- resourceName = resourceName.substring(0, resourceName.lastIndexOf(".dylib")) + ".jnilib";
- url = Native.class.getResource(resourceName);
- }
- if (url == null) {
- throw new UnsatisfiedLinkError("jnidispatch (" + resourceName
- + ") not found in resource path");
- }
-
- File lib = null;
- if (url.getProtocol().toLowerCase().equals("file")) {
- try {
- lib = new File(url.toURI());
- }
- catch(URISyntaxException e) {
- lib = new File(url.getPath());
- }
- if (!lib.exists()) {
- throw new Error("File URL " + url + " could not be properly decoded");
- }
- }
- else {
- InputStream is = Native.class.getResourceAsStream(resourceName);
- if (is == null) {
- throw new Error("Can't obtain jnidispatch InputStream");
- }
-
- FileOutputStream fos = null;
- try {
- // Suffix is required on windows, or library fails to load
- // Let Java pick the suffix, except on windows, to avoid
- // problems with Web Start.
- lib = File.createTempFile("jna", Platform.isWindows()?".dll":null);
- lib.deleteOnExit();
- ClassLoader cl = Native.class.getClassLoader();
- if (Platform.deleteNativeLibraryAfterVMExit()
- && (cl == null
- || cl.equals(ClassLoader.getSystemClassLoader()))) {
- Runtime.getRuntime().addShutdownHook(new DeleteNativeLibrary(lib));
- }
- fos = new FileOutputStream(lib);
- int count;
- byte[] buf = new byte[1024];
- while ((count = is.read(buf, 0, buf.length)) > 0) {
- fos.write(buf, 0, count);
- }
- }
- catch(IOException e) {
- throw new Error("Failed to create temporary file for jnidispatch library: " + e);
- }
- finally {
- try { is.close(); } catch(IOException e) { }
- if (fos != null) {
- try { fos.close(); } catch(IOException e) { }
- }
- }
- unpacked = true;
+ throw new RuntimeException(e);
}
- System.load(lib.getAbsolutePath());
- nativeLibraryPath = lib.getAbsolutePath();
}
/**

View File

@ -1,6 +1,7 @@
--- jna-3.0.4-svn700/build.xml 2008-10-01 12:57:20.000000000 -0400
+++ jna-3.0.4-svn700.orig/build.xml 2008-10-01 12:57:16.000000000 -0400
@@ -427,6 +427,7 @@
diff -up ./build.xml.tests-headless ./build.xml
--- ./build.xml.tests-headless 2009-11-09 10:35:40.000000000 +0100
+++ ./build.xml 2009-11-09 10:36:06.000000000 +0100
@@ -466,6 +466,7 @@
<jvmarg value="-Djna.protected=true"/>
<jvmarg value="-Djna.builddir=${build}"/>
<jvmarg value="${vmopt.arch}"/>

View File

@ -1,26 +0,0 @@
diff -ur jna-3.0.4-svn729/src/com/sun/jna/Function.java jna-3.0.4-svn729.orig/src/com/sun/jna/Function.java
--- jna-3.0.4-svn729/src/com/sun/jna/Function.java 2008-10-14 19:47:44.000000000 -0400
+++ jna-3.0.4-svn729.orig/src/com/sun/jna/Function.java 2008-10-14 19:48:00.000000000 -0400
@@ -314,6 +314,20 @@
String s = invokeString(callingConvention, args, true);
result = s != null ? new WString(s) : null;
}
+ else if (returnType == String[].class) {
+ Pointer tmp = invokePointer(callingConvention, args);
+ if (tmp != null)
+ result = tmp.getStringArray(0);
+ else
+ result = null;
+ }
+ else if (returnType == WString[].class) {
+ Pointer tmp = invokePointer(callingConvention, args);
+ if (tmp != null)
+ result = tmp.getStringArray(0, true);
+ else
+ result = null;
+ }
else if (Pointer.class.isAssignableFrom(returnType)) {
result = invokePointer(callingConvention, args);
}
Only in jna-3.0.4-svn729.orig/src/com/sun/jna: Function.java~
Only in jna-3.0.4-svn729/src/com/sun/jna: Function.java.nativemapped-array

View File

@ -1,6 +1,6 @@
Name: jna
Version: 3.0.4
Release: 10.svn729%{?dist}
Version: 3.2.4
Release: 1%{?dist}
Summary: Pure Java access to native libraries
Group: Development/Libraries
@ -9,27 +9,29 @@ URL: https://jna.dev.java.net/
# The source for this package was pulled from upstream's vcs. Use the
# following commands to generate the tarball:
# svn export https://jna.dev.java.net/svn/jna/tags/%{version}/jnalib/ --username guest jna-%{version}
# rm jna-%{version}/dist/*
# tar -cjf jna-%{version}.tar.bz2 jna-%{version}
Source0: %{name}-%{version}.svn729.tar.bz2
Source0: %{name}-%{version}.tar.bz2
# This patch is Fedora-specific for now until we get the huge
# JNI library location mess sorted upstream
Patch1: jna-3.0.2-loadlibrary.patch
Patch1: jna-3.2.4-loadlibrary.patch
# The X11 tests currently segfault; overall I think the X11 JNA stuff is just a
# Really Bad Idea, for relying on AWT internals, using the X11 API at all,
# and using a complex API like X11 through JNA just increases the potential
# for problems.
Patch2: jna-tests-headless.patch
# https://jna.dev.java.net/issues/show_bug.cgi?id=90
Patch3: jna-3.0.4-nativemapped-array.patch
# https://jna.dev.java.net/issues/show_bug.cgi?id=XXX
Patch4: jna-stringarray-return.patch
Patch2: jna-3.2.4-tests-headless.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: java-devel >= 1.6 ant jpackage-utils ant-nodeps
BuildRequires: libX11-devel libXt-devel libffi-devel
# We manually require libffi because find-requires doesn't work
# inside jars.
Requires: java >= 1:1.6.0 jpackage-utils
Requires: java >= 1:1.6.0 jpackage-utils libffi
# for ExcludeArch see bug: 468831
%if 0%{?rhel} < 6
ExcludeArch: ppc ppc64
%endif
%description
JNA provides Java programs easy access to native shared libraries
@ -50,12 +52,20 @@ Requires: %{name} = %{version}-%{release}
This package contains the javadocs for %{name}.
%package examples
Summary: Examples for %{name}
Group: Documentation
Requires: %{name} = %{version}-%{release}
%description examples
This package contains the examples for %{name}.
%prep
%setup -q -n %{name}-%{version}-svn729
%setup -q -n %{name}-%{version}
sed -e 's|@JNIPATH@|%{_libdir}/%{name}|' %{PATCH1} | patch -p1
%patch2 -p1 -b .tests-headless
%patch3 -p1 -b .nativemapped-array
%patch4 -p1 -b .stringarray-return
# all java binaries must be removed from the sources
find . -name '*.jar' -exec rm -f '{}' \;
@ -64,9 +74,6 @@ find . -name '*.class' -exec rm -f '{}' \;
# remove internal copy of libffi
rm -rf native/libffi
# remove random unused zips
rm dist/{src,doc}.zip
# clean LICENSE.txt
sed -i 's/\r//' LICENSE.txt
chmod 0644 LICENSE.txt
@ -75,7 +82,7 @@ chmod 0644 LICENSE.txt
%build
# We pass -Ddynlink.native which comes from our patch because
# upstream doesn't want to default to dynamic linking.
ant jar -Dcflags_extra.native="%{optflags}" -Ddynlink.native=true -Dnomixedjar.native=true
ant -Dcflags_extra.native="%{optflags}" -Ddynlink.native=true -Dnomixedjar.native=true jar examples
ant javadoc
@ -84,6 +91,7 @@ rm -rf %{buildroot}
# jars
install -D -m 644 build*/%{name}.jar %{buildroot}%{_javadir}/%{name}-%{version}.jar
install -D -m 644 build*/examples.jar %{buildroot}%{_javadir}/%{name}-examples-%{version}.jar
(cd %{buildroot}%{_javadir}/; for jar in `ls *-%{version}.jar`; do ln -s $jar `echo $jar | sed -e 's/-%{version}//'`; done)
# NOTE: JNA has highly custom code to look for native jars in this
# directory. Since this roughly matches the jpackage guidelines,
@ -104,14 +112,43 @@ rm -rf %{buildroot}
%defattr(-,root,root,-)
%doc LICENSE.txt
%{_libdir}/%{name}
%{_javadir}/*.jar
%{_javadir}/%{name}.jar
%{_javadir}/%{name}-%{version}.jar
%files javadoc
%defattr(-,root,root,-)
%{_javadocdir}/%{name}-%{version}
%files examples
%defattr(-,root,root,-)
%{_javadir}/%{name}-examples.jar
%{_javadir}/%{name}-examples-%{version}.jar
%changelog
* Sat Nov 14 2009 Levente Farkas <lfarkas@lfarkas.org> - 3.2.4-1
- Rebase on upstream 3.2.4
* Thu Oct 29 2009 Lubomir Rintel <lkundrak@v3.sk> - 3.0.9-6
- Add examples subpackage
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.9-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.9-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
* Tue Dec 30 2008 Colin Walters <walters@redhat.com> - 3.0.9-3
- Add patch to allow opening current process
* Sun Nov 30 2008 Colin Walters <walters@redhat.com> - 3.0.9-2
- Fix library mapping, remove upstreamed patches
* Fri Oct 31 2008 Colin Walters <walters@redhat.com> - 3.0.9-1
- Rebase on upstream 3.0.9
* Tue Oct 14 2008 Colin Walters <walters@redhat.com> - 3.0.4-10.svn729
- Add patch to support String[] returns

View File

@ -1 +1 @@
789cf82e63d0cbc11198d3b2015d3490 jna-3.0.4.svn729.tar.bz2
3e53de2ba6c9e3920ec681224114209e jna-3.2.4.tar.bz2