| Core Assembly | Main Assembly |
|---|---|
Rxmxnx.JNetInterface provides an implementation of the Java Native Interface (JNI) and the Invocation API for .NET
applications.
Rxmxnx.JNetInterface.Core: Provides essential types and abstractions to work with JNI without requiring an actual JVM instance.- Unit Testing Support: The
Rxmxnx.JNetInterface.Proxiesnamespace includes types that enable unit testing without a JVM.
Note: Some features may not be available in Visual Basic .NET and may require additional configuration in F#.
Install via NuGet:
dotnet add package Rxmxnx.JNetInterfaceIf you only need the core functionality without linking to a JVM, install:
dotnet add package Rxmxnx.JNetInterface.CoreSupported Frameworks:
This package supports .NET 7.0 and later. Ensure your project targets a compatible framework.
Rxmxnx.JNetInterface provides safe, high-level APIs to interact with JNI and the JVM.
The table below shows how common JNI types map to Rxmxnx.JNetInterface.
| Java Type | JNI Type | Managed Type | Unmanaged Type |
|---|---|---|---|
| boolean | jboolean | IWrapper<System.Boolean> | JBoolean |
| byte | jbyte | IWrapper<System.SByte> | JByte |
| char | jchar | IWrapper<System.Char> | JChar |
| double | jdouble | IWrapper<System.Double> | JDouble |
| float | jfloat | IWrapper<System.Single> | JFloat |
| int | jint | IWrapper<System.Int32> | JInt |
| long | jlong | IWrapper<System.Int64> | JLong |
| short | jshort | IWrapper<System.Int16> | JShort |
| java.lang.Object | jobject | JLocalObject | JLocalRef |
| java.lang.Class<?> | jclass | JClassObject 2 | JClassLocalRef |
| java.lang.String | jstring | JStringObject | JStringLocalRef |
| java.lang.Throwable | jthrowable | JThrowableObject | JThrowableLocalRef |
| [] | jarray | JArrayObject | JArrayLocalRef |
| boolean[] | jbooleanArray | JArrayObject<JBoolean> | JBooleanArrayLocalRef |
| byte[] | jbyteArray | JArrayObject<JByte> | JByteArrayLocalRef |
| char[] | jcharArray | JArrayObject<JChar> | JCharArrayLocalRef |
| double[] | jdoubleArray | JArrayObject<JDouble> | JDoubleArrayLocalRef |
| float[] | jfloatArray | JArrayObject<JFloat> | JFloatArrayLocalRef |
| int[] | jintArray | JArrayObject<JInt> | JIntArrayLocalRef |
| long[] | jlongArray | JArrayObject<JLong> | JLongArrayLocalRef |
| short[] | jshortArray | JArrayObject<JShort> | JShortArrayLocalRef |
| T[] | jobjectArray | JArrayObject<T> | JObjectArrayLocalRef |
| N/A | JavaVM* | IVirtualMachine 1 | JVirtualMachineRef |
| N/A | JNIEnv* | IEnvironment 1 | JEnvironmentRef |
| N/A | jglobal | JGlobal 2 | JGlobalRef |
| N/A | jweak | JWeak | JWeakRef |
| N/A | jmethodID | JCallDefinition 3 | JMethodId |
| N/A | jfieldID | JFieldDefinition 3 | JFieldId |
- When initialized via the Invocation API,
IInvokedVirtualMachineis used. When a thread is attached to the JVM,IThreadis used. JClassObjectandJGlobalreferences to classes may not have active JNI references and are loaded as needed.- Definitions serve as keys for JNI access calls.
Note: As mentioned in
Inconsistent Interop Behavior for Blittable Floating-Point Wrapper Structs in Windows,
it is not possible to use JDouble and JFloat in native JNI calls due to differences with the ABI, even though these
structs are binary-equivalent to System.Double and System.Single, respectively.
Therefore, any JNI call that returns or receives a double or float value as a parameter must use the CLR native
types when declaring methods, function pointers, or delegates.