Skip to content

Rxmxnx.JNetInterface provides an implementation of the Java Native Interface and Invocation API for use within the .NET ecosystem.

License

Notifications You must be signed in to change notification settings

josephmoresena/Rxmxnx.JNetInterface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quality Gate Status Bugs Coverage Lines of Code Reliability Rating Maintainability Rating Security Rating Ask DeepWiki

Package Information

Core Assembly Main Assembly
NuGet(Core) NuGet

Description

Rxmxnx.JNetInterface provides an implementation of the Java Native Interface (JNI) and the Invocation API for .NET applications.

Core Features

  • Rxmxnx.JNetInterface.Core: Provides essential types and abstractions to work with JNI without requiring an actual JVM instance.
  • Unit Testing Support: The Rxmxnx.JNetInterface.Proxies namespace 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#.


Getting Started

Installation

Install via NuGet:

dotnet add package Rxmxnx.JNetInterface

If you only need the core functionality without linking to a JVM, install:

dotnet add package Rxmxnx.JNetInterface.Core

Supported Frameworks:
This package supports .NET 8 and later. Ensure your project targets a compatible framework.


Overview

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
  1. When initialized via the Invocation API, IInvokedVirtualMachine is used. When a thread is attached to the JVM, IThread is used.
  2. JClassObject and JGlobal references to classes may not have active JNI references and are loaded as needed.
  3. 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.


About

Rxmxnx.JNetInterface provides an implementation of the Java Native Interface and Invocation API for use within the .NET ecosystem.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages