23 #ifndef __ccxx_JavaContext_hxx 24 #define __ccxx_JavaContext_hxx 36 class JavaVirtualMachine;
109 String& descriptor,
bool& isStatic);
120 jclass findClass(
const String& name);
130 jclass defineClass(
const String& name,
const byte_t* buf,
size_t length);
154 jobject createObject(jclass clazz, jmethodID constructor, ...);
165 jobject createObjectVA(jclass clazz, jmethodID constructor, va_list args);
175 void callVoidMethod(jobject
object, jmethodID method, ...);
186 jobject callObjectMethod(jobject
object, jmethodID method, ...);
197 String callStringMethod(jobject
object, jmethodID method, ...);
208 bool callBooleanMethod(jobject
object, jmethodID method, ...);
219 byte_t callByteMethod(jobject
object, jmethodID method, ...);
230 char16_t callCharMethod(jobject
object, jmethodID method, ...);
241 int16_t callShortMethod(jobject
object, jmethodID method, ...);
252 int32_t callIntMethod(jobject
object, jmethodID method, ...);
263 int64_t callLongMethod(jobject
object, jmethodID method, ...);
274 float callFloatMethod(jobject
object, jmethodID method, ...);
285 double callDoubleMethod(jobject
object, jmethodID method, ...);
296 void callNonvirtualVoidMethod(jobject
object, jclass clazz, jmethodID method,
309 jobject callNonvirtualObjectMethod(jobject
object, jclass clazz,
310 jmethodID method, ...);
322 bool callNonvirtualBooleanMethod(jobject
object, jclass clazz,
323 jmethodID method, ...);
335 byte_t callNonvirtualByteMethod(jobject
object, jclass clazz,
336 jmethodID method, ...);
348 char16_t callNonvirtualCharMethod(jobject
object, jclass clazz,
349 jmethodID method, ...);
361 int16_t callNonvirtualShortMethod(jobject
object, jclass clazz,
362 jmethodID method, ...);
374 int32_t callNonvirtualIntMethod(jobject
object, jclass clazz,
375 jmethodID method, ...);
387 int64_t callNonvirtualLongMethod(jobject
object, jclass clazz,
388 jmethodID method, ...);
400 float callNonvirtualFloatMethod(jobject
object, jclass clazz,
401 jmethodID method, ...);
413 double callNonvirtualDoubleMethod(jobject
object, jclass clazz,
414 jmethodID method, ...);
425 void callStaticVoidMethod(jclass clazz, jmethodID method, ...);
436 jobject callStaticObjectMethod(jclass clazz, jmethodID method, ...);
447 String callStaticStringMethod(jclass clazz, jmethodID method, ...);
458 bool callStaticBooleanMethod(jclass clazz, jmethodID method, ...);
469 byte_t callStaticByteMethod(jclass clazz, jmethodID method, ...);
480 char16_t callStaticCharMethod(jclass clazz, jmethodID method, ...);
491 int16_t callStaticShortMethod(jclass clazz, jmethodID method, ...);
502 int32_t callStaticIntMethod(jclass clazz, jmethodID method, ...);
513 int64_t callStaticLongMethod(jclass clazz, jmethodID method, ...);
524 float callStaticFloatMethod(jclass clazz, jmethodID method, ...);
535 double callStaticDoubleMethod(jclass clazz, jmethodID method, ...);
545 bool checkException(
bool verbose =
false);
551 void clearException();
559 jthrowable getException();
568 bool throwException(jclass exception,
const String& message);
590 jobject getObjectField(jobject
object, jfieldID field);
600 bool getBooleanField(jobject
object, jfieldID field);
610 byte_t getByteField(jobject
object, jfieldID field);
620 char16_t getCharField(jobject
object, jfieldID field);
630 int16_t getShortField(jobject
object, jfieldID field);
640 int32_t getIntField(jobject
object, jfieldID field);
650 int64_t getLongField(jobject
object, jfieldID field);
660 float getFloatField(jobject
object, jfieldID field);
670 double getDoubleField(jobject
object, jfieldID field);
680 String getStringField(jobject
object, jfieldID field);
690 jobject getStaticObjectField(jclass clazz, jfieldID field);
700 bool getStaticBooleanField(jclass clazz, jfieldID field);
710 byte_t getStaticByteField(jclass clazz, jfieldID field);
720 char16_t getStaticCharField(jclass clazz, jfieldID field);
730 int16_t getStaticShortField(jclass clazz, jfieldID field);
740 int32_t getStaticIntField(jclass clazz, jfieldID field);
750 int64_t getStaticLongField(jclass clazz, jfieldID field);
760 float getStaticFloatField(jclass clazz, jfieldID field);
770 double getStaticDoubleField(jclass clazz, jfieldID field);
780 String getStaticStringField(jclass clazz, jfieldID field);
790 void setObjectField(jobject
object, jfieldID field, jobject value);
800 void setBooleanField(jobject
object, jfieldID field,
bool value);
810 void setByteField(jobject
object, jfieldID field,
byte_t value);
820 void setCharField(jobject
object, jfieldID field,
char16_t value);
830 void setShortField(jobject
object, jfieldID field, int16_t value);
840 void setIntField(jobject
object, jfieldID field, int32_t value);
850 void setLongField(jobject
object, jfieldID field, int64_t value);
860 void setFloatField(jobject
object, jfieldID field,
float value);
870 void setDoubleField(jobject
object, jfieldID field,
double value);
880 void setStringField(jobject
object, jfieldID field,
const String& value);
890 void setStaticObjectField(jclass clazz, jfieldID field, jobject value);
900 void setStaticBooleanField(jclass clazz, jfieldID field,
bool value);
910 void setStaticByteField(jclass clazz, jfieldID field,
byte_t value);
920 void setStaticCharField(jclass clazz, jfieldID field,
char16_t value);
930 void setStaticShortField(jclass clazz, jfieldID field, int16_t value);
940 void setStaticIntField(jclass clazz, jfieldID field, int32_t value);
950 void setStaticLongField(jclass clazz, jfieldID field, int64_t value);
960 void setStaticFloatField(jclass clazz, jfieldID field,
float value);
970 void setStaticDoubleField(jclass clazz, jfieldID field,
double value);
979 jbyteArray createByteArray(
uint_t length);
989 void setObjectArrayElement(jobjectArray array,
uint_t index, jobject value);
999 jobject getObjectArrayElement(jobjectArray array,
uint_t index);
1008 uint_t getArrayLength(jarray array);
1019 jobject createDirectByteBuffer(
byte_t* buf,
size_t size);
1031 void* getDirectBufferRegion(jobject buf, uint64_t& size);
1040 jobject createLocalRef(jobject
object);
1047 void deleteLocalRef(jobject ref);
1055 void ensureLocalCapacity(
uint_t capacity);
1064 jobject createGlobalRef(jobject
object);
1071 void deleteGlobalRef(jobject ref);
1080 String decodeString(jstring str);
1089 jstring encodeString(
const String& str);
1097 uint_t getStringLength(jstring str);
1113 void* getArrayData(jarray array,
uint_t &length,
bool* isCopy = NULL);
1122 void releaseArrayData(jarray array,
void* data);
1132 jbyteArray createByteArray(
const byte_t* data,
size_t length);
1144 jarray createObjectArray(jclass type,
uint_t length,
1145 jobject initialValue = NULL);
1155 bool isSameObject(jobject object1, jobject object2);
1166 bool isInstanceOf(jobject
object, jclass clazz);
1176 bool isAssignableFrom(jclass clazz1, jclass clazz2);
1184 jclass getClassForObject(jobject
object);
1193 jclass getSuperclass(jclass clazz);
1202 void enterMonitor(jobject
object);
1210 void exitMonitor(jobject
object);
1220 void registerNativeMethods(jclass clazz,
const JavaNativeMethod methods[]);
1227 void unregisterNativeMethods(jclass clazz);
1235 void pushLocalFrame(
uint_t capacity = 8);
1241 void popLocalFrame();
1245 {
return(_verbose); }
1251 inline bool isAttached()
const 1252 {
return(_env != NULL); }
1254 inline JNIEnv* getEnv()
const 1264 #endif // __ccxx_JavaContext_hxx
#define COMMONCPPJVM_API
Definition: Common.h++:128
String signature
The signature of the native method.
Definition: JavaContext.h++:46
An object that encapsulates (most of) the Java Native Interface (JNI) to a Java Virtual Machine...
Definition: JavaVirtualMachine.h++:53
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
When the Invocation Interface is being used (that is, when a C++ program calls into Java code)...
Definition: JavaContext.h++:67
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
bool isVerbose() const
Determine if verbose mode is enabled for this context.
Definition: JavaContext.h++:1244
uint16_t char16_t
A UTF-16 character.
Definition: Common.h++:201
A structure representing a Java native method.
Definition: JavaContext.h++:43
Definition: AllocationMap.c++:25
unsigned char byte_t
An unsigned 8-bit value.
Definition: Integers.h++:68