public class BridJ extends Object
static {
BridJ.register();
}
register(java.lang.Class)
setNativeLibraryActualName(String, String)
and
addNativeLibraryAlias(String, String)
Modifier and Type | Field and Description |
---|---|
static boolean |
alignDoubles |
static boolean |
cachePointers |
static boolean |
debug |
static boolean |
debugNeverFree |
static boolean |
debugPointerReleases |
static boolean |
debugPointers |
static boolean |
enableDestructors |
static boolean |
logCalls |
static boolean |
protectedMode |
static boolean |
quiet |
static boolean |
verbose |
static boolean |
veryVerbose |
Constructor and Description |
---|
BridJ() |
Modifier and Type | Method and Description |
---|---|
static void |
addLibraryPath(String path) |
static void |
addNativeLibraryAlias(String name,
String alias)
Add a possible alias for a library.
|
static void |
addNativeLibraryDependencies(String name,
String... dependencyNames)
Add names of library dependencies for a library.
|
static <O extends NativeObject> |
copyNativeObjectToAddress(O value,
Type type,
Pointer<O> ptr) |
static <O extends NativeObject> |
createNativeObjectFromPointer(Pointer<? super O> pointer,
Type type) |
static <O extends NativeObject> |
createNativeObjectFromReturnValuePointer(Pointer<? super O> pointer,
Type type) |
static boolean |
debug(String message) |
static void |
delete(NativeObject nativeObject) |
static String |
describe(NativeObject instance)
Creates a string that describes the provided native object, printing
generally-relevant internal data (for instance for structures, this will
typically display the fields values).
|
static String |
describe(Type nativeObjectType)
Creates a string that describes the provided native object type, printing
generally-relevant internal data (for instance for structures, this will
typically display name of the fields, their offsets and lengths...).
|
static boolean |
error(String message) |
static boolean |
error(String message,
Throwable ex) |
static Object |
getJavaObjectFromNativePeer(long peer) |
static NativeEntities |
getNativeEntities(AnnotatedElement type) |
static NativeLibrary |
getNativeLibrary(AnnotatedElement type) |
static NativeLibrary |
getNativeLibrary(String name)
Loads the library with the name provided in argument (see
getNativeLibraryFile(String) ) |
static NativeLibrary |
getNativeLibrary(String name,
File f)
Loads the shared library file under the provided name.
|
static File |
getNativeLibraryFile(String libraryName)
Given a library name (e.g.
|
static String |
getNativeLibraryName(AnnotatedElement m)
Gets the name of the library declared for an annotated element.
|
static NativeEntities |
getOrphanEntities() |
static BridJRuntime |
getRuntime(Class<?> type)
|
static <R extends BridJRuntime> |
getRuntimeByRuntimeClass(Class<R> runtimeClass) |
static Class<? extends BridJRuntime> |
getRuntimeClass(Class<?> type)
|
static Demangler.Symbol |
getSymbolByAddress(long peer) |
static boolean |
info(String message) |
static boolean |
info(String message,
Throwable ex) |
static boolean |
isCastingNativeObjectInCurrentThread()
Deprecated.
|
static boolean |
isCastingNativeObjectReturnTypeInCurrentThread()
Deprecated.
|
static boolean |
isDirectModeEnabled()
Query direct mode.
|
static void |
main(String[] args) |
static <T extends NativeObject> |
protectFromGC(T ob)
Keep a hard reference to a native object to avoid its garbage
collection.
|
static <T extends NativeObject> |
readFromNative(T instance)
Some native object need manual synchronization between Java fields and
native memory.
|
static void |
register()
Registers the native methods of the caller class and all its inner types.
|
static BridJRuntime |
register(Class<?> type)
Registers the native method of a type (and all its inner types).
|
static void |
releaseAll()
Reclaims all the memory allocated by BridJ in the JVM and on the native
side.
|
static void |
releaseLibrary(File library) |
static void |
releaseLibrary(String name) |
static <O extends NativeObject> |
setJavaObjectFromNativePeer(long peer,
O object) |
static void |
setMinLogLevel(Level level) |
static void |
setNativeLibraryActualName(String name,
String actualName)
Define the actual name of a library.
|
static void |
setNativeLibraryFile(String libraryName,
File nativeLibraryFile)
Associate a library name (e.g.
|
static void |
setOrphanEntities(NativeEntities orphanEntities) |
static long |
sizeOf(Type type) |
static <T> Class<? extends T> |
subclassWithSynchronizedNativeMethods(Class<T> original)
Create a subclass of the provided original class with synchronized
overrides for all native methods.
|
static <T extends NativeObject> |
unprotectFromGC(T ob)
Drop the hard reference created with
protectFromGC(NativeObject) . |
static void |
unregister(Class<?> type) |
static boolean |
warning(String message) |
static boolean |
warning(String message,
Throwable ex) |
static <T extends NativeObject> |
writeToNative(T instance)
Some native object need manual synchronization between Java fields and
native memory.
|
public static final boolean debug
public static final boolean debugNeverFree
public static final boolean debugPointers
public static final boolean debugPointerReleases
public static final boolean veryVerbose
public static final boolean verbose
public static final boolean quiet
public static final boolean logCalls
public static final boolean protectedMode
public static final boolean enableDestructors
public static final boolean alignDoubles
public static final boolean cachePointers
public BridJ()
public static <T extends NativeObject> T protectFromGC(T ob)
unprotectFromGC(NativeObject)
to remove the GC
protection.public static <T extends NativeObject> T unprotectFromGC(T ob)
protectFromGC(NativeObject)
.public static void delete(NativeObject nativeObject)
public static void register()
\@Library("mylib")
public class MyLib {
static {
BridJ.register();
}
public static native void someFunc();
}
public static <T> Class<? extends T> subclassWithSynchronizedNativeMethods(Class<T> original) throws IOException
T
- original
- IOException
@Deprecated public static boolean isCastingNativeObjectInCurrentThread()
@Deprecated public static boolean isCastingNativeObjectReturnTypeInCurrentThread()
public static <O extends NativeObject> void setJavaObjectFromNativePeer(long peer, O object)
public static Object getJavaObjectFromNativePeer(long peer)
public static <O extends NativeObject> void copyNativeObjectToAddress(O value, Type type, Pointer<O> ptr)
public static <O extends NativeObject> O createNativeObjectFromPointer(Pointer<? super O> pointer, Type type)
public static <O extends NativeObject> O createNativeObjectFromReturnValuePointer(Pointer<? super O> pointer, Type type)
public static <R extends BridJRuntime> R getRuntimeByRuntimeClass(Class<R> runtimeClass)
public static Class<? extends BridJRuntime> getRuntimeClass(Class<?> type)
public static BridJRuntime getRuntime(Class<?> type)
public static BridJRuntime register(Class<?> type)
\@Library("mylib")
public class MyLib {
static {
BridJ.register(MyLib.class);
}
public static native void someFunc();
}
public static void unregister(Class<?> type)
public static void setMinLogLevel(Level level)
public static NativeEntities getNativeEntities(AnnotatedElement type) throws IOException
IOException
public static NativeLibrary getNativeLibrary(AnnotatedElement type) throws IOException
IOException
public static void releaseAll()
public static void releaseLibrary(String name)
public static void releaseLibrary(File library)
public static void addLibraryPath(String path)
public static void setNativeLibraryActualName(String name, String actualName)
name
- actualName
- public static void addNativeLibraryAlias(String name, String alias)
setNativeLibraryActualName(String, String)
), in the order
they are defined.name
- alias
- public static void addNativeLibraryDependencies(String name, String... dependencyNames)
name
- dependencyNames
- public static File getNativeLibraryFile(String libraryName)
public static void setNativeLibraryFile(String libraryName, File nativeLibraryFile)
public static boolean isDirectModeEnabled()
public static NativeLibrary getNativeLibrary(String name) throws IOException
getNativeLibraryFile(String)
)IOException
public static NativeLibrary getNativeLibrary(String name, File f) throws IOException
getNativeLibrary(String)
will return this library.IOException
public static String getNativeLibraryName(AnnotatedElement m)
Library
annotation.public static Demangler.Symbol getSymbolByAddress(long peer)
public static void setOrphanEntities(NativeEntities orphanEntities)
public static NativeEntities getOrphanEntities()
public static <T extends NativeObject> T readFromNative(T instance)
public static <T extends NativeObject> T writeToNative(T instance)
public static String describe(NativeObject instance)
public static String describe(Type nativeObjectType)
Copyright © 2009-2020. All Rights Reserved.