Qore jni Module  1.0.1
org.qore.jni.QoreJavaApi Class Reference

This class provides methods that allow Java to interface with Qore code. More...

Static Public Member Methods

static void initQore () throws Throwable
 Initialize the qore library and the jni module from a native Java thread. More...
 
static Object callFunction (String name, Object... args) throws Throwable
 Calls the given Qore function with the given arguments and returns the result.
 
static Object callFunctionArgs (String name, Object[] args) throws Throwable
 Calls a Qore function and returns the result as a Java Object, takes a variable number of arguments.
 
static Object callFunctionSave (String name, Object... args) throws Throwable
 Calls the given Qore function 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...
 
static Object callFunctionSaveArgs (String name, Object[] args) throws Throwable
 Calls the given Qore function 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, takes a variable number of arguments. More...
 
static Object callStaticMethod (String class_name, String method_name, Object... args) throws Throwable
 Calls the given Qore static method with the given arguments and returns the result.
 
static Object callStaticMethodArgs (String class_name, String method_name, Object[] args) throws Throwable
 Calls a Qore static method and returns the result as a Java Object, takes a variable number of arguments.
 
static Object callStaticMethodSave (String class_name, String method_name, Object... args) throws Throwable
 Calls the given Qore static 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...
 
static Object callStaticMethodSaveArgs (String class_name, String method_name, Object[] args) throws Throwable
 Calls the given Qore static 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, takes a variable number of arguments. More...
 
static QoreObject newObjectSave (String class_name, Object... args) throws Throwable
 Creates a new QoreObject from the class name and constructor arguments; a strong reference to the object is stored in thread-local data. More...
 
static QoreObject newObjectSaveArgs (String class_name, Object[] args) throws Throwable
 Creates a new QoreObject from the class name and constructor arguments; a strong reference to the object is stored in thread-local data under the given key. More...
 
static StackTraceElement [] getStackTrace ()
 Returns the current stack trace, not including the call to this method.
 

Detailed Description

This class provides methods that allow Java to interface with Qore code.

Member Function Documentation

◆ callFunctionSave()

static Object org.qore.jni.QoreJavaApi.callFunctionSave ( String  name,
Object...  args 
) throws Throwable
inlinestatic

Calls the given Qore function 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 function to call
argsargument to the function call
Returns
the result of the call
Exceptions
Throwableany Qore-language exception is rethrown here

◆ callFunctionSaveArgs()

static Object org.qore.jni.QoreJavaApi.callFunctionSaveArgs ( String  name,
Object []  args 
) throws Throwable
inlinestatic

Calls the given Qore function 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, takes a variable number of arguments.

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 function to call
argsargument to the function call
Returns
the result of the call
Exceptions
Throwableany Qore-language exception is rethrown here

◆ callStaticMethodSave()

static Object org.qore.jni.QoreJavaApi.callStaticMethodSave ( String  class_name,
String  method_name,
Object...  args 
) throws Throwable
inlinestatic

Calls the given Qore static 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
class_namethe name of the class where the static method is defined; can have a namespace-justified path (ex: "Namespace::ClassName")
method_namethe static method name to call
argsargument to the static method call
Returns
the result of the call
Exceptions
Throwableany Qore-language exception is rethrown here

◆ callStaticMethodSaveArgs()

static Object org.qore.jni.QoreJavaApi.callStaticMethodSaveArgs ( String  class_name,
String  method_name,
Object []  args 
) throws Throwable
inlinestatic

Calls the given Qore static 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, takes a variable number of arguments.

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
class_namethe name of the class where the static method is defined; can have a namespace-justified path (ex: "Namespace::ClassName")
method_namethe static method name to call
argsargument to the static method call
Returns
the result of the call
Exceptions
Throwableany Qore-language exception is rethrown here

◆ initQore()

static void org.qore.jni.QoreJavaApi.initQore ( ) throws Throwable
inlinestatic

Initialize the qore library and the jni module from a native Java thread.

This method allows Qore functionality or Java APIs backed by Qore APIs to be used from native Java threads in an existing JVM process not started by Qore itself.

This requires the platform-dependent qore library to be found in a directory set in the java.library.path or by setting the QORE_LIBRARY environment variable to the absolute path of the qore library.

If neither of these are set, then calling this method will result in a java.lang.UnsatisfiedLinkError exception being raised.

This method is also safe to call when the Qore library and the jni module have been initialized already.

◆ newObjectSave()

static QoreObject org.qore.jni.QoreJavaApi.newObjectSave ( String  class_name,
Object...  args 
) throws Throwable
inlinestatic

Creates a new QoreObject from the class name and constructor arguments; a strong reference to the object is stored in thread-local data.

Parameters
class_namethe class name or namespace-justified path (ex: "Qore::SQL::SQLStatement") of the object to create
argsoptional arguments to the constructor
Returns
the object created
Exceptions
Throwableany Qore-language exception is rethrown here

◆ newObjectSaveArgs()

static QoreObject org.qore.jni.QoreJavaApi.newObjectSaveArgs ( String  class_name,
Object []  args 
) throws Throwable
inlinestatic

Creates a new QoreObject from the class name and constructor arguments; a strong reference to the object is stored in thread-local data under the given key.

Parameters
class_namethe class name or namespace-justified path (ex: "Qore::SQL::SQLStatement") of the object to create
argsoptional arguments to the constructor
Returns
the object created
Exceptions
Throwableany Qore-language exception is rethrown here

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