Package com.kenai.jffi
Class NativeMethods
- java.lang.Object
-
- com.kenai.jffi.NativeMethods
-
public final class NativeMethods extends java.lang.Object
Utility class to register native methods on a class
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
NativeMethods.ResourceHolder
-
Field Summary
Fields Modifier and Type Field Description private NativeMethods.ResourceHolder
memory
private static java.util.Map<java.lang.Class,NativeMethods>
registeredMethods
Store a link from the class to the native method holder in a weak hash map, so as long as the class remains alive, the native memory for the structures remains alive.
-
Constructor Summary
Constructors Modifier Constructor Description private
NativeMethods(NativeMethods.ResourceHolder memory)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
register(java.lang.Class clazz, java.util.List<NativeMethod> methods)
Registers the native methods for a class.static void
unregister(java.lang.Class clazz)
Removes all native method attachments for the specified class.
-
-
-
Field Detail
-
registeredMethods
private static final java.util.Map<java.lang.Class,NativeMethods> registeredMethods
Store a link from the class to the native method holder in a weak hash map, so as long as the class remains alive, the native memory for the structures remains alive. This doesn't seem to be necessary on sun's jvm, but best do it to be safe.
-
memory
private final NativeMethods.ResourceHolder memory
-
-
Constructor Detail
-
NativeMethods
private NativeMethods(NativeMethods.ResourceHolder memory)
-
-
Method Detail
-
register
public static final void register(java.lang.Class clazz, java.util.List<NativeMethod> methods)
Registers the native methods for a class.- Parameters:
clazz
- The java class to register the native methods for.methods
- The list of methods to attach to the class.
-
unregister
public static final void unregister(java.lang.Class clazz)
Removes all native method attachments for the specified class.- Parameters:
clazz
- The class to unregister the native methods on.
-
-