Skip to content

Commit

Permalink
Added static helper method to Library interface for getting the wrapp…
Browse files Browse the repository at this point in the history
…ed NativeLibrary instance.
  • Loading branch information
serinana47 committed Jun 25, 2024
1 parent 4f94c57 commit 4959403
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/com/sun/jna/Library.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 4959403

Please sign in to comment.