diff --git a/src/com/sun/jna/Native.java b/src/com/sun/jna/Native.java index 86e342e86d..7f54b1c587 100644 --- a/src/com/sun/jna/Native.java +++ b/src/com/sun/jna/Native.java @@ -503,7 +503,7 @@ public static List toStringList(char[] buf, int offset, int len) { * @throws UnsatisfiedLinkError if the library cannot be found or * dependent libraries are missing. */ - public static T loadLibrary(Class interfaceClass) { + public static T loadLibrary(Class interfaceClass) { return loadLibrary(null, interfaceClass); } @@ -522,7 +522,7 @@ public static T loadLibrary(Class interfaceClass) { * dependent libraries are missing. * @see #loadLibrary(String, Class, Map) */ - public static T loadLibrary(Class interfaceClass, Map options) { + public static T loadLibrary(Class interfaceClass, Map options) { return loadLibrary(null, interfaceClass, options); } @@ -540,7 +540,7 @@ public static T loadLibrary(Class interfaceClass, Map options) * dependent libraries are missing. * @see #loadLibrary(String, Class, Map) */ - public static T loadLibrary(String name, Class interfaceClass) { + public static T loadLibrary(String name, Class interfaceClass) { return loadLibrary(name, interfaceClass, Collections.emptyMap()); } @@ -560,8 +560,9 @@ public static T loadLibrary(String name, Class interfaceClass) { * @throws UnsatisfiedLinkError if the library cannot be found or * dependent libraries are missing. */ - public static T loadLibrary(String name, Class interfaceClass, Map options) { + public static T loadLibrary(String name, Class interfaceClass, Map options) { if (!Library.class.isAssignableFrom(interfaceClass)) { + // Maybe still possible if the caller is not using generics? throw new IllegalArgumentException("Interface (" + interfaceClass.getSimpleName() + ")" + " of library=" + name + " does not extend " + Library.class.getSimpleName()); } diff --git a/test/com/sun/jna/NativeTest.java b/test/com/sun/jna/NativeTest.java index bb8c5fe8e9..8345d0a198 100644 --- a/test/com/sun/jna/NativeTest.java +++ b/test/com/sun/jna/NativeTest.java @@ -61,7 +61,7 @@ public void testLoadLibraryMethods() throws Exception { Method m = Native.class.getMethod("loadLibrary", paramTypes); Class returnType = m.getReturnType(); signature.append(Native.getSignature(returnType)); - assertSame("Mismatched return type for signature=" + signature, Object.class, returnType); + assertSame("Mismatched return type for signature=" + signature, Library.class, returnType); // System.out.println("===>" + m.getName() + ": " + signature); } catch(NoSuchMethodError err) { fail("No method for signature=" + signature);