This class is needed by many classes to correctly initialize internal data structures, and each library loaded has its own instance of this class.
To obtain an instance of this class, use getRuntime(Object) on a loaded library.
Example
public interface LibC {
public long write(int fd, Pointer data, long len);
}
LibC library = LibraryLoader.create(LibC.class).load("c");
byte[] bytes = "Hello, World\n".getBytes("UTF-8");
// Use the loaded library's Runtime to allocate memory for the string
jnr.ffi.Runtime runtime = jnr.ffi.Runtime.getRuntime(library);
Pointer buffer = Memory.allocateDirect(runtime, bytes.length);
// Copy the java string data to the native memory, then write the contents to STDOUT
buffer.put(0, bytes, 0, bytes.length);
library.write(1, buffer, bytes.length);
| Modifier and Type | Class and Description |
|---|---|
| private static class | Runtime.
singleton holder for the default Runtime |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract long | |
| public abstract int | Returns: The size of an address in bytes.Gets the size of an address (e.g. a pointer) for this runtime |
| public abstract ByteOrder | |
| public abstract Type | Returns: AType instance.The native pseudo-type. type)Looks up the runtime-specific type that corresponds to the pseudo-type |
| public abstract Type | |
| public abstract ClosureManager | Returns: TheClosureManager of the runtimeGets the native closure manager for this runtime |
| public abstract int | |
| public static List | Returns: the list ofNativeLibrary. which represents all currently loaded librariesGets a list of |
| public abstract MemoryManager | Returns: TheMemoryManager of the runtimeGets the native memory manager for this runtime |
| public static Runtime | Returns: The runtime that loaded the libraryA loaded library instance as returned from library)LibraryLoader#load()Returns the runtime associated with the library instance. |
| public static Runtime | |
| public abstract boolean | Returns: true if the other runtime is compatible with this onethe other runtime to test for compatibility other)Indicates whether this |
| public abstract int | Returns: The size of a C long integer in bytes.Gets the size of a C long integer for this runtime |
| public abstract < the type parameter of the T> ObjectReferenceManagerObjectReferenceManager. | Returns: A newObjectReferenceManagerCreates a new |
| public abstract void |
| Runtime | back to summary |
|---|---|
| public Runtime() | |
| addressMask | back to summary |
|---|---|
| public abstract long addressMask() Gets the address mask for this runtime
| |
| addressSize | back to summary |
|---|---|
| public abstract int addressSize() Gets the size of an address (e.g. a pointer) for this runtime
| |
| byteOrder | back to summary |
|---|---|
| public abstract ByteOrder byteOrder() Gets the native byte order of the runtime.
| |
| findType | back to summary |
|---|---|
| public abstract Type findType(NativeType type) Looks up the runtime-specific type that corresponds to the pseudo-type
| |
| findType | back to summary |
|---|---|
| public abstract Type findType(TypeAlias type) Looks up the runtime-specific type that corresponds to the type alias | |
| getClosureManager | back to summary |
|---|---|
| public abstract ClosureManager getClosureManager() Gets the native closure manager for this runtime
| |
| getLastError | back to summary |
|---|---|
| public abstract int getLastError() Gets the last native error code. This returns the errno value that was set at the time of the last native function call.
| |
| getLoadedLibraries | back to summary |
|---|---|
| public static List Gets a list of
| |
| getMemoryManager | back to summary |
|---|---|
| public abstract MemoryManager getMemoryManager() Gets the native memory manager for this runtime
| |
| getRuntime | back to summary |
|---|---|
| public static Runtime getRuntime(Object library) Returns the runtime associated with the library instance.
| |
| getSystemRuntime | back to summary |
|---|---|
| public static Runtime getSystemRuntime() Gets the global Runtime for the current FFI provider
| |
| isCompatible | back to summary |
|---|---|
| public abstract boolean isCompatible(Runtime other) Indicates whether this
This is not the same as calling This is mostly for internal use.
| |
| longSize | back to summary |
|---|---|
| public abstract int longSize() Gets the size of a C long integer for this runtime
| |
| newObjectReferenceManager | back to summary |
|---|---|
| public abstract <T> ObjectReferenceManager Creates a new
| |
| setLastError | back to summary |
|---|---|
| public abstract void setLastError(int error) Sets the native error code.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final Runtime |
| Access | Constructor and Description |
|---|---|
| private |
| SYSTEM_RUNTIME | back to summary |
|---|---|
| public static final Runtime SYSTEM_RUNTIME | |
| SingletonHolder | back to summary |
|---|---|
| private SingletonHolder() | |