Skip to content

Commit 4959403

Browse files
committed
Added static helper method to Library interface for getting the wrapped NativeLibrary instance.
1 parent 4f94c57 commit 4959403

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/com/sun/jna/Library.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,12 @@ public Object invoke(Object proxy, Method method, Object[] inArgs)
271271
}
272272
}
273273
}
274+
275+
static final NativeLibrary getNativeLibrary(final Library library) {
276+
final Class<?> interfaceClass;
277+
if (!Library.class.isAssignableFrom(interfaceClass = library.getClass())) {
278+
throw new IllegalArgumentException("Interface " + interfaceClass.getSimpleName() + " does not extend " + Library.class.getSimpleName());
279+
}
280+
return ((Handler)Proxy.getInvocationHandler(library)).getNativeLibrary();
281+
}
274282
}

0 commit comments

Comments
 (0)