diff --git a/src/com/sun/jna/Library.java b/src/com/sun/jna/Library.java index 71745ffd7..d2f3fee2e 100644 --- a/src/com/sun/jna/Library.java +++ b/src/com/sun/jna/Library.java @@ -271,4 +271,12 @@ public Object invoke(Object proxy, Method method, Object[] inArgs) } } } + + static final NativeLibrary getNativeLibrary(final Library library) { + final Class interfaceClass; + if (!Library.class.isAssignableFrom(interfaceClass = library.getClass())) { + throw new IllegalArgumentException("Interface " + interfaceClass.getSimpleName() + " does not extend " + Library.class.getSimpleName()); + } + return ((Handler)Proxy.getInvocationHandler(library)).getNativeLibrary(); + } }