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. | |
| ~JavaContext () | |
| Destructor. | |
| jclass | findClass (const String &name) throw (JavaException) |
| Look up a class by name. | |
| jmethodID | findMethod (jclass clazz, const String &signature) throw (JavaException) |
| Look up a method or constructor by signature. | |
| jobject | createObject (jclass clazz, jmethodID constructor,...) throw (JavaException) |
| Instantiate a new Java object. | |
| jobject | createObjectVA (jclass clazz, jmethodID constructor, va_list args) throw (JavaException) |
| Instantiate a new Java object. | |
| void | callVoidMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns void. | |
| jobject | callObjectMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a Java Object. | |
| String | callStringMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a java.lang.String. | |
| WString | callWStringMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a java.lang.String. | |
| jboolean | callBooleanMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a boolean. | |
| jbyte | callByteMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a byte. | |
| jchar | callCharMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a char. | |
| jshort | callShortMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a short. | |
| jint | callIntMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns an int. | |
| jlong | callLongMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a long. | |
| jfloat | callFloatMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a float. | |
| jdouble | callDoubleMethod (jobject object, jmethodID method,...) throw (JavaException) |
| Call a Java method that returns a double. | |
| void | callNonvirtualVoidMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns void. | |
| jobject | callNonvirtualObjectMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a Java object. | |
| jboolean | callNonvirtualBooleanMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a boolean. | |
| jbyte | callNonvirtualByteMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a byte. | |
| jchar | callNonvirtualCharMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a char. | |
| jshort | callNonvirtualShortMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a short. | |
| jint | callNonvirtualIntMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns an int. | |
| jlong | callNonvirtualLongMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a long. | |
| jfloat | callNonvirtualFloatMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a float. | |
| jdouble | callNonvirtualDoubleMethod (jobject object, jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a non-virtual Java method that returns a double. | |
| void | callStaticVoidMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns void. | |
| jobject | callStaticObjectMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a Java Object. | |
| String | callStaticStringMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a java.lang.String. | |
| WString | callStaticWStringMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a java.lang.String. | |
| jboolean | callStaticBooleanMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a boolean. | |
| jbyte | callStaticByteMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a byte. | |
| jchar | callStaticCharMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a char. | |
| jshort | callStaticShortMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a short. | |
| jint | callStaticIntMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns an int. | |
| jlong | callStaticLongMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a long. | |
| jfloat | callStaticFloatMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a float. | |
| jdouble | callStaticDoubleMethod (jclass clazz, jmethodID method,...) throw (JavaException) |
| Call a static Java method that returns a double. | |
| bool | checkException (bool verbose=false) |
| Determine if a Java exception has been thrown in the current thread. | |
| void | clearException () throw () |
| Clear any pending Java exception that is currently being thrown in the current thread. | |
| jthrowable | getException () throw () |
| Get the pending Java exception, if one is currently being thrown in the current thread. | |
| bool | throwException (jclass exception, const String &message) |
| Throw a Java exception. | |
| jfieldID | findField (jclass clazz, const String &signature) throw (JavaException) |
| Look up a field by signature. | |
| jobject | getObjectField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of an Object field in an Object. | |
| jboolean | getBooleanField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of an boolean field in an Object. | |
| jbyte | getByteField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a byte field in an Object. | |
| jchar | getCharField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a char field in an Object. | |
| jshort | getShortField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a short field in an Object. | |
| jint | getIntField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of an int field in an Object. | |
| jlong | getLongField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a long field in an Object. | |
| jfloat | getFloatField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a float field in an Object. | |
| jdouble | getDoubleField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a double field in an Object. | |
| String | getStringField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a java.lang.String field in an Object. | |
| WString | getWStringField (jobject object, jfieldID field) throw (JavaException) |
| Get the value of a java.lang.String field in an Object. | |
| jobject | getStaticObjectField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static Object field in a class. | |
| jboolean | getStaticBooleanField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static boolean field in a class. | |
| jbyte | getStaticByteField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static byte field in a class. | |
| jchar | getStaticCharField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static char field in a class. | |
| jshort | getStaticShortField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static short field in a class. | |
| jint | getStaticIntField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static int field in a class. | |
| jlong | getStaticLongField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static long field in a class. | |
| jfloat | getStaticFloatField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static float field in a class. | |
| jdouble | getStaticDoubleField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static double field in a class. | |
| String | getStaticStringField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static String field in a class. | |
| WString | getStaticWStringField (jclass clazz, jfieldID field) throw (JavaException) |
| Get the value of a static String field in a class. | |
| void | setObjectField (jobject object, jfieldID field, jobject value) throw (JavaException) |
| Set the value of an Object field in an object. | |
| void | setBooleanField (jobject object, jfieldID field, jboolean value) throw (JavaException) |
| Set the value of a boolean field in an object. | |
| void | setByteField (jobject object, jfieldID field, jbyte value) throw (JavaException) |
| Set the value of a byte field in an object. | |
| void | setCharField (jobject object, jfieldID field, jchar value) throw (JavaException) |
| Set the value of a char field in an object. | |
| void | setShortField (jobject object, jfieldID field, jshort value) throw (JavaException) |
| Set the value of a short field in an object. | |
| void | setIntField (jobject object, jfieldID field, jint value) throw (JavaException) |
| Set the value of an int field in an object. | |
| void | setLongField (jobject object, jfieldID field, jlong value) throw (JavaException) |
| Set the value of a long field in an object. | |
| void | setFloatField (jobject object, jfieldID field, jfloat value) throw (JavaException) |
| Set the value of a float field in an object. | |
| void | setDoubleField (jobject object, jfieldID field, jdouble value) throw (JavaException) |
| Set the value of a double field in an object. | |
| void | setStringField (jobject object, jfieldID field, const String &value) throw (JavaException) |
| Set the value of a java.lang.String field in an object. | |
| void | setWStringField (jobject object, jfieldID field, const WString &value) throw (JavaException) |
| Set the value of a java.lang.String field in an object. | |
| void | setStaticObjectField (jclass clazz, jfieldID field, jobject value) throw (JavaException) |
| Set the value of a static Object field in a class. | |
| void | setStaticBooleanField (jclass clazz, jfieldID field, jboolean value) throw (JavaException) |
| Set the value of a static boolean field in a class. | |
| void | setStaticByteField (jclass clazz, jfieldID field, jbyte value) throw (JavaException) |
| Set the value of a static byte field in a class. | |
| void | setStaticCharField (jclass clazz, jfieldID field, jchar value) throw (JavaException) |
| Set the value of a static char field in a class. | |
| void | setStaticShortField (jclass clazz, jfieldID field, jshort value) throw (JavaException) |
| Set the value of a static short field in a class. | |
| void | setStaticIntField (jclass clazz, jfieldID field, jint value) throw (JavaException) |
| Set the value of a static int field in a class. | |
| void | setStaticLongField (jclass clazz, jfieldID field, jlong value) throw (JavaException) |
| Set the value of a static long field in a class. | |
| void | setStaticFloatField (jclass clazz, jfieldID field, jfloat value) throw (JavaException) |
| Set the value of a static float field in a class. | |
| void | setStaticDoubleField (jclass clazz, jfieldID field, jdouble value) throw (JavaException) |
| Set the value of a static double field in a class. | |
| jbyteArray | createByteArray (uint_t length) throw (JavaException) |
| Create a Java byte array. | |
| void | setObjectArrayElement (jobjectArray array, uint_t index, jobject value) throw (JavaException) |
| Set an element of a Java object array. | |
| jobject | getObjectArrayElement (jobjectArray array, uint_t index) throw (JavaException) |
| Get an element of a Java object array. | |
| uint_t | getArrayLength (jarray array) throw (JavaException) |
| Get the length of a Java array. | |
| jobject | createDirectByteBuffer (byte_t *buf, size_t size) throw (JavaException) |
| Create a new Java DirectByteBuffer. | |
| void * | getDirectBufferRegion (jobject buf, uint64_t &size) |
| Get a pointer to and the size of the memory region occupied by a Java DirectBuffer. | |
| jobject | createLocalRef (jobject object) throw (JavaException) |
| Create a local reference to a Java object. | |
| void | deleteLocalRef (jobject ref) |
| Delete a local reference. | |
| void | ensureLocalCapacity (size_t capacity) throw (JavaException) |
| Reserve space for local references. | |
| jobject | createGlobalRef (jobject object) throw (JavaException) |
| Create a global reference to a Java object. | |
| void | deleteGlobalRef (jobject ref) |
| Delete a local reference. | |
| String | decodeString (jstring str) throw (JavaException) |
| Decode a java.lang.String into a String. | |
| WString | decodeWString (jstring str) throw (JavaException) |
| Decode a java.lang.String into a WString. | |
| jstring | encodeString (const String &str) throw (JavaException) |
| Encode a String into a java.lang.String. | |
| jstring | encodeWString (const WString &str) throw (JavaException) |
| Encode a WString into a java.lang.String. | |
| size_t | getStringLength (jstring str) |
| Get the length of a Java string. | |
| void * | getArrayData (jarray array, size_t &length, bool *isCopy=NULL) throw (JavaException) |
| Obtain a pointer to the body of a primitive Java array. | |
| void | releaseArrayData (jarray array, void *data) |
| Release the buffer returned by getArrayData(). | |
| jbyteArray | createByteArray (const byte_t *data, size_t length) throw (JavaException) |
| Create a Java byte array. | |
| jarray | createObjectArray (jclass type, size_t length, jobject initialValue=NULL) throw (JavaException) |
| Create a Java object array. | |
| bool | isSameObject (jobject object1, jobject object2) |
| Test two Java object references for equality. | |
| bool | isInstanceOf (jobject object, jclass clazz) |
| Test if a Java object is an instance of an interface or another class. | |
| 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. | |
| jclass | getClassForObject (jobject object) |
| Get the class for a Java object. | |
| jclass | getSuperclass (jclass clazz) |
| Get the superclass for a Java class. | |
| void | enterMonitor (jobject object) throw (JavaException) |
| Enter the monitor associated with a Java object. | |
| void | exitMonitor (jobject object) throw (JavaException) |
| Exit the monitor associated with a Java object. | |
| void | registerNativeMethods (jclass clazz, const JavaNativeMethod methods[]) throw (JavaException) |
| Register native methods for a Java class. | |
| void | unregisterNativeMethods (jclass clazz) |
| Unregister all native methods for a Java class. | |
| void | pushLocalFrame (uint_t capacity=8) throw (JavaException) |
| Create a new local reference frame. | |
| void | popLocalFrame () |
| Destroy the topmost local reference frame. | |
| bool | isVerbose () const throw () |
| Determine if verbose mode is enabled for this context. | |
Static Public Member Functions | |
| static String | encodeType (const String &type) |
| Encode a datatype into a JNI datatype descriptor. | |
| 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. | |
Friends | |
| class | JavaVirtualMachine |
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.
| jboolean callBooleanMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jbyte callByteMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jchar callCharMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jdouble callDoubleMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jfloat callFloatMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jint callIntMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jlong callLongMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jboolean callNonvirtualBooleanMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jbyte callNonvirtualByteMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jchar callNonvirtualCharMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jdouble callNonvirtualDoubleMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jfloat callNonvirtualFloatMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jint callNonvirtualIntMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jlong callNonvirtualLongMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jshort callNonvirtualShortMethod | ( | jobject | object, | |
| jclass | clazz, | |||
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jshort callShortMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jboolean callStaticBooleanMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jbyte callStaticByteMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jchar callStaticCharMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jdouble callStaticDoubleMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jfloat callStaticFloatMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jint callStaticIntMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jlong callStaticLongMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| jshort callStaticShortMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| WString callStaticWStringMethod | ( | jclass | clazz, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| String callStringMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| WString callWStringMethod | ( | jobject | object, | |
| jmethodID | method, | |||
| ... | ||||
| ) | throw (JavaException) |
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. |
| 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 | ( | ) | throw () |
Clear any pending Java exception that is currently being thrown in the current thread.
| jbyteArray createByteArray | ( | const byte_t * | data, | |
| size_t | length | |||
| ) | throw (JavaException) |
Create a Java byte array.
| data | The data to copy into the array. | |
| length | The length of the array. |
| JavaException | If an error occurs. |
| jbyteArray createByteArray | ( | uint_t | length | ) | throw (JavaException) |
Create a Java byte array.
| length | The length of the array. |
| JavaException | If an error occurs. |
| jobject createDirectByteBuffer | ( | byte_t * | buf, | |
| size_t | size | |||
| ) | throw (JavaException) |
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 | ) | throw (JavaException) |
Create a global reference to a Java object.
| object | The object. |
| JavaException | If an error occurs. |
| jobject createLocalRef | ( | jobject | object | ) | throw (JavaException) |
Create a local reference to a Java object.
| object | The object. |
| JavaException | If an error occurs. |
| jobject createObject | ( | jclass | clazz, | |
| jmethodID | constructor, | |||
| ... | ||||
| ) | throw (JavaException) |
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, | |
| size_t | length, | |||
| jobject | initialValue = NULL | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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 | ) | throw (JavaException) |
Decode a java.lang.String into a String.
| str | The Java string. |
| JavaException | If an error occurs. |
| WString decodeWString | ( | jstring | str | ) | throw (JavaException) |
Decode a java.lang.String into a WString.
| str | The Java string. |
| JavaException | If an error occurs. |
| 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 | ) | throw (JavaException) |
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. |
| jstring encodeWString | ( | const WString & | str | ) | throw (JavaException) |
Encode a WString into a java.lang.String.
| str | The String. |
| JavaException | If an error occurs. |
| void ensureLocalCapacity | ( | size_t | capacity | ) | throw (JavaException) |
Reserve space for local references.
| capacity | The number of local references to reserve capacity for. |
| JavaException | If an error occurs. |
| void enterMonitor | ( | jobject | object | ) | throw (JavaException) |
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 | ) | throw (JavaException) |
Exit the monitor associated with a Java object.
| object | The object. |
| JavaException | If an error occurs. |
| jclass findClass | ( | const String & | name | ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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.lang.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, | |
| size_t & | length, | |||
| bool * | isCopy = NULL | |||
| ) | throw (JavaException) |
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 | ) | throw (JavaException) |
Get the length of a Java array.
| array | The array. |
| JavaException | If an error occurs. |
| jboolean getBooleanField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of an boolean field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jbyte getByteField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a byte field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jchar getCharField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
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. |
| jdouble getDoubleField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a double field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jthrowable getException | ( | ) | throw () |
Get the pending Java exception, if one is currently being thrown in the current thread.
| jfloat getFloatField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a float field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jint getIntField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of an int field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jlong getLongField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
Get the value of an Object field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jshort getShortField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a short field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jboolean getStaticBooleanField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a static boolean field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jbyte getStaticByteField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a static byte field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jchar getStaticCharField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a static char field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jdouble getStaticDoubleField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a static double field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jfloat getStaticFloatField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a static float field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jint getStaticIntField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a static int field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jlong getStaticLongField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
Get the value of a static Object field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| jshort getStaticShortField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
Get the value of a static String field in a class.
| clazz | The class. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| WString getStaticWStringField | ( | jclass | clazz, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
Get the value of a java.lang.String field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| size_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. | WString getWStringField | ( | jobject | object, | |
| jfieldID | field | |||
| ) | throw (JavaException) |
Get the value of a java.lang.String field in an Object.
| object | The object. | |
| field | The field ID. |
| JavaException | If an error occurs. |
| 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. |
| bool isVerbose | ( | ) | const throw () [inline] |
Determine if verbose mode is enabled for this context.
| bool parseSignature | ( | const String & | signature, | |
| String & | method, | |||
| String & | descriptor, | |||
| bool & | isStatic | |||
| ) | [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 |
) | throw (JavaException) |
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[] | |||
| ) | throw (JavaException) |
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, | |||
| jboolean | value | |||
| ) | throw (JavaException) |
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, | |||
| jbyte | value | |||
| ) | throw (JavaException) |
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, | |||
| jchar | value | |||
| ) | throw (JavaException) |
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, | |||
| jdouble | value | |||
| ) | throw (JavaException) |
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, | |||
| jfloat | value | |||
| ) | throw (JavaException) |
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, | |||
| jint | value | |||
| ) | throw (JavaException) |
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, | |||
| jlong | value | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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, | |||
| jshort | value | |||
| ) | throw (JavaException) |
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, | |||
| jboolean | value | |||
| ) | throw (JavaException) |
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, | |||
| jbyte | value | |||
| ) | throw (JavaException) |
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, | |||
| jchar | value | |||
| ) | throw (JavaException) |
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, | |||
| jdouble | value | |||
| ) | throw (JavaException) |
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, | |||
| jfloat | value | |||
| ) | throw (JavaException) |
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, | |||
| jint | value | |||
| ) | throw (JavaException) |
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, | |||
| jlong | value | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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, | |||
| jshort | value | |||
| ) | throw (JavaException) |
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 | |||
| ) | throw (JavaException) |
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. |
| void setWStringField | ( | jobject | object, | |
| jfieldID | field, | |||
| const WString & | value | |||
| ) | throw (JavaException) |
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 class JavaVirtualMachine [friend] |
1.5.9