Package org.astonbitecode.j4rs.api
Interface Instance<T>
- All Superinterfaces:
JsonValue,ObjectValue
- All Known Implementing Classes:
InvocationArg,JsonInvocationImpl
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> InstanceCasts a the object that is contained in a Instance to an object of class clazz.default <U> booleancheckEquals(Instance<U> other) static <T> InstancecloneInstance(Instance from) Clones a InstanceRetrieves the instance held under the Field fieldNamedefault TvoidinitializeCallbackChannel(long channelAddress) Initialize a callback channel for thisInstance.invoke(String methodName, InvocationArg... args) Invokes a method of the instance of the class that is set for thisInstancevoidinvokeAsyncToChannel(long functionPointerAddress, String methodName, InvocationArg... args) Invokes asynchronously a method of the instance of the class that is set for thisInstance.invokeStatic(String methodName, InvocationArg... args) Invokes a static method of the class that is set for thisInstancevoidinvokeToChannel(long channelAddress, String methodName, InvocationArg... args) Invokes a method of the instance of the class that is set for thisInstance.Methods inherited from interface org.astonbitecode.j4rs.api.ObjectValue
getObject, getObjectClass, getObjectClassName
-
Method Details
-
invoke
Invokes a method of the instance of the class that is set for thisInstance- Parameters:
methodName- The method nameargs- The arguments to use for invoking the method- Returns:
- A
Instanceinstance containing the result of the invocation
-
invokeStatic
Invokes a static method of the class that is set for thisInstance- Parameters:
methodName- The static method nameargs- The arguments to use for invoking the static method- Returns:
- A
Instanceinstance containing the result of the invocation
-
invokeAsyncToChannel
Invokes asynchronously a method of the instance of the class that is set for thisInstance. The result of the invocation must be aFuture. When the Future returned from the invocation completes, j4rs will invoke native Rust code to either send a success value or a failure.Please note that it is best that this function returns a
CompletableFuture, as this improves performance. j4rs handles simpleFutures with polling using an internalScheduledExecutorServicewith one thread and this has apparent performance issues. You may have a look atJ4rsPolledFuturefor more details.- Parameters:
functionPointerAddress- The address of the function pointer that will be used when theFuturecompletes, in the native side, in order to actually perform the callback and complete a Future that is created in Rust and awaits for the Java Future to complete.methodName- The method nameargs- The arguments to use when invoking the callback method (the functionPointer)
-
invokeToChannel
Invokes a method of the instance of the class that is set for thisInstance. The result of the invocation should be provided later using the doCallback method of aNativeCallbackToRustChannelSupportclass. Any possible returned objects from the actual synchronous invocation of the defined method will be dropped.- Parameters:
channelAddress- The memory address of the channelmethodName- The method nameargs- The arguments
-
initializeCallbackChannel
void initializeCallbackChannel(long channelAddress) Initialize a callback channel for thisInstance. The channel can be used by Java to send values to Rust using the doCallback method of aNativeCallbackToRustChannelSupportclass.- Parameters:
channelAddress- The memory address of the channel
-
field
Retrieves the instance held under the Field fieldName- Parameters:
fieldName- The name of the field to retrieve- Returns:
- A
Instanceinstance containing the defined field.
-
cast
Casts a the object that is contained in a Instance to an object of class clazz. -
cloneInstance
Clones a Instance- Type Parameters:
T- Generically defined return type- Parameters:
from- The object to clone.- Returns:
- a
Instanceinstance.
-
getOrDeserializeJavaObject
-
checkEquals
-