Qore jni Module  1.1.0
org.qore.jni.QoreObject Class Reference

wrapper class for a Qore object; this class holds a weak reference to the Qore object More...

Public Member Methods

 QoreObject (long obj)
 creates the wrapper object with a pointer to an object; this JAva object holds a weak reference to the Qore object passed here
 
long get ()
 returns the pointer to the object
 
String className ()
 returns the class name for the object
 
boolean instanceOf (String class_name)
 returns true if the object is an instance of the given class
 
Object callMethod (String name, Object... args) throws Throwable
 calls the given method with the given arguments and returns the result
 
Object callMethodArgs (String name, Object[] args) throws Throwable
 calls the given method with the given arguments and returns the result
 
Object callMethodSave (String name, Object... args) throws Throwable
 Calls the given method with the given arguments and returns the result; if an object is returned, then a strong reference to the object is stored in thread-local data. More...
 
Object callMethodArgsSave (String name, Object[] args) throws Throwable
 Calls the given method with the given arguments and returns the result; if an object is returned, then a strong reference to the object is stored in thread-local data. More...
 
Object getMemberValue (String name) throws Throwable
 returns the value of the given member
 
void release ()
 releases the Qore object without destroying it More...
 
void destroy ()
 runs the destructor
 

Private Member Methods

void finalize () throws Throwable
 releases the weak reference
 

Detailed Description

wrapper class for a Qore object; this class holds a weak reference to the Qore object

Due to the different in garbage collecting approaches (Qore's garbage collector being deterministic and Java's not), strong references to Qore objects must be managed outside of Java.

Note
API usage errors such as with releasing / deleting the object and then calling methods on the object will cause a crash

Member Function Documentation

◆ callMethodArgsSave()

Object org.qore.jni.QoreObject.callMethodArgsSave ( String  name,
Object []  args 
) throws Throwable
inline

Calls the given method with the given arguments and returns the result; if an object is returned, then a strong reference to the object is stored in thread-local data.

This method can be used to save objects in thread-local data that would otherwise go out of scope. The top-level hash key is determined by the value of the "_jni_save" thread-local key, if set, if not then "_jni_save" is used instead as a literal key

Parameters
namethe name of the method to call
argsargument to the function call
Returns
the result of the call
Exceptions
Throwableany Qore-language exception is rethrown here

◆ callMethodSave()

Object org.qore.jni.QoreObject.callMethodSave ( String  name,
Object...  args 
) throws Throwable
inline

Calls the given method with the given arguments and returns the result; if an object is returned, then a strong reference to the object is stored in thread-local data.

This method can be used to save objects in thread-local data that would otherwise go out of scope. The top-level hash key is determined by the value of the "_jni_save" thread-local key, if set, if not then "_jni_save" is used instead as a literal key

Parameters
namethe name of the method to call
argsargument to the function call
Returns
the result of the call
Exceptions
Throwableany Qore-language exception is rethrown here

◆ release()

void org.qore.jni.QoreObject.release ( )
inline

releases the Qore object without destroying it

Note
if the object is returned to Qore, do not release it; allow the weak reference to be released when finalized

The documentation for this class was generated from the following file: