MCPcopy Create free account
hub / github.com/java-native-access/jna / findEnclosingLibraryClass

Method findEnclosingLibraryClass

src/com/sun/jna/Native.java:780–806  ·  view source on GitHub ↗

Find the library interface corresponding to the given class. Checks all ancestor classes and interfaces for a declaring class which implements Library. @param cls The given class @return The enclosing class

(Class<?> cls)

Source from the content-addressed store, hash-verified

778 * @return The enclosing class
779 */
780 static Class<?> findEnclosingLibraryClass(Class<?> cls) {
781 if (cls == null) {
782 return null;
783 }
784 // Check for direct-mapped libraries, which won't necessarily
785 // implement com.sun.jna.Library.
786 Map<String, ?> libOptions = typeOptions.get(cls);
787 if (libOptions != null) {
788 Class<?> enclosingClass = (Class<?>)libOptions.get(_OPTION_ENCLOSING_LIBRARY);
789 if (enclosingClass != null) {
790 return enclosingClass;
791 }
792 return cls;
793 }
794 if (Library.class.isAssignableFrom(cls)) {
795 return cls;
796 }
797 if (Callback.class.isAssignableFrom(cls)) {
798 cls = CallbackReference.findCallbackClass(cls);
799 }
800 Class<?> declaring = cls.getDeclaringClass();
801 Class<?> fromDeclaring = findEnclosingLibraryClass(declaring);
802 if (fromDeclaring != null) {
803 return fromDeclaring;
804 }
805 return findEnclosingLibraryClass(cls.getSuperclass());
806 }
807
808
809 /** Return the preferred native library configuration options for the given

Callers 2

getLibraryOptionsMethod · 0.95

Calls 2

findCallbackClassMethod · 0.95
getMethod · 0.45

Tested by 1