|
libcommonc++
0.7
|
When the Invocation Interface is being used (that is, when a C++ program calls into Java code), the getContext() method of the JavaVirtualMachine class is used to obtain an appropriate JavaContext object.
More...
#include <JavaContext.h++>
Public Member Functions | |
| JavaContext (JNIEnv *env) | |
| Construct a new JavaContext for the given JNI environment pointer. More... | |
| ~JavaContext () | |
| Destructor. More... | |
| jclass | findClass (const String &name) |
| Look up a class by name. More... | |
| jclass | defineClass (const String &name, const byte_t *buf, size_t length) |
| Define a Java class from a buffer of raw bytecode. More... | |
| jmethodID | findMethod (jclass clazz, const String &signature) |
| Look up a method or constructor by signature. More... | |
| jobject | createObject (jclass clazz, jmethodID constructor,...) |
| Instantiate a new Java object. More... | |
| jobject | createObjectVA (jclass clazz, jmethodID constructor, va_list args) |
| Instantiate a new Java object. More... | |
| void | callVoidMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns void. More... | |
| jobject | callObjectMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a Java Object. More... | |
| String | callStringMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a java.lang.String. More... | |
| bool | callBooleanMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a boolean. More... | |
| byte_t | callByteMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a byte. More... | |
| char16_t | callCharMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a char. More... | |
| int16_t | callShortMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a short. More... | |
| int32_t | callIntMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns an int. More... | |
| int64_t | callLongMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a long. More... | |
| float | callFloatMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a float. More... | |
| double | callDoubleMethod (jobject object, jmethodID method,...) |
| Call a Java method that returns a double. More... | |
| void | callNonvirtualVoidMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns void. More... | |
| jobject | callNonvirtualObjectMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a Java object. More... | |
| bool | callNonvirtualBooleanMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a boolean. More... | |
| byte_t | callNonvirtualByteMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a byte. More... | |
| char16_t | callNonvirtualCharMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a char. More... | |
| int16_t | callNonvirtualShortMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a short. More... | |
| int32_t | callNonvirtualIntMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns an int. More... | |
| int64_t | callNonvirtualLongMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a long. More... | |
| float | callNonvirtualFloatMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a float. More... | |
| double | callNonvirtualDoubleMethod (jobject object, jclass clazz, jmethodID method,...) |
| Call a non-virtual Java method that returns a double. More... | |
| void | callStaticVoidMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns void. More... | |
| jobject | callStaticObjectMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a Java Object. More... | |
| String | callStaticStringMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a java.lang.String. More... | |
| bool | callStaticBooleanMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a boolean. More... | |
| byte_t | callStaticByteMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a byte. More... | |
| char16_t | callStaticCharMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a char. More... | |
| int16_t | callStaticShortMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a short. More... | |
| int32_t | callStaticIntMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns an int. More... | |
| int64_t | callStaticLongMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a long. More... | |
| float | callStaticFloatMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a float. More... | |
| double | callStaticDoubleMethod (jclass clazz, jmethodID method,...) |
| Call a static Java method that returns a double. More... | |
| bool | checkException (bool verbose=false) |
| Determine if a Java exception has been thrown in the current thread. More... | |
| void | clearException () |
| Clear any pending Java exception that is currently being thrown in the current thread. More... | |
| jthrowable | getException () |
| Get the pending Java exception, if one is currently being thrown in the current thread. More... | |
| bool | throwException (jclass exception, const String &message) |
| Throw a Java exception. More... | |
| jfieldID | findField (jclass clazz, const String &signature) |
| Look up a field by signature. More... | |
| jobject | getObjectField (jobject object, jfieldID field) |
| Get the value of an Object field in an Object. More... | |
| bool | getBooleanField (jobject object, jfieldID field) |
| Get the value of an boolean field in an Object. More... | |
| byte_t | getByteField (jobject object, jfieldID field) |
| Get the value of a byte field in an Object. More... | |
| char16_t | getCharField (jobject object, jfieldID field) |
| Get the value of a char field in an Object. More... | |
| int16_t | getShortField (jobject object, jfieldID field) |
| Get the value of a short field in an Object. More... | |
| int32_t | getIntField (jobject object, jfieldID field) |
| Get the value of an int field in an Object. More... | |
| int64_t | getLongField (jobject object, jfieldID field) |
| Get the value of a long field in an Object. More... | |
| float | getFloatField (jobject object, jfieldID field) |
| Get the value of a float field in an Object. More... | |
| double | getDoubleField (jobject object, jfieldID field) |
| Get the value of a double field in an Object. More... | |
| String | getStringField (jobject object, jfieldID field) |
| Get the value of a java.lang.String field in an Object. More... | |
| jobject | getStaticObjectField (jclass clazz, jfieldID field) |
| Get the value of a static Object field in a class. More... | |
| bool | getStaticBooleanField (jclass clazz, jfieldID field) |
| Get the value of a static boolean field in a class. More... | |
| byte_t | getStaticByteField (jclass clazz, jfieldID field) |
| Get the value of a static byte field in a class. More... | |
| char16_t | getStaticCharField (jclass clazz, jfieldID field) |
| Get the value of a static char field in a class. More... | |
| int16_t | getStaticShortField (jclass clazz, jfieldID field) |
| Get the value of a static short field in a class. More... | |
| int32_t | getStaticIntField (jclass clazz, jfieldID field) |
| Get the value of a static int field in a class. More... | |
| int64_t | getStaticLongField (jclass clazz, jfieldID field) |
| Get the value of a static long field in a class. More... | |
| float | getStaticFloatField (jclass clazz, jfieldID field) |
| Get the value of a static float field in a class. More... | |
| double | getStaticDoubleField (jclass clazz, jfieldID field) |
| Get the value of a static double field in a class. More... | |
| String | getStaticStringField (jclass clazz, jfieldID field) |
| Get the value of a static String field in a class. More... | |
| void | setObjectField (jobject object, jfieldID field, jobject value) |
| Set the value of an Object field in an object. More... | |
| void | setBooleanField (jobject object, jfieldID field, bool value) |
| Set the value of a boolean field in an object. More... | |
| void | setByteField (jobject object, jfieldID field, byte_t value) |
| Set the value of a byte field in an object. More... | |
| void | setCharField (jobject object, jfieldID field, char16_t value) |
| Set the value of a char field in an object. More... | |
| void | setShortField (jobject object, jfieldID field, int16_t value) |
| Set the value of a short field in an object. More... | |
| void | setIntField (jobject object, jfieldID field, int32_t value) |
| Set the value of an int field in an object. More... | |
| void | setLongField (jobject object, jfieldID field, int64_t value) |
| Set the value of a long field in an object. More... | |
| void | setFloatField (jobject object, jfieldID field, float value) |
| Set the value of a float field in an object. More... | |
| void | setDoubleField (jobject object, jfieldID field, double value) |
| Set the value of a double field in an object. More... | |
| void | setStringField (jobject object, jfieldID field, const String &value) |
| Set the value of a java.lang.String field in an object. More... | |
| void | setStaticObjectField (jclass clazz, jfieldID field, jobject value) |
| Set the value of a static Object field in a class. More... | |
| void | setStaticBooleanField (jclass clazz, jfieldID field, bool value) |
| Set the value of a static boolean field in a class. More... | |
| void | setStaticByteField (jclass clazz, jfieldID field, byte_t value) |
| Set the value of a static byte field in a class. More... | |
| void | setStaticCharField (jclass clazz, jfieldID field, char16_t value) |
| Set the value of a static char field in a class. More... | |
| void | setStaticShortField (jclass clazz, jfieldID field, int16_t value) |
| Set the value of a static short field in a class. More... | |
| void | setStaticIntField (jclass clazz, jfieldID field, int32_t value) |
| Set the value of a static int field in a class. More... | |
| void | setStaticLongField (jclass clazz, jfieldID field, int64_t value) |
| Set the value of a static long field in a class. More... | |
| void | setStaticFloatField (jclass clazz, jfieldID field, float value) |
| Set the value of a static float field in a class. More... | |
| void | setStaticDoubleField (jclass clazz, jfieldID field, double value) |
| Set the value of a static double field in a class. More... | |
| jbyteArray | createByteArray (uint_t length) |
| Create a Java byte array. More... | |
| void | setObjectArrayElement (jobjectArray array, uint_t index, jobject value) |
| Set an element of a Java object array. More... | |
| jobject | getObjectArrayElement (jobjectArray array, uint_t index) |
| Get an element of a Java object array. More... | |
| uint_t | getArrayLength (jarray array) |
| Get the length of a Java array. More... | |
| jobject | createDirectByteBuffer (byte_t *buf, size_t size) |
| Create a new Java DirectByteBuffer. More... | |
| void * | getDirectBufferRegion (jobject buf, uint64_t &size) |
| Get a pointer to and the size of the memory region occupied by a Java DirectBuffer. More... | |
| jobject | createLocalRef (jobject object) |
| Create a local reference to a Java object. More... | |
| void | deleteLocalRef (jobject ref) |
| Delete a local reference. More... | |
| void | ensureLocalCapacity (uint_t capacity) |
| Reserve space for local references. More... | |
| jobject | createGlobalRef (jobject object) |
| Create a global reference to a Java object. More... | |
| void | deleteGlobalRef (jobject ref) |
| Delete a local reference. More... | |
| String | decodeString (jstring str) |
| Decode a java.lang.String into a String. More... | |
| jstring | encodeString (const String &str) |
| Encode a String into a java.lang.String. More... | |
| uint_t | getStringLength (jstring str) |
| Get the length of a Java string. More... | |
| void * | getArrayData (jarray array, uint_t &length, bool *isCopy=NULL) |
| Obtain a pointer to the body of a primitive Java array. More... | |
| void | releaseArrayData (jarray array, void *data) |
| Release the buffer returned by getArrayData(). More... | |
| jbyteArray | createByteArray (const byte_t *data, size_t length) |
| Create a Java byte array. More... | |
| jarray | createObjectArray (jclass type, uint_t length, jobject initialValue=NULL) |
| Create a Java object array. More... | |
| bool | isSameObject (jobject object1, jobject object2) |
| Test two Java object references for equality. More... | |
| bool | isInstanceOf (jobject object, jclass clazz) |
| Test if a Java object is an instance of an interface or another class. More... | |
| bool | isAssignableFrom (jclass clazz1, jclass clazz2) |
| Test if an object of a class or interface can be safely cast to a class or interface of another class. More... | |
| jclass | getClassForObject (jobject object) |
| Get the class for a Java object. More... | |
| jclass | getSuperclass (jclass clazz) |
| Get the superclass for a Java class. More... | |
| void | enterMonitor (jobject object) |
| Enter the monitor associated with a Java object. More... | |
| void | exitMonitor (jobject object) |
| Exit the monitor associated with a Java object. More... | |
| void | registerNativeMethods (jclass clazz, const JavaNativeMethod methods[]) |
| Register native methods for a Java class. More... | |
| void | unregisterNativeMethods (jclass clazz) |
| Unregister all native methods for a Java class. More... | |
| void | pushLocalFrame (uint_t capacity=8) |
| Create a new local reference frame. More... | |
| void | popLocalFrame () |
| Destroy the topmost local reference frame. More... | |
| bool | isVerbose () const |
| Determine if verbose mode is enabled for this context. More... | |
Static Public Member Functions | |
| static String | encodeType (const String &type) |
| Encode a datatype into a JNI datatype descriptor. More... | |
| static bool | parseSignature (const String &signature, String &method, String &descriptor, bool &isStatic) |
| Parse a method signature into a method name, a JNI method descriptor, and a static flag. More... | |
Friends | |
| class | JavaVirtualMachine |
When the Invocation Interface is being used (that is, when a C++ program calls into Java code), the getContext() method of the JavaVirtualMachine class is used to obtain an appropriate JavaContext object.
In C++ code that implements a Java native method, on the other hand, a JavaContext instance must be explicitly constructed from the JNIEnv pointer that was passed into the native function.
This is a lightweight object that should typically be stack-allocated, and may be passed and copied by value.
| JavaContext | ( | JNIEnv * | env | ) |
Construct a new JavaContext for the given JNI environment pointer.
| env | The JNI environment pointer. |
| ~JavaContext | ( | ) |
Destructor.
| bool callBooleanMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a boolean.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| byte_t callByteMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a byte.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| char16_t callCharMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a char.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| double callDoubleMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a double.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| float callFloatMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a float.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int32_t callIntMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns an int.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int64_t callLongMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a long.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| bool callNonvirtualBooleanMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a boolean.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| byte_t callNonvirtualByteMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a byte.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| char16_t callNonvirtualCharMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a char.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| double callNonvirtualDoubleMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a double.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| float callNonvirtualFloatMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a float.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int32_t callNonvirtualIntMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns an int.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int64_t callNonvirtualLongMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a long.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| jobject callNonvirtualObjectMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a Java object.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int16_t callNonvirtualShortMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns a short.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| void callNonvirtualVoidMethod | ( | jobject | object, |
| jclass | clazz, | ||
| jmethodID | method, | ||
| ... | |||
| ) |
Call a non-virtual Java method that returns void.
| object | The object instance. |
| clazz | The method's defining class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| jobject callObjectMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a Java Object.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int16_t callShortMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a short.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| bool callStaticBooleanMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a boolean.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| byte_t callStaticByteMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a byte.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| char16_t callStaticCharMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a char.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| double callStaticDoubleMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a double.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| float callStaticFloatMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a float.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int32_t callStaticIntMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns an int.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int64_t callStaticLongMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a long.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| jobject callStaticObjectMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a Java Object.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| int16_t callStaticShortMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a short.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| String callStaticStringMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns a java.lang.String.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| void callStaticVoidMethod | ( | jclass | clazz, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a static Java method that returns void.
| clazz | The Java class. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| String callStringMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns a java.lang.String.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| void callVoidMethod | ( | jobject | object, |
| jmethodID | method, | ||
| ... | |||
| ) |
Call a Java method that returns void.
| object | The object instance. |
| method | The method to call. |
| JavaException | If the called method throws an exception, or if an invocation error occurs. |
| bool checkException | ( | bool | verbose = false | ) |
Determine if a Java exception has been thrown in the current thread.
| verbose | If true, print the exception stack trace to standard error. |
| void clearException | ( | ) |
Clear any pending Java exception that is currently being thrown in the current thread.
| jbyteArray createByteArray | ( | uint_t | length | ) |
Create a Java byte array.
| length | The length of the array. |
| JavaException | If an error occurs. |
| jbyteArray createByteArray | ( | const byte_t * | data, |
| size_t | length | ||
| ) |
Create a Java byte array.
| data | The data to copy into the array. |
| length | The length of the array. |
| JavaException | If an error occurs. |
| jobject createDirectByteBuffer | ( | byte_t * | buf, |
| size_t | size | ||
| ) |
Create a new Java DirectByteBuffer.
| buf | A pointer to the natively-allocated memory block for the buffer. |
| size | The size of the memory block, in bytes. |
| JavaException | If an error occurs. |
| jobject createGlobalRef | ( | jobject | object | ) |
Create a global reference to a Java object.
| object | The object. |
| JavaException | If an error occurs. |
| jobject createLocalRef | ( | jobject | object | ) |
Create a local reference to a Java object.
| object | The object. |
| JavaException | If an error occurs. |
| jobject createObject | ( | jclass | clazz, |
| jmethodID | constructor, | ||
| ... | |||
| ) |
Instantiate a new Java object.
| clazz | The class. |
| constructor | The constructor to invoke. |
| JavaException | If the constructor throws an exception, or if an invocation error occurs. |
| jarray createObjectArray | ( | jclass | type, |
| uint_t | length, | ||
| jobject | initialValue = NULL |
||
| ) |
Create a Java object array.
| type | The array type. |
| length | The length of the array. |
| initialValue | An optional initial value to store into every element in the new array. |
| JavaException | If an error occurs. |
| jobject createObjectVA | ( | jclass | clazz, |
| jmethodID | constructor, | ||
| va_list | args | ||
| ) |
Instantiate a new Java object.
| clazz | The class. |
| constructor | The constructor to invoke. |
| args | The arguments to pass to the constructor. |
| JavaException | If the constructor throws an exception, or if an invocation error occurs. |
| String decodeString | ( | jstring | str | ) |
Decode a java.lang.String into a String.
| str | The Java string. |
| JavaException | If an error occurs. |
Define a Java class from a buffer of raw bytecode.
| name | The name of the class. |
| buf | The byte buffer containing the bytecode. |
| length | The length of the buffer. |
| JavaException | If the class could not be loaded. |
| void deleteGlobalRef | ( | jobject | ref | ) |
Delete a local reference.
| ref | The reference. |
| void deleteLocalRef | ( | jobject | ref | ) |
Delete a local reference.
| ref | The reference. |
| jstring encodeString | ( | const String & | str | ) |
Encode a String into a java.lang.String.
| str | The String. |
| JavaException | If an error occurs. |
Encode a datatype into a JNI datatype descriptor.
For example, "String[]" is encoded as "[Ljava/lang/String;".
| type | The datatype. |
| void ensureLocalCapacity | ( | uint_t | capacity | ) |
Reserve space for local references.
| capacity | The number of local references to reserve capacity for. |
| JavaException | If an error occurs. |
| void enterMonitor | ( | jobject | object | ) |
Enter the monitor associated with a Java object.
The method blocks if another thread is currently in the monitor.
| object | The object. |
| JavaException | If an error occurs. |
| void exitMonitor | ( | jobject | object | ) |
Exit the monitor associated with a Java object.
| object | The object. |
| JavaException | If an error occurs. |
| jclass findClass | ( | const String & | name | ) |
Look up a class by name.
The class name must be fully qualified (for example, "java.util.Vector"), with the following classes as the only exceptions: String, Object, Class.
| name | The name of the class. |
| JavaException | If the class was not found. |
| jfieldID findField | ( | jclass | clazz, |
| const String & | signature | ||
| ) |
Look up a field by signature.
The signature must be specified in Java source code form, for example "String name" or "static int foo".
| clazz | The Java class. |
| signature | The signature of the field. |
| JavaException | If the field was not found. |
| jmethodID findMethod | ( | jclass | clazz, |
| const String & | signature | ||
| ) |
Look up a method or constructor by signature.
The signature must be specified in Java source code form, without parameter names, for example "int foo(int, byte[])" or "static boolean bar(java.util.Vector, int, String)", or "(int, String, String)" (a constructor).
| clazz | The Java class. |
| signature | The signature of the method. |
| JavaException | If the method was not found. |
| void * getArrayData | ( | jarray | array, |
| uint_t & | length, | ||
| bool * | isCopy = NULL |
||
| ) |
Obtain a pointer to the body of a primitive Java array.
This data may be used and modified safely (without any intervening JNI calls) until a matching call to releaseArrayData().
| array | The primitive array. |
| length | A parameter in which to store the length of the buffer containing the array data. |
| isCopy | If not NULL, a pointer in which to store a flag indicating whether the returned buffer is a copy of the array data. |
| JavaException | If an error occurs. |
| uint_t getArrayLength | ( | jarray | array | ) |
Get the length of a Java array.
| array | The array. |
| JavaException | If an error occurs. |
| bool getBooleanField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of an boolean field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| byte_t getByteField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of a byte field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| char16_t getCharField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of a char field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| jclass getClassForObject | ( | jobject | object | ) |
Get the class for a Java object.
| object | The object. |
| void * getDirectBufferRegion | ( | jobject | buf, |
| uint64_t & | size | ||
| ) |
Get a pointer to and the size of the memory region occupied by a Java DirectBuffer.
| buf | The DirectBuffer object. |
| size | The variable in which to store the size of the memory region. |
| double getDoubleField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of a double field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| jthrowable getException | ( | ) |
Get the pending Java exception, if one is currently being thrown in the current thread.
| float getFloatField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of a float field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| int32_t getIntField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of an int field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| int64_t getLongField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of a long field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| jobject getObjectArrayElement | ( | jobjectArray | array, |
| uint_t | index | ||
| ) |
Get an element of a Java object array.
| array | The array. |
| index | The index of the element. |
| JavaException | If an error occurs. |
| jobject getObjectField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of an Object field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| int16_t getShortField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of a short field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| bool getStaticBooleanField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static boolean field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| byte_t getStaticByteField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static byte field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| char16_t getStaticCharField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static char field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| double getStaticDoubleField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static double field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| float getStaticFloatField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static float field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| int32_t getStaticIntField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static int field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| int64_t getStaticLongField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static long field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| jobject getStaticObjectField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static Object field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| int16_t getStaticShortField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static short field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| String getStaticStringField | ( | jclass | clazz, |
| jfieldID | field | ||
| ) |
Get the value of a static String field in a class.
| clazz | The class. |
| field | The field ID. |
| JavaException | If an error occurs. |
| String getStringField | ( | jobject | object, |
| jfieldID | field | ||
| ) |
Get the value of a java.lang.String field in an Object.
| object | The object. |
| field | The field ID. |
| JavaException | If an error occurs. |
| uint_t getStringLength | ( | jstring | str | ) |
Get the length of a Java string.
| str | The string. |
| jclass getSuperclass | ( | jclass | clazz | ) |
Get the superclass for a Java class.
| clazz | The class. |
java.lang.Object. | bool isAssignableFrom | ( | jclass | clazz1, |
| jclass | clazz2 | ||
| ) |
Test if an object of a class or interface can be safely cast to a class or interface of another class.
| clazz1 | The class of the object to be cast. |
| clazz2 | The class of the cast. |
| bool isInstanceOf | ( | jobject | object, |
| jclass | clazz | ||
| ) |
Test if a Java object is an instance of an interface or another class.
| object | The object. |
| clazz | The class or interface. |
| bool isSameObject | ( | jobject | object1, |
| jobject | object2 | ||
| ) |
Test two Java object references for equality.
| object1 | The first object reference. |
| object2 | The second object reference. |
|
inline |
Determine if verbose mode is enabled for this context.
|
static |
Parse a method signature into a method name, a JNI method descriptor, and a static flag.
For example, "static int foo(int, char[])" results in a method name of "foo", a JNI method descriptor of "(I[C)I", and a static flag of true.
| signature | The signature to parse. |
| method | The string in which to place the method name. |
| descriptor | The string in which to place the JNI method descriptor. |
| isStatic | The flag in which to store the static flag (true if a "static" qualifier is present, false otherwise). |
| void popLocalFrame | ( | ) |
Destroy the topmost local reference frame.
All local references created in the frame will be freed.
| void pushLocalFrame | ( | uint_t | capacity = 8 | ) |
Create a new local reference frame.
| capacity | The minimal local reference capacity of the new frame. |
| JavaException | If an error occurs. |
| void registerNativeMethods | ( | jclass | clazz, |
| const JavaNativeMethod | methods[] | ||
| ) |
Register native methods for a Java class.
| clazz | The class. |
| methods | An array of native methods to register. The last element in the array must have the function field set to NULL. |
| JavaException | If an error occurs. |
| void releaseArrayData | ( | jarray | array, |
| void * | data | ||
| ) |
Release the buffer returned by getArrayData().
The data will be copied back into the original array, if necessary.
| array | The primitive array. |
| data | The buffer containing the array data. |
| void setBooleanField | ( | jobject | object, |
| jfieldID | field, | ||
| bool | value | ||
| ) |
Set the value of a boolean field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setByteField | ( | jobject | object, |
| jfieldID | field, | ||
| byte_t | value | ||
| ) |
Set the value of a byte field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setCharField | ( | jobject | object, |
| jfieldID | field, | ||
| char16_t | value | ||
| ) |
Set the value of a char field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setDoubleField | ( | jobject | object, |
| jfieldID | field, | ||
| double | value | ||
| ) |
Set the value of a double field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setFloatField | ( | jobject | object, |
| jfieldID | field, | ||
| float | value | ||
| ) |
Set the value of a float field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setIntField | ( | jobject | object, |
| jfieldID | field, | ||
| int32_t | value | ||
| ) |
Set the value of an int field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setLongField | ( | jobject | object, |
| jfieldID | field, | ||
| int64_t | value | ||
| ) |
Set the value of a long field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setObjectArrayElement | ( | jobjectArray | array, |
| uint_t | index, | ||
| jobject | value | ||
| ) |
Set an element of a Java object array.
| array | The array. |
| index | The index of the element. |
| value | The new value for the element. |
| JavaException | If an error occurs. |
| void setObjectField | ( | jobject | object, |
| jfieldID | field, | ||
| jobject | value | ||
| ) |
Set the value of an Object field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setShortField | ( | jobject | object, |
| jfieldID | field, | ||
| int16_t | value | ||
| ) |
Set the value of a short field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticBooleanField | ( | jclass | clazz, |
| jfieldID | field, | ||
| bool | value | ||
| ) |
Set the value of a static boolean field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticByteField | ( | jclass | clazz, |
| jfieldID | field, | ||
| byte_t | value | ||
| ) |
Set the value of a static byte field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticCharField | ( | jclass | clazz, |
| jfieldID | field, | ||
| char16_t | value | ||
| ) |
Set the value of a static char field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticDoubleField | ( | jclass | clazz, |
| jfieldID | field, | ||
| double | value | ||
| ) |
Set the value of a static double field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticFloatField | ( | jclass | clazz, |
| jfieldID | field, | ||
| float | value | ||
| ) |
Set the value of a static float field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticIntField | ( | jclass | clazz, |
| jfieldID | field, | ||
| int32_t | value | ||
| ) |
Set the value of a static int field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticLongField | ( | jclass | clazz, |
| jfieldID | field, | ||
| int64_t | value | ||
| ) |
Set the value of a static long field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticObjectField | ( | jclass | clazz, |
| jfieldID | field, | ||
| jobject | value | ||
| ) |
Set the value of a static Object field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStaticShortField | ( | jclass | clazz, |
| jfieldID | field, | ||
| int16_t | value | ||
| ) |
Set the value of a static short field in a class.
| clazz | The class. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| void setStringField | ( | jobject | object, |
| jfieldID | field, | ||
| const String & | value | ||
| ) |
Set the value of a java.lang.String field in an object.
| object | The object. |
| field | The field ID. |
| value | The new value for the field. |
| JavaException | If an error occurs. |
| bool throwException | ( | jclass | exception, |
| const String & | message | ||
| ) |
Throw a Java exception.
| exception | The class of the exception. |
| message | The exception message. |
| void unregisterNativeMethods | ( | jclass | clazz | ) |
Unregister all native methods for a Java class.
| clazz | The class. |
|
friend |