* This commit adds C++ wrapper classes for OpenJDK. Actually I'm done
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 5 Aug 2008 23:56:54 +0000 (19:56 -0400)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 5 Aug 2008 23:56:54 +0000 (19:56 -0400)
with the porting but we need some testing.

--HG--
branch : twisti

12 files changed:
src/native/jni.cpp
src/native/llni.h
src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp
src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp
src/native/vm/openjdk/jvm.cpp
src/native/vm/reflection.cpp
src/native/vm/reflection.hpp
src/native/vm/sun_misc_Unsafe.cpp
src/threads/posix/thread-posix.cpp
src/threads/thread.cpp
src/vmcore/javaobjects.cpp
src/vmcore/javaobjects.hpp

index e64e99949dea1a712acfb9d6d4446d4504c4043b..83419faff6d6fd8c33a1f9062ec2f272f1014c22 100644 (file)
@@ -1462,46 +1462,21 @@ jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method)
        // FIXME We can't access the object here directly.
        if (o->vftbl->clazz == class_java_lang_reflect_Constructor) {
                java_lang_reflect_Constructor rc(method);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               java_lang_reflect_VMConstructor rvmc(rc.get_cons());
-               m = rvmc.get_method();
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-               LLNI_field_get_cls(rc, clazz, c);
-               LLNI_field_get_val(rc, slot , slot);
-
-#else
-# error unknown configuration
-#endif
+               m = rc.get_method();
        }
        else {
                // FIXME We can't access the object here directly.
                assert(o->vftbl->clazz == class_java_lang_reflect_Method);
 
                java_lang_reflect_Method rm(method);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-               java_lang_reflect_VMMethod rvmm(rm.get_m());
-               m = rvmm.get_method();
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-               LLNI_field_get_cls(rm, clazz, c);
-               LLNI_field_get_val(rm, slot , slot);
-
-#else
-# error unknown configuration
-#endif
+               m = rm.get_method();
        }
 
        return (jmethodID) m;
 #else
        vm_abort("jni_FromReflectedMethod: Not implemented in this configuration.");
 
-       /* Keep compiler happy. */
-
+       // Keep compiler happy.
        return NULL;
 #endif
 }
@@ -1517,36 +1492,20 @@ jfieldID jni_FromReflectedField(JNIEnv* env, jobject field)
 {
 #if defined(ENABLE_JAVASE)
 
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-#endif
-
        TRACEJNICALLS(("jni_FromReflectedField(env=%p, field=%p)", env, field));
 
-       if (field == NULL)
-               return NULL;
-
        java_lang_reflect_Field rf(field);
 
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       java_lang_reflect_VMField rvmf(rf.get_f());
-       fieldinfo* f = rvmf.get_field();
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+       if (rf.is_null())
+               return NULL;
 
-       LLNI_field_get_cls(rf, clazz, c);
-       LLNI_field_get_val(rf, slot , slot);
-
-#else
-# error unknown configuration
-#endif
+       fieldinfo* f = rf.get_field();
 
        return (jfieldID) f;
 #else
        vm_abort("jni_FromReflectedField: Not implemented in this configuration.");
 
-       /* Keep compiler happy. */
-
+       // Keep compiler happy.
        return NULL;
 #endif
 }
@@ -1574,10 +1533,10 @@ jobject jni_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, jbool
        java_handle_t* h;
 
        if (m->name == utf_init) {
-               h = java_lang_reflect_Constructor::create(m);
+               h = java_lang_reflect_Constructor(m).get_handle();
        }
        else {
-               h = java_lang_reflect_Method::create(m);
+               h = java_lang_reflect_Method(m).get_handle();
        }
 
        return (jobject) h;
@@ -3576,26 +3535,16 @@ void* jni_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 
 # elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
-       java_nio_Buffer *o;
-       int64_t          address;
-       void            *p;
+       TRACEJNICALLS(("jni_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
 
-       TRACEJNICALLS(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf));
+       java_nio_Buffer jnb(buf);
 
-       /* Prevent compiler warning. */
-
-       h = (java_handle_t *) buf;
-
-       if ((h != NULL) && !builtin_instanceof(h, class_sun_nio_ch_DirectBuffer))
+       if (jnb.is_non_null() && !builtin_instanceof(jnb.get_handle(), class_sun_nio_ch_DirectBuffer))
                return NULL;
 
-       o = (java_nio_Buffer *) buf;
-
-       LLNI_field_get_val(o, address, address);
+       void* address = jnb.get_address();
 
-       p = (void *) (intptr_t) address;
-
-       return p;
+       return address;
 
 # else
 #  error unknown classpath configuration
@@ -3603,10 +3552,9 @@ void* jni_GetDirectBufferAddress(JNIEnv *env, jobject buf)
 
 #else
 
-       vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration");
-
-       /* keep compiler happy */
+       vm_abort("jni_GetDirectBufferAddress: Not implemented in this configuration.");
 
+       // Keep compiler happy.
        return NULL;
 
 #endif
index d36381d4bad7bcce861896b084b0482c8c48d2c0..043d82964baa26a3bcd6e12dc88b8e9857ab4735 100644 (file)
@@ -60,42 +60,6 @@ extern "C" {
 #include "threads/thread.hpp"
 
 
-/* LLNI macros *****************************************************************
-
-   The following macros should be used whenever a Java Object is
-   accessed in native code without the use of an JNI function.
-
-   LLNI_field_set_val, LLNI_field_get_val:
-     Deal with primitive values like integer and float values. Do
-     not use these macros to access pointers or references!
-
-   LLNI_field_set_ref, LLNI_field_get_ref:
-     Deal with references to other objects.
-
-   LLNI_field_set_cls, LLNI_field_get_cls:
-     Deal with references to Java Classes which are internally
-     represented by classinfo or java_lang_Class.
-
-*******************************************************************************/
-
-#define LLNI_field_set_val(obj, field, value) \
-       LLNI_field_direct(obj, field) = (value)
-
-#define LLNI_field_set_ref(obj, field, reference) \
-       LLNI_field_direct(obj, field) = LLNI_UNWRAP(reference)
-
-#define LLNI_field_set_cls(obj, field, value) \
-       LLNI_field_direct(obj, field) = (java_lang_Class *) (value)
-
-#define LLNI_field_get_val(obj, field, variable) \
-       (variable) = LLNI_field_direct(obj, field)
-
-#define LLNI_field_get_ref(obj, field, variable) \
-       (variable) = LLNI_WRAP(LLNI_field_direct(obj, field))
-
-#define LLNI_field_get_cls(obj, field, variable) \
-       (variable) = (classinfo *) LLNI_field_direct(obj, field)
-
 #define LLNI_class_get(obj, variable) \
        (variable) = LLNI_field_direct((java_handle_t *) obj, vftbl->clazz)
 
index 3207ff1e571a41390eb9f53266926ec07220ef7e..6e7ba8bd0a8ddbf0cbc4533e4ecdf3350327275e 100644 (file)
@@ -98,12 +98,10 @@ JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getException
  */
 JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, jobject _this, jobjectArray args)
 {
-       java_lang_reflect_VMConstructor rvmc(_this);
-       java_lang_reflect_Constructor rc(rvmc.get_cons());
-       methodinfo* m = rvmc.get_method();
-       int32_t override = rc.get_flag();
+       java_lang_reflect_VMConstructor jlrvmc(_this);
+       java_lang_reflect_Constructor jlrc(jlrvmc.get_cons());
 
-       java_handle_t* o = java_lang_reflect_Constructor::new_instance(m, (java_handle_objectarray_t*) args, override);
+       java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args);
 
        return (jobject) o;
 }
index 8ec93342cd0dbb872d9e3b262df0da3b3de216e3..a4c6385eb2b29d12b10e46325574e90d864706e7 100644 (file)
@@ -149,7 +149,9 @@ JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env
        }
 
        /* XXX: is that right? or do I have to use resolve_method_*? */
-       return (jobject) java_lang_reflect_Method::create(ref->p.method);
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
 }
 
 
@@ -180,7 +182,9 @@ JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNI
                return NULL;
        }
 
-       return (jobject) java_lang_reflect_Method::create(ref->p.method);
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
 }
 
 
@@ -194,15 +198,17 @@ JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env,
        constant_FMIref *ref;
        classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Fieldref);
+       ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref);
 
        if (ref == NULL) {
                exceptions_throw_illegalargumentexception();
                return NULL;
        }
 
-       return (jobject) java_lang_reflect_Field::create(ref->p.field);
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
 }
 
 
@@ -217,8 +223,7 @@ JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIE
        classinfo *c;
        classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
-       ref = (constant_FMIref*)class_getconstant(
-               cls, index, CONSTANT_Fieldref);
+       ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref);
 
        if (ref == NULL) {
                exceptions_throw_illegalargumentexception();
@@ -233,7 +238,10 @@ JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIE
                return NULL;
        }
 
-       return (jobject) java_lang_reflect_Field::create(ref->p.field);
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
 }
 
 
@@ -259,8 +267,7 @@ JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, jobj
        constant_integer *ref;
        classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
-       ref = (constant_integer*)class_getconstant(
-               cls, index, CONSTANT_Integer);
+       ref = (constant_integer*) class_getconstant(cls, index, CONSTANT_Integer);
 
        if (ref == NULL) {
                exceptions_throw_illegalargumentexception();
index 9fdb319d893709b0ba2f16bd9d5617685167fce8..a22bd39f1950afe39e0f601f49f832298d5d5459 100644 (file)
@@ -1233,7 +1233,7 @@ jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
 
        java_lang_reflect_Method jlrm(method);
 
-       if (jlrm.is_null() == NULL) {
+       if (jlrm.is_null()) {
                exceptions_throw_nullpointerexception();
                return NULL;
        }
@@ -1263,14 +1263,11 @@ jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean pu
 
 jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly)
 {
-       classinfo                 *c;
-       java_handle_objectarray_t *oa;
-
        TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly));
 
-       c = LLNI_classinfo_unwrap(ofClass);
+       classinfo* c = LLNI_classinfo_unwrap(ofClass);
 
-       oa = class_get_declaredmethods(c, publicOnly);
+       java_handle_objectarray_t* oa = class_get_declaredmethods(c, publicOnly);
 
        return (jobjectArray) oa;
 }
@@ -1418,8 +1415,11 @@ jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool,
                return NULL;
        }
 
+       // Create a new java.lang.reflect.Method Java object.
        /* XXX: is that right? or do I have to use resolve_method_*? */
-       return (jobject)reflect_method_new(ref->p.method);
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
 }
 
 
@@ -1449,7 +1449,10 @@ jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject
                return NULL;
        }
 
-       return (jobject)reflect_method_new(ref->p.method);
+       // Create a new java.lang.reflect.Method Java object.
+       java_lang_reflect_Method jlrm(ref->p.method);
+
+       return (jobject) jlrm.get_handle();
 }
 
 
@@ -1470,7 +1473,10 @@ jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool,
                return NULL;
        }
 
-       return (jobject)reflect_field_new(ref->p.field);
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
 }
 
 
@@ -1500,7 +1506,10 @@ jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject
                return NULL;
        }
 
-       return (jobject)reflect_field_new(ref->p.field);
+       // Create a new java.lang.reflect.Field Java object.
+       java_lang_reflect_Field jlrf(ref->p.field);
+
+       return (jobject) jlrf.get_handle();
 }
 
 
@@ -1691,8 +1700,6 @@ jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls)
 
 jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
 {
-       classinfo                             *c;
-       java_lang_AssertionStatusDirectives   *o;
        java_handle_objectarray_t             *classes;
        java_handle_objectarray_t             *packages;
        java_booleanarray_t                   *classEnabled;
@@ -1705,16 +1712,6 @@ jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
 
        TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused));
 
-       c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
-
-       if (c == NULL)
-               return NULL;
-
-       o = (java_lang_AssertionStatusDirectives *) builtin_new(c);
-
-       if (o == NULL)
-               return NULL;
-
 #if defined(ENABLE_ASSERTION)
        classes = builtin_anewarray(assertion_class_count, class_java_lang_Object);
 #else
@@ -1779,12 +1776,9 @@ jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused)
 
        /* set instance fields */
 
-       o->classes  = classes;
-       o->packages = packages;
-       o->classEnabled = classEnabled;
-       o->packageEnabled = packageEnabled;
+       java_lang_AssertionStatusDirectives jlasd(classes, classEnabled, packages, packageEnabled);
 
-       return (jobject) o;
+       return (jobject) jlasd.get_handle();
 }
 
 
@@ -3202,26 +3196,13 @@ void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, un
 
 jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)
 {
-       java_lang_reflect_Method *rm;
-       classinfo     *c;
-       int32_t        slot;
-       int32_t        override;
-       methodinfo    *m;
-       java_handle_t *ro;
-
        TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0));
 
-       rm = (java_lang_reflect_Method *) method;
-
-       LLNI_field_get_cls(rm, clazz,    c);
-       LLNI_field_get_val(rm, slot,     slot);
-       LLNI_field_get_val(rm, override, override);
-
-       m = &(c->methods[slot]);
-
-       ro = reflect_method_invoke(m, (java_handle_t *) obj, (java_handle_objectarray_t *) args0, override);
+       java_lang_reflect_Method jlrm(method);
+       
+       java_handle_t* result = jlrm.invoke((java_handle_t*) obj, (java_handle_objectarray_t*) args0);
 
-       return (jobject) ro;
+       return (jobject) result;
 }
 
 
@@ -3229,24 +3210,10 @@ jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray
 
 jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0)
 {
-       java_lang_reflect_Constructor *rc;
-       classinfo                     *c;
-       int32_t                        slot;
-       int32_t                        override;
-       methodinfo                    *m;
-       java_handle_t                 *o;
-
        TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0));
 
-       rc = (java_lang_reflect_Constructor *) con;
-
-       LLNI_field_get_cls(rc, clazz,    c);
-       LLNI_field_get_val(rc, slot,     slot);
-       LLNI_field_get_val(rc, override, override);
-
-       m = &(c->methods[slot]);
-
-       o = reflect_constructor_newinstance(m, (java_handle_objectarray_t *) args0, override);
+       java_lang_reflect_Constructor jlrc(con);
+       java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args0);
 
        return (jobject) o;
 }
index 5156dc2e994c30137fa411bb7485b0902fcf9b80..831f258124237ed71a7c52b95d8c45e777a141b3 100644 (file)
@@ -121,62 +121,6 @@ java_handle_t* Reflection::invoke(methodinfo *m, java_handle_t *o, java_handle_o
 }
 
 
-/* reflect_method_invoke *******************************************************
-
-   Invokes the given method.
-
-   ARGUMENTS:
-      m .......... methodinfo
-      args ....... method arguments
-      override ... override security checks
-
-   RETURN:
-      return value of the method
-
-*******************************************************************************/
-
-java_handle_t* Reflection::method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override)
-{
-       java_handle_t *ro;
-
-       /* Should we bypass security the checks (AccessibleObject)? */
-
-       if (override == false) {
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-               /* This method is always called like this:
-                      [0] java.lang.reflect.Method.invokeNative (Native Method)
-                      [1] java.lang.reflect.Method.invoke (Method.java:329)
-                      [2] <caller>
-               */
-
-               if (!access_check_method(m, 2))
-                       return NULL;
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-               /* We only pass 1 here as stacktrace_get_caller_class, which
-                  is called from access_check_method, skips
-                  java.lang.reflect.Method.invoke(). */
-
-               if (!access_check_method(m, 1))
-                       return NULL;
-#else
-# error unknown classpath configuration
-#endif
-       }
-
-       /* Check if method class is initialized. */
-
-       if (!(m->clazz->state & CLASS_INITIALIZED))
-               if (!initialize_class(m->clazz))
-                       return NULL;
-
-       /* Call the Java method. */
-
-       ro = invoke(m, o, args);
-
-       return ro;
-}
-
-
 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
 /* reflect_get_declaredannotations *********************************************
 
index 151222fc76443b8b4cc3471bf0a43378e664126d..a43cca156814be42f22760587e0becd8c417e96d 100644 (file)
@@ -40,7 +40,6 @@
 class Reflection {
 public:
        static java_handle_t* invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params);
-       static java_handle_t* method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override);
 
 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS)
        static java_handle_t* get_declaredannotations(java_handle_bytearray_t *annotations, classinfo* declaringClass, classinfo *referer);
index f9dbb59b0992f895bdea22b4e0cc55c964ec5442..85cf8986391ab2bdb91f3444832950c6178768d1 100644 (file)
@@ -576,8 +576,8 @@ JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, jobj
 
 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
-       LLNI_field_get_cls((java_lang_reflect_Field *) field, clazz, c);
-       LLNI_field_get_val((java_lang_reflect_Field *) field, slot , slot);
+       java_lang_reflect_Field rf(field);
+       fieldinfo* f = rf.get_field();
 
 #else
 # error unknown configuration
@@ -771,8 +771,8 @@ JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, jobj
 
 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
-       LLNI_field_get_cls((java_lang_reflect_Field *) rf, clazz, c);
-       LLNI_field_get_val((java_lang_reflect_Field *) rf, slot , slot);
+       java_lang_reflect_Field rf(field);
+       fieldinfo* f = rf.get_field();
 
 #else
 # error unknown configuration
@@ -915,14 +915,14 @@ JNIEXPORT jclass JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3
                return NULL;
 
        java_handle_t* h = LLNI_classinfo_wrap(c);
-       java_lang_Class jlc(h);
 
 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
        // Set ProtectionDomain.
+       java_lang_Class jlc(h);
        jlc.set_pd(protectionDomain);
 #endif
 
-       return (jclass) jlc.get_handle();
+       return (jclass) h;
 }
 
 
index aef67d8e6aa4b7c28609163b11c91a4ca1fd7c96..2e0ac45b590658415a9649d8b69149c60831755d 100644 (file)
@@ -1078,7 +1078,7 @@ bool thread_detach_current_thread(void)
 
 # elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
-               LLNI_field_get_ref(object, uncaughtExceptionHandler, handler);
+               java_handle_t* handler = jlt.get_uncaughtExceptionHandler();
 
 # endif
 
index 8d06573aeb3eca8c511dcd4120f0febe92762886..8f22830257fa25ca24e808bf415ca8785f008398 100644 (file)
@@ -292,19 +292,14 @@ static bool thread_create_object(threadobject *t, java_handle_t *name, java_hand
 
 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
-       /* OpenJDK's java.lang.Thread does not have a VMThread field in
-          the class.  Nothing to do here. */
-
        /* Set the priority.  java.lang.Thread.<init> requires it because
           it sets the priority of the current thread to the parent's one
           (which is the current thread in this case). */
+       jlt.set_priority(NORM_PRIORITY);
 
-       LLNI_field_set_val(to, priority, NORM_PRIORITY);
-
-       /* Call:
-          java.lang.Thread.<init>(Ljava/lang/ThreadGroup;Ljava/lang/String;)V */
+       // Call: java.lang.Thread.<init>(Ljava/lang/ThreadGroup;Ljava/lang/String;)V
 
-       (void) vm_call_method(thread_method_init, o, group, name);
+       (void) vm_call_method(thread_method_init, jlt.get_handle(), group, name);
 
        if (exceptions_get_exception())
                return false;
index 93d08db48593f9f10dcf0a6773a32c5e1e37705f..ccdfc4f85070d874e7888a340e909d8523622273 100644 (file)
@@ -32,6 +32,7 @@
 #include "vm/access.h"
 #include "vm/builtin.h"
 #include "vm/global.h"
+#include "vm/initialize.h"
 
 #include "vmcore/globals.hpp"
 #include "vmcore/javaobjects.hpp"
 
 #if defined(ENABLE_JAVASE)
 
-/**
- * Allocates a new java.lang.reflect.Constructor object and
- * initializes the fields with the method passed.
- */
-java_handle_t* java_lang_reflect_Constructor::create(methodinfo *m)
-{
-       java_handle_t* h;
-
-       /* Allocate a java.lang.reflect.Constructor object. */
-
-       h = builtin_new(class_java_lang_reflect_Constructor);
-
-       if (h == NULL)
-               return NULL;
-
-       java_lang_reflect_Constructor rc(h);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Allocate a java.lang.reflect.VMConstructor object. */
-
-       h = builtin_new(class_java_lang_reflect_VMConstructor);
-
-       if (h == NULL)
-               return NULL;
-
-       java_lang_reflect_VMConstructor rvmc(h, m);
-
-       // Link the two Java objects.
-
-       rc.set_cons(rvmc.get_handle());
-       rvmc.set_cons(rc.get_handle());
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* Calculate the slot. */
-
-       int slot = m - m->clazz->methods;
-
-       /* Set Java object instance fields. */
-
-       LLNI_field_set_cls(rc, clazz               , m->clazz);
-       LLNI_field_set_ref(rc, parameterTypes      , method_get_parametertypearray(m));
-       LLNI_field_set_ref(rc, exceptionTypes      , method_get_exceptionarray(m));
-       LLNI_field_set_val(rc, modifiers           , m->flags & ACC_CLASS_REFLECT_MASK);
-       LLNI_field_set_val(rc, slot                , slot);
-       LLNI_field_set_ref(rc, signature           , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
-       LLNI_field_set_ref(rc, annotations         , method_get_annotations(m));
-       LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
-
-#else
-# error unknown classpath configuration
-#endif
-
-       return rc.get_handle();
-}
-
-
 /**
  * Constructs a Java object with the given
  * java.lang.reflect.Constructor.
  *
- * @param m        Method structure of the constructor.
  * @param args     Constructor arguments.
- * @param override Override security checks.
  *
  * @return Handle to Java object.
  */
-java_handle_t* java_lang_reflect_Constructor::new_instance(methodinfo* m, java_handle_objectarray_t* args, bool override)
+java_handle_t* java_lang_reflect_Constructor::new_instance(java_handle_objectarray_t* args)
 {
-       java_handle_t* h;
+       methodinfo* m = get_method();
 
        // Should we bypass security the checks (AccessibleObject)?
-       if (override == false) {
+       if (get_override() == false) {
                /* This method is always called like this:
                       [0] java.lang.reflect.Constructor.constructNative (Native Method)
                       [1] java.lang.reflect.Constructor.newInstance
@@ -124,7 +65,7 @@ java_handle_t* java_lang_reflect_Constructor::new_instance(methodinfo* m, java_h
        }
 
        // Create a Java object.
-       h = builtin_new(m->clazz);
+       java_handle_t* h = builtin_new(m->clazz);
 
        if (h == NULL)
                return NULL;
@@ -137,143 +78,57 @@ java_handle_t* java_lang_reflect_Constructor::new_instance(methodinfo* m, java_h
 
 
 /**
- * Creates a java.lang.reflect.Field object on the GC heap and
- * intializes it with the given field.
+ * Invokes the given method.
  *
- * @param f Field structure.
+ * @param args Method arguments.
  *
- * @return Handle to Java object.
+ * @return return value of the method
  */
-java_handle_t* java_lang_reflect_Field::create(fieldinfo* f)
+java_handle_t* java_lang_reflect_Method::invoke(java_handle_t* o, java_handle_objectarray_t* args)
 {
-       java_handle_t* h;
-
-       /* Allocate a java.lang.reflect.Field object. */
-
-       h = builtin_new(class_java_lang_reflect_Field);
-
-       if (h == NULL)
-               return NULL;
-
-       java_lang_reflect_Field rf(h);
+       methodinfo* m = get_method();
 
+       // Should we bypass security the checks (AccessibleObject)?
+       if (get_override() == false) {
 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
+               /* This method is always called like this:
+                      [0] java.lang.reflect.Method.invokeNative (Native Method)
+                      [1] java.lang.reflect.Method.invoke (Method.java:329)
+                      [2] <caller>
+               */
 
-       // Allocate a java.lang.reflect.VMField object.
-
-       h = builtin_new(class_java_lang_reflect_VMField);
-
-       if (h == NULL)
-               return NULL;
-
-       java_lang_reflect_VMField rvmf(h, f);
-
-       // Link the two Java objects.
-
-       rf.set_f(rvmf.get_handle());
-       rvmf.set_f(rf.get_handle());
-
+               if (!access_check_method(m, 2))
+                       return NULL;
 #elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
+               /* We only pass 1 here as stacktrace_get_caller_class, which
+                  is called from access_check_method, skips
+                  java.lang.reflect.Method.invoke(). */
 
-       /* Calculate the slot. */
-
-       int slot = f - f->clazz->fields;
-
-       /* Set the Java object fields. */
-
-       LLNI_field_set_cls(rf, clazz,       f->clazz);
-
-       /* The name needs to be interned */
-       /* XXX implement me better! */
-
-       LLNI_field_set_ref(rf, name,        (java_lang_String *) javastring_intern(javastring_new(f->name)));
-       LLNI_field_set_cls(rf, type,        (java_lang_Class *) field_get_type(f));
-       LLNI_field_set_val(rf, modifiers,   f->flags);
-       LLNI_field_set_val(rf, slot,        slot);
-       LLNI_field_set_ref(rf, signature,   f->signature ? (java_lang_String *) javastring_new(f->signature) : NULL);
-       LLNI_field_set_ref(rf, annotations, field_get_annotations(f));
-
+               if (!access_check_method(m, 1))
+                       return NULL;
 #else
 # error unknown classpath configuration
 #endif
+       }
 
-       return rf.get_handle();
-}
-
-
-/*
- * Allocates a new java.lang.reflect.Method object and initializes the
- * fields with the method passed.
- *
- * @param m Method structure.
- *
- * @return Handle to Java object.
- */
-java_handle_t* java_lang_reflect_Method::create(methodinfo *m)
-{
-       java_handle_t* h;
-
-       /* Allocate a java.lang.reflect.Method object. */
-
-       h = builtin_new(class_java_lang_reflect_Method);
-
-       if (h == NULL)
-               return NULL;
-
-       java_lang_reflect_Method rm(h);
-
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
-
-       /* Allocate a java.lang.reflect.VMMethod object. */
-
-       h = builtin_new(class_java_lang_reflect_VMMethod);
-
-       if (h == NULL)
-               return NULL;
-
-       java_lang_reflect_VMMethod rvmm(h, m);
-
-       // Link the two Java objects.
-
-       rm.set_m(rvmm.get_handle());
-       rvmm.set_m(rm.get_handle());
-
-#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
-
-       /* Calculate the slot. */
-
-       int slot = m - m->clazz->methods;
-
-       LLNI_field_set_cls(rm, clazz,                m->clazz);
-
-       /* The name needs to be interned */
-       /* XXX implement me better! */
-
-       LLNI_field_set_ref(rm, name,                 (java_lang_String *) javastring_intern(javastring_new(m->name)));
-       LLNI_field_set_ref(rm, parameterTypes,       method_get_parametertypearray(m));
-       LLNI_field_set_cls(rm, returnType,           (java_lang_Class *) method_returntype_get(m));
-       LLNI_field_set_ref(rm, exceptionTypes,       method_get_exceptionarray(m));
-       LLNI_field_set_val(rm, modifiers,            m->flags & ACC_CLASS_REFLECT_MASK);
-       LLNI_field_set_val(rm, slot,                 slot);
-       LLNI_field_set_ref(rm, signature,            m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL);
-       LLNI_field_set_ref(rm, annotations,          method_get_annotations(m));
-       LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m));
-       LLNI_field_set_ref(rm, annotationDefault,    method_get_annotationdefault(m));
+       // Check if method class is initialized.
+       if (!(m->clazz->state & CLASS_INITIALIZED))
+               if (!initialize_class(m->clazz))
+                       return NULL;
 
-#else
-# error unknown classpath configuration
-#endif
+       // Call the Java method.
+       java_handle_t* result = Reflection::invoke(m, o, args);
 
-       return rm.get_handle();
+       return result;
 }
 
 
 // Legacy C interface.
 
 extern "C" {
-java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m) { return java_lang_reflect_Constructor::create(m); }
-java_handle_t* java_lang_reflect_Field_create(fieldinfo* f) { return java_lang_reflect_Field::create(f); }
-java_handle_t* java_lang_reflect_Method_create(methodinfo* m) { return java_lang_reflect_Method::create(m); }
+       java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m) { return java_lang_reflect_Constructor(m).get_handle(); }
+       java_handle_t* java_lang_reflect_Field_create(fieldinfo* f) { return java_lang_reflect_Field(f).get_handle(); }
+       java_handle_t* java_lang_reflect_Method_create(methodinfo* m) { return java_lang_reflect_Method(m).get_handle(); }
 }
 
 #endif // ENABLE_JAVASE
index 60ce5e968b9e33b487cfba604e1ffec5c62f5899..27105b8e1c503222079668d1e035b7bbed208c2b 100644 (file)
@@ -35,7 +35,9 @@
 
 #include "vm/global.h"
 
+#include "vmcore/class.h"
 #include "vmcore/field.h"
+#include "vmcore/globals.hpp"
 #include "vmcore/method.h"
 
 
@@ -189,7 +191,8 @@ public:
        inline vftbl_t*               get_vftbl () const;
        inline classinfo*             get_Class () const;
 
-       inline bool is_null() const;
+       inline bool is_null    () const;
+       inline bool is_non_null() const;
 };
 
 
@@ -221,6 +224,11 @@ inline bool java_lang_Object::is_null() const
        return (_handle == NULL);
 }
 
+inline bool java_lang_Object::is_non_null() const
+{
+       return (_handle != NULL);
+}
+
 
 /**
  * java/lang/Boolean
@@ -478,6 +486,54 @@ inline void java_lang_Double::set_value(double value)
 }
 
 
+#if defined(ENABLE_JAVASE)
+
+# if defined(ENABLE_ANNOTATIONS)
+/**
+ * OpenJDK sun/reflect/ConstantPool
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. java.lang.Object constantPoolOop;
+ */
+class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+
+public:
+       sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
+       sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
+
+       // Setters.
+       inline void set_constantPoolOop(classinfo* value);
+       inline void set_constantPoolOop(jclass value);
+};
+
+
+inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
+{
+       set_constantPoolOop(constantPoolOop);
+}
+
+
+inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
+{
+       set(_handle, offset_constantPoolOop, value);
+}
+
+inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
+{
+       // XXX jclass is a boxed object.
+       set_constantPoolOop(LLNI_classinfo_unwrap(value));
+}
+# endif // ENABLE_ANNOTATIONS
+
+#endif // ENABLE_JAVASE
+
+
 #if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
 
 /**
@@ -888,60 +944,6 @@ inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value)
 }
 
 
-/**
- * GNU Classpath java/lang/reflect/Constructor
- *
- * Object layout:
- *
- * 0. object header
- * 1. boolean                                     flag;
- * 2. gnu.java.lang.reflect.MethodSignatureParser p;
- * 3. java.lang.reflect.VMConstructor             cons;
- */
-class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
-private:
-       // Static offsets of the object's instance fields.
-       // TODO These offsets need to be checked on VM startup.
-       static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t),         sizeof(int32_t));
-       static const off_t offset_p    = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
-       static const off_t offset_cons = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
-
-public:
-       java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
-       java_lang_reflect_Constructor(jobject h);
-
-       static java_handle_t* create(methodinfo* m);
-       static java_handle_t* new_instance(methodinfo* m, java_handle_objectarray_t* args, bool override);
-
-       // Getters.
-       inline int32_t        get_flag() const;
-       inline java_handle_t* get_cons() const;
-
-       // Setters.
-       inline void set_cons(java_handle_t* value);
-};
-
-inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h)
-{
-       java_lang_reflect_Constructor((java_handle_t*) h);
-}
-
-inline int32_t java_lang_reflect_Constructor::get_flag() const
-{
-       return get<int32_t>(_handle, offset_flag);
-}
-
-inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
-{
-       return get<java_handle_t*>(_handle, offset_cons);
-}
-
-inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
-{
-       set(_handle, offset_cons, value);
-}
-
-
 /**
  * GNU Classpath java/lang/reflect/VMConstructor
  *
@@ -969,7 +971,7 @@ private:
 public:
        java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
        java_lang_reflect_VMConstructor(jobject h);
-       java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m);
+       java_lang_reflect_VMConstructor(methodinfo* m);
 
        // Getters.
        inline classinfo*               get_clazz               () const;
@@ -991,13 +993,19 @@ public:
        inline methodinfo* get_method();
 };
 
+
 inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(jobject h) : java_lang_Object(h)
 {
        java_lang_reflect_VMConstructor((java_handle_t*) h);
 }
 
-inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m) : java_lang_Object(h)
+inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m)
 {
+       _handle = builtin_new(class_java_lang_reflect_VMConstructor);
+
+       if (is_null())
+               return;
+
        int                      slot                 = m - m->clazz->methods;
        java_handle_bytearray_t* annotations          = method_get_annotations(m);
        java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
@@ -1008,6 +1016,7 @@ inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(java_han
        set_parameterAnnotations(parameterAnnotations);
 }
 
+
 inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
 {
        return get<classinfo*>(_handle, offset_clazz);
@@ -1078,55 +1087,92 @@ inline methodinfo* java_lang_reflect_VMConstructor::get_method()
 
 
 /**
- * GNU Classpath java/lang/reflect/Field
+ * GNU Classpath java/lang/reflect/Constructor
  *
  * Object layout:
  *
  * 0. object header
- * 1. boolean                                    flag;
- * 2. gnu.java.lang.reflect.FieldSignatureParser p;
- * 3. java.lang.reflect.VMField                  f;
+ * 1. boolean                                     flag;
+ * 2. gnu.java.lang.reflect.MethodSignatureParser p;
+ * 3. java.lang.reflect.VMConstructor             cons;
  */
-class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
+class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
 private:
        // Static offsets of the object's instance fields.
        // TODO These offsets need to be checked on VM startup.
        static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t),         sizeof(int32_t));
        static const off_t offset_p    = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
-       static const off_t offset_f    = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_cons = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
 
 public:
-       java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
-       java_lang_reflect_Field(jobject h);
+       java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Constructor(jobject h);
+       java_lang_reflect_Constructor(methodinfo* m);
 
-       static java_handle_t* create(fieldinfo* f);
+       java_handle_t* new_instance(java_handle_objectarray_t* args);
 
        // Getters.
        inline int32_t        get_flag() const;
-       inline java_handle_t* get_f() const;
+       inline java_handle_t* get_cons() const;
 
        // Setters.
-       inline void set_f(java_handle_t* value);
+       inline void set_cons(java_handle_t* value);
+
+       // Convenience functions.
+       inline methodinfo* get_method  () const;
+       inline int32_t     get_override() const;
 };
 
-inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h)
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h)
 {
-       java_lang_reflect_Field((java_handle_t*) h);
+       java_lang_reflect_Constructor((java_handle_t*) h);
 }
 
-inline int32_t java_lang_reflect_Field::get_flag() const
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
+{
+       java_lang_reflect_VMConstructor jlrvmc(m);
+
+       if (jlrvmc.is_null())
+               return;
+
+       _handle = builtin_new(class_java_lang_reflect_Constructor);
+
+       if (is_null())
+               return;
+
+       // Link the two Java objects.
+       set_cons(jlrvmc.get_handle());
+       jlrvmc.set_cons(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Constructor::get_flag() const
 {
        return get<int32_t>(_handle, offset_flag);
 }
 
-inline java_handle_t* java_lang_reflect_Field::get_f() const
+inline java_handle_t* java_lang_reflect_Constructor::get_cons() const
 {
-       return get<java_handle_t*>(_handle, offset_f);
+       return get<java_handle_t*>(_handle, offset_cons);
 }
 
-inline void java_lang_reflect_Field::set_f(java_handle_t* value)
+
+inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value)
 {
-       set(_handle, offset_f, value);
+       set(_handle, offset_cons, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Constructor::get_method() const
+{
+       java_lang_reflect_VMConstructor jlrvmc(get_cons());
+       return jlrvmc.get_method();
+}
+
+inline int32_t java_lang_reflect_Constructor::get_override() const
+{
+       return get_flag();
 }
 
 
@@ -1157,7 +1203,7 @@ private:
 public:
        java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {}
        java_lang_reflect_VMField(jobject h);
-       java_lang_reflect_VMField(java_handle_t* h, fieldinfo* f);
+       java_lang_reflect_VMField(fieldinfo* f);
 
        // Getters.
        inline classinfo*               get_clazz              () const;
@@ -1178,13 +1224,19 @@ public:
        inline fieldinfo* get_field() const;
 };
 
+
 inline java_lang_reflect_VMField::java_lang_reflect_VMField(jobject h) : java_lang_Object(h)
 {
        java_lang_reflect_VMField((java_handle_t*) h);
 }
 
-inline java_lang_reflect_VMField::java_lang_reflect_VMField(java_handle_t* h, fieldinfo* f) : java_lang_Object(h)
+inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f)
 {
+       _handle = builtin_new(class_java_lang_reflect_VMField);
+
+       if (is_null())
+               return;
+
        java_handle_t*           name        = javastring_intern(javastring_new(f->name));
        int                      slot        = f - f->clazz->fields;
        java_handle_bytearray_t* annotations = field_get_annotations(f);
@@ -1195,6 +1247,7 @@ inline java_lang_reflect_VMField::java_lang_reflect_VMField(java_handle_t* h, fi
        set_annotations(annotations);
 }
 
+
 inline classinfo* java_lang_reflect_VMField::get_clazz() const
 {
        return get<classinfo*>(_handle, offset_clazz);
@@ -1220,6 +1273,7 @@ inline java_handle_t* java_lang_reflect_VMField::get_f() const
        return get<java_handle_t*>(_handle, offset_f);
 }
 
+
 inline void java_lang_reflect_VMField::set_clazz(classinfo* value)
 {
        set(_handle, offset_clazz, value);
@@ -1260,55 +1314,74 @@ inline fieldinfo* java_lang_reflect_VMField::get_field() const
 
 
 /**
- * GNU Classpath java/lang/reflect/Method
+ * GNU Classpath java/lang/reflect/Field
  *
  * Object layout:
  *
  * 0. object header
- * 1. boolean                                     flag;
- * 2. gnu.java.lang.reflect.MethodSignatureParser p;
- * 3. java.lang.reflect.VMMethod                  m;
+ * 1. boolean                                    flag;
+ * 2. gnu.java.lang.reflect.FieldSignatureParser p;
+ * 3. java.lang.reflect.VMField                  f;
  */
-class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
+class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
 private:
        // Static offsets of the object's instance fields.
        // TODO These offsets need to be checked on VM startup.
        static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t),         sizeof(int32_t));
        static const off_t offset_p    = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
-       static const off_t offset_m    = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_f    = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
 
 public:
-       java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
-       java_lang_reflect_Method(jobject h);
-
-       static java_handle_t* create(methodinfo* m);
+       java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Field(jobject h);
+       java_lang_reflect_Field(fieldinfo* f);
 
        // Getters.
        inline int32_t        get_flag() const;
-       inline java_handle_t* get_m() const;
+       inline java_handle_t* get_f() const;
 
        // Setters.
-       inline void set_m(java_handle_t* value);
+       inline void set_f(java_handle_t* value);
 };
 
-inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h)
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h)
 {
-       java_lang_reflect_Method((java_handle_t*) h);
+       java_lang_reflect_Field((java_handle_t*) h);
 }
 
-inline int32_t java_lang_reflect_Method::get_flag() const
+inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
+{
+       java_lang_reflect_VMField jlrvmf(f);
+
+       if (jlrvmf.is_null())
+               return;
+
+       _handle = builtin_new(class_java_lang_reflect_Field);
+
+       if (is_null())
+               return;
+
+       // Link the two Java objects.
+       set_f(jlrvmf.get_handle());
+       jlrvmf.set_f(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Field::get_flag() const
 {
        return get<int32_t>(_handle, offset_flag);
 }
 
-inline java_handle_t* java_lang_reflect_Method::get_m() const
+inline java_handle_t* java_lang_reflect_Field::get_f() const
 {
-       return get<java_handle_t*>(_handle, offset_m);
+       return get<java_handle_t*>(_handle, offset_f);
 }
 
-inline void java_lang_reflect_Method::set_m(java_handle_t* value)
+
+inline void java_lang_reflect_Field::set_f(java_handle_t* value)
 {
-       set(_handle, offset_m, value);
+       set(_handle, offset_f, value);
 }
 
 
@@ -1343,7 +1416,7 @@ private:
 public:
        java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {}
        java_lang_reflect_VMMethod(jobject h);
-       java_lang_reflect_VMMethod(java_handle_t* h, methodinfo* m);
+       java_lang_reflect_VMMethod(methodinfo* m);
 
        // Getters.
        inline classinfo*               get_clazz               () const;
@@ -1373,8 +1446,13 @@ inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(jobject h) : java_
        java_lang_reflect_VMMethod((java_handle_t*) h);
 }
 
-inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(java_handle_t* h, methodinfo* m) : java_lang_Object(h)
+inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m)
 {
+       _handle = builtin_new(class_java_lang_reflect_VMMethod);
+
+       if (is_null())
+               return;
+
        java_handle_t*           name                 = javastring_intern(javastring_new(m->name));
        int                      slot                 = m - m->clazz->methods;
        java_handle_bytearray_t* annotations          = method_get_annotations(m);
@@ -1474,37 +1552,109 @@ inline methodinfo* java_lang_reflect_VMMethod::get_method() const
 
 
 /**
- * GNU Classpath java/nio/Buffer
+ * GNU Classpath java/lang/reflect/Method
  *
  * Object layout:
  *
  * 0. object header
- * 1. int                   cap;
- * 2. int                   limit;
- * 3. int                   pos;
- * 4. int                   mark;
- * 5. gnu.classpath.Pointer address;
+ * 1. boolean                                     flag;
+ * 2. gnu.java.lang.reflect.MethodSignatureParser p;
+ * 3. java.lang.reflect.VMMethod                  m;
  */
-class java_nio_Buffer : public java_lang_Object, private FieldAccess {
+class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
 private:
        // Static offsets of the object's instance fields.
        // TODO These offsets need to be checked on VM startup.
-       static const off_t offset_cap     = MEMORY_ALIGN(sizeof(java_object_t),          sizeof(int32_t));
-       static const off_t offset_limit   = MEMORY_ALIGN(offset_cap   + sizeof(int32_t), sizeof(int32_t));
-       static const off_t offset_pos     = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
-       static const off_t offset_mark    = MEMORY_ALIGN(offset_pos   + sizeof(int32_t), sizeof(int32_t));
-       static const off_t offset_address = MEMORY_ALIGN(offset_mark  + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t),         sizeof(int32_t));
+       static const off_t offset_p    = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_m    = MEMORY_ALIGN(offset_p    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
 
 public:
-       java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Method(jobject h);
+       java_lang_reflect_Method(methodinfo* m);
 
        // Getters.
-       inline int32_t get_cap() const;
+       inline int32_t        get_flag() const;
+       inline java_handle_t* get_m() const;
+
+       // Setters.
+       inline void set_m(java_handle_t* value);
 };
 
-inline int32_t java_nio_Buffer::get_cap() const
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h)
 {
-       return get<int32_t>(_handle, offset_cap);
+       java_lang_reflect_Method((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
+{
+       java_lang_reflect_VMMethod jlrvmm(m);
+
+       if (jlrvmm.is_null())
+               return;
+
+       _handle = builtin_new(class_java_lang_reflect_Method);
+
+       if (is_null())
+               return;
+
+       // Link the two Java objects.
+       set_m(jlrvmm.get_handle());
+       jlrvmm.set_m(get_handle());
+}
+
+
+inline int32_t java_lang_reflect_Method::get_flag() const
+{
+       return get<int32_t>(_handle, offset_flag);
+}
+
+inline java_handle_t* java_lang_reflect_Method::get_m() const
+{
+       return get<java_handle_t*>(_handle, offset_m);
+}
+
+
+inline void java_lang_reflect_Method::set_m(java_handle_t* value)
+{
+       set(_handle, offset_m, value);
+}
+
+
+/**
+ * GNU Classpath java/nio/Buffer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int                   cap;
+ * 2. int                   limit;
+ * 3. int                   pos;
+ * 4. int                   mark;
+ * 5. gnu.classpath.Pointer address;
+ */
+class java_nio_Buffer : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_cap     = MEMORY_ALIGN(sizeof(java_object_t),          sizeof(int32_t));
+       static const off_t offset_limit   = MEMORY_ALIGN(offset_cap   + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_pos     = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_mark    = MEMORY_ALIGN(offset_pos   + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_address = MEMORY_ALIGN(offset_mark  + sizeof(int32_t), SIZEOF_VOID_P);
+
+public:
+       java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
+
+       // Getters.
+       inline int32_t get_cap() const;
+};
+
+inline int32_t java_nio_Buffer::get_cap() const
+{
+       return get<int32_t>(_handle, offset_cap);
 }
 
 
@@ -1601,54 +1751,56 @@ inline void gnu_classpath_Pointer::set_data(void* value)
        set(_handle, offset_data, value);
 }
 
+#endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
+
+
+#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
-# if defined(ENABLE_ANNOTATIONS)
 /**
- * GNU Classpath sun/reflect/ConstantPool
+ * OpenJDK java/lang/AssertionStatusDirectives
  *
  * Object layout:
  *
  * 0. object header
- * 1. java.lang.Object constantPoolOop;
+ * 1. java.lang.String[] classes;
+ * 2. boolean[]          classEnabled;
+ * 3. java.lang.String[] packages;
+ * 4. boolean[]          packageEnabled;
+ * 5. boolean            deflt;
  */
-class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess {
+class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess {
 private:
        // Static offsets of the object's instance fields.
        // TODO These offsets need to be checked on VM startup.
-       static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P);
+       static const off_t offset_classes        = MEMORY_ALIGN(sizeof(java_object_t),                 SIZEOF_VOID_P);
+       static const off_t offset_classEnabled   = MEMORY_ALIGN(offset_classes        + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_packages       = MEMORY_ALIGN(offset_classEnabled   + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages       + SIZEOF_VOID_P, SIZEOF_VOID_P);
+       static const off_t offset_deflt          = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t));
 
 public:
-       sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {}
-       sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop);
-
-       // Setters.
-       inline void set_constantPoolOop(classinfo* value);
-       inline void set_constantPoolOop(jclass value);
+       java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled);
 };
 
-
-inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h)
+inline java_lang_AssertionStatusDirectives::java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled)
 {
-       set_constantPoolOop(constantPoolOop);
-}
-
+       classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives"));
 
-inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value)
-{
-       set(_handle, offset_constantPoolOop, value);
-}
+       // FIXME Load the class at VM startup.
+       if (c == NULL)
+               return;
 
-inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value)
-{
-       // XXX jclass is a boxed object.
-       set_constantPoolOop(LLNI_classinfo_unwrap(value));
-}
-# endif // ENABLE_ANNOTATIONS
+       _handle = builtin_new(c);
 
-#endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH
+       if (is_null())
+               return;
 
+       set(_handle, offset_classes,        classes);
+       set(_handle, offset_classEnabled,   classEnabled);
+       set(_handle, offset_packages,       packages);
+       set(_handle, offset_packageEnabled, packageEnabled);
+}
 
-#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
 
 /**
  * OpenJDK java/lang/StackTraceElement
@@ -1689,6 +1841,192 @@ inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* d
 }
 
 
+/**
+ * OpenJDK java/lang/String
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. char[] value;
+ * 2. int    offset;
+ * 3. int    count;
+ * 4. int    hash;
+ */
+class java_lang_String : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_value  = MEMORY_ALIGN(sizeof(java_object_t),           SIZEOF_VOID_P);
+       static const off_t offset_offset = MEMORY_ALIGN(offset_value  + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_count  = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_hash   = MEMORY_ALIGN(offset_count  + sizeof(int32_t), sizeof(int32_t));
+
+public:
+       java_lang_String(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_String(jstring h);
+       java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0);
+
+       // Getters.
+       inline java_handle_chararray_t* get_value () const;
+       inline int32_t                  get_offset() const;
+       inline int32_t                  get_count () const;
+
+       // Setters.
+       inline void set_value (java_handle_chararray_t* value);
+       inline void set_offset(int32_t value);
+       inline void set_count (int32_t value);
+};
+
+inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h)
+{
+       java_lang_String((java_handle_t*) h);
+}
+
+inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h)
+{
+       set_value(value);
+       set_offset(offset);
+       set_count(count);
+}
+
+inline java_handle_chararray_t* java_lang_String::get_value() const
+{
+       return get<java_handle_chararray_t*>(_handle, offset_value);
+}
+
+inline int32_t java_lang_String::get_offset() const
+{
+       return get<int32_t>(_handle, offset_offset);
+}
+
+inline int32_t java_lang_String::get_count() const
+{
+       return get<int32_t>(_handle, offset_count);
+}
+
+inline void java_lang_String::set_value(java_handle_chararray_t* value)
+{
+       set(_handle, offset_value, value);
+}
+
+inline void java_lang_String::set_offset(int32_t value)
+{
+       set(_handle, offset_offset, value);
+}
+
+inline void java_lang_String::set_count(int32_t value)
+{
+       set(_handle, offset_count, value);
+}
+
+
+/**
+ * OpenJDK java/lang/Thread
+ *
+ * Object layout:
+ *
+ * 0.  object header
+ * 1.  char[]                                    name;
+ * 2.  int                                       priority;
+ * 3.  java_lang_Thread                          threadQ;
+ * 4.  long                                      eetop;
+ * 5.  boolean                                   single_step;
+ * 6.  boolean                                   daemon;
+ * 7.  boolean                                   stillborn;
+ * 8.  java_lang_Runnable                        target;
+ * 9.  java_lang_ThreadGroup                     group;
+ * 10. java_lang_ClassLoader                     contextClassLoader;
+ * 11. java_security_AccessControlContext        inheritedAccessControlContext;
+ * 12. java_lang_ThreadLocal_ThreadLocalMap      threadLocals;
+ * 13. java_lang_ThreadLocal_ThreadLocalMap      inheritableThreadLocals;
+ * 14. long                                      stackSize;
+ * 15. long                                      nativeParkEventPointer;
+ * 16. long                                      tid;
+ * 17. int                                       threadStatus;
+ * 18. java_lang_Object                          parkBlocker;
+ * 19. sun_nio_ch_Interruptible                  blocker;
+ * 20. java_lang_Object                          blockerLock;
+ * 21. boolean                                   stopBeforeStart;
+ * 22. java_lang_Throwable                       throwableFromStop;
+ * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler;
+ */
+class java_lang_Thread : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_name                          = MEMORY_ALIGN(sizeof(java_object_t),                                  SIZEOF_VOID_P);
+       static const off_t offset_priority                      = MEMORY_ALIGN(offset_name                          + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_threadQ                       = MEMORY_ALIGN(offset_priority                      + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_eetop                         = MEMORY_ALIGN(offset_threadQ                       + SIZEOF_VOID_P,   sizeof(int64_t));
+       static const off_t offset_single_step                   = MEMORY_ALIGN(offset_eetop                         + sizeof(int64_t), sizeof(int32_t));
+       static const off_t offset_daemon                        = MEMORY_ALIGN(offset_single_step                   + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_stillborn                     = MEMORY_ALIGN(offset_daemon                        + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_target                        = MEMORY_ALIGN(offset_stillborn                     + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_group                         = MEMORY_ALIGN(offset_target                        + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_contextClassLoader            = MEMORY_ALIGN(offset_group                         + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_threadLocals                  = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_inheritableThreadLocals       = MEMORY_ALIGN(offset_threadLocals                  + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_stackSize                     = MEMORY_ALIGN(offset_inheritableThreadLocals       + SIZEOF_VOID_P,   sizeof(int64_t));
+       static const off_t offset_nativeParkEventPointer        = MEMORY_ALIGN(offset_stackSize                     + sizeof(int64_t), sizeof(int64_t));
+       static const off_t offset_tid                           = MEMORY_ALIGN(offset_nativeParkEventPointer        + sizeof(int64_t), sizeof(int64_t));
+       static const off_t offset_threadStatus                  = MEMORY_ALIGN(offset_tid                           + sizeof(int64_t), sizeof(int32_t));
+       static const off_t offset_parkBlocker                   = MEMORY_ALIGN(offset_threadStatus                  + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_blocker                       = MEMORY_ALIGN(offset_parkBlocker                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_blockerLock                   = MEMORY_ALIGN(offset_blocker                       + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_stopBeforeStart               = MEMORY_ALIGN(offset_blockerLock                   + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_throwableFromStop             = MEMORY_ALIGN(offset_stopBeforeStart               + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_uncaughtExceptionHandler      = MEMORY_ALIGN(offset_throwableFromStop             + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
+//     java_lang_Thread(threadobject* t);
+
+       // Getters.
+       inline int32_t        get_priority                () const;
+       inline int32_t        get_daemon                  () const;
+       inline java_handle_t* get_group                   () const;
+       inline java_handle_t* get_uncaughtExceptionHandler() const;
+
+       // Setters.
+       inline void set_priority(int32_t value);
+       inline void set_group   (java_handle_t* value);
+};
+
+
+inline int32_t java_lang_Thread::get_priority() const
+{
+       return get<int32_t>(_handle, offset_priority);
+}
+
+inline int32_t java_lang_Thread::get_daemon() const
+{
+       return get<int32_t>(_handle, offset_daemon);
+}
+
+inline java_handle_t* java_lang_Thread::get_group() const
+{
+       return get<java_handle_t*>(_handle, offset_group);
+}
+
+inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const
+{
+       return get<java_handle_t*>(_handle, offset_uncaughtExceptionHandler);
+}
+
+
+inline void java_lang_Thread::set_priority(int32_t value)
+{
+       set(_handle, offset_priority, value);
+}
+
+inline void java_lang_Thread::set_group(java_handle_t* value)
+{
+       set(_handle, offset_group, value);
+}
+
+
+
 /**
  * OpenJDK java/lang/Throwable
  *
@@ -1779,120 +2117,437 @@ inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value)
  * 13. java.lang.reflect.Constructor                         root;
  * 14. java.util.Map                                         declaredAnnotations;
  */
-class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess {
+class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess {
 private:
        // Static offsets of the object's instance fields.
        // TODO These offsets need to be checked on VM startup.
-       static const off_t offset_clazz                = MEMORY_ALIGN(sizeof(java_object_t),                         SIZEOF_VOID_P);
+       static const off_t offset_override             = MEMORY_ALIGN(sizeof(java_object_t),                         sizeof(int32_t));
+       static const off_t offset_clazz                = MEMORY_ALIGN(offset_override             + sizeof(int32_t), SIZEOF_VOID_P);
        static const off_t offset_slot                 = MEMORY_ALIGN(offset_clazz                + SIZEOF_VOID_P,   sizeof(int32_t));
-       static const off_t offset_annotations          = MEMORY_ALIGN(offset_slot                 + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_parameterTypes       = MEMORY_ALIGN(offset_slot                 + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_exceptionTypes       = MEMORY_ALIGN(offset_parameterTypes       + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_modifiers            = MEMORY_ALIGN(offset_exceptionTypes       + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_signature            = MEMORY_ALIGN(offset_modifiers            + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_genericInfo          = MEMORY_ALIGN(offset_signature            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotations          = MEMORY_ALIGN(offset_genericInfo          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
        static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
-       static const off_t offset_declaredAnnotations  = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P,   SIZEOF_VOID_P);
-       static const off_t offset_cons                 = MEMORY_ALIGN(offset_declaredAnnotations  + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckCache   = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_constructorAccessor  = MEMORY_ALIGN(offset_securityCheckCache   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_root                 = MEMORY_ALIGN(offset_constructorAccessor  + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations  = MEMORY_ALIGN(offset_root                 + SIZEOF_VOID_P,   SIZEOF_VOID_P);
 
 public:
-       java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {}
-       java_lang_reflect_VMConstructor(jobject h);
-       java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m);
+       java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Constructor(jobject h);
+       java_lang_reflect_Constructor(methodinfo* m);
+
+       java_handle_t* new_instance(java_handle_objectarray_t* args);
 
        // Getters.
-       inline classinfo*               get_clazz               () const;
-       inline int32_t                  get_slot                () const;
-       inline java_handle_bytearray_t* get_annotations         () const;
-       inline java_handle_bytearray_t* get_parameterAnnotations() const;
-       inline java_handle_t*           get_declaredAnnotations () const;
-       inline java_handle_t*           get_cons                () const;
+       inline int32_t                  get_override   () const;
+       inline classinfo*               get_clazz      () const;
+       inline int32_t                  get_slot       () const;
+       inline java_handle_bytearray_t* get_annotations() const;
 
        // Setters.
        inline void set_clazz               (classinfo* value);
        inline void set_slot                (int32_t value);
+       inline void set_parameterTypes      (java_handle_objectarray_t* value);
+       inline void set_exceptionTypes      (java_handle_objectarray_t* value);
+       inline void set_modifiers           (int32_t value);
+       inline void set_signature           (java_handle_t* value);
        inline void set_annotations         (java_handle_bytearray_t* value);
        inline void set_parameterAnnotations(java_handle_bytearray_t* value);
-       inline void set_declaredAnnotations (java_handle_t* value);
-       inline void set_cons                (java_handle_t* value);
 
        // Convenience functions.
        inline methodinfo* get_method();
 };
 
-inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(jobject h) : java_lang_Object(h)
+
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h)
 {
-       java_lang_reflect_VMConstructor((java_handle_t*) h);
+       java_lang_reflect_Constructor((java_handle_t*) h);
 }
 
-inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(java_handle_t* h, methodinfo* m) : java_lang_Object(h)
+inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m)
 {
-       int                      slot                 = m - m->clazz->methods;
-       java_handle_bytearray_t* annotations          = method_get_annotations(m);
-       java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m);
+       _handle = builtin_new(class_java_lang_reflect_Constructor);
+
+       if (is_null())
+               return;
+
+       int                        slot                 = m - m->clazz->methods;
+       java_handle_objectarray_t* parameterTypes       = method_get_parametertypearray(m);
+       java_handle_objectarray_t* exceptionTypes       = method_get_exceptionarray(m);
+       java_handle_bytearray_t*   annotations          = method_get_annotations(m);
+       java_handle_bytearray_t*   parameterAnnotations = method_get_parameterannotations(m);
 
        set_clazz(m->clazz);
        set_slot(slot);
+       set_parameterTypes(parameterTypes);
+       set_exceptionTypes(exceptionTypes);
+       set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK);
+       set_signature(m->signature ? javastring_new(m->signature) : NULL);
        set_annotations(annotations);
        set_parameterAnnotations(parameterAnnotations);
 }
 
-inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const
+
+inline int32_t java_lang_reflect_Constructor::get_override() const
+{
+       return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Constructor::get_clazz() const
 {
        return get<classinfo*>(_handle, offset_clazz);
 }
 
-inline int32_t java_lang_reflect_VMConstructor::get_slot() const
+inline int32_t java_lang_reflect_Constructor::get_slot() const
 {
        return get<int32_t>(_handle, offset_slot);
 }
 
-inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const
+inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const
 {
        return get<java_handle_bytearray_t*>(_handle, offset_annotations);
 }
 
-inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const
+
+inline void java_lang_reflect_Constructor::set_clazz(classinfo* value)
 {
-       return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+       set(_handle, offset_clazz, value);
 }
 
-inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const
+inline void java_lang_reflect_Constructor::set_slot(int32_t value)
 {
-       return get<java_handle_t*>(_handle, offset_declaredAnnotations);
+       set(_handle, offset_slot, value);
 }
 
-inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const
+inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value)
 {
-       return get<java_handle_t*>(_handle, offset_cons);
+       set(_handle, offset_parameterTypes, value);
 }
 
-inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value)
+inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value)
+{
+       set(_handle, offset_exceptionTypes, value);
+}
+
+inline void java_lang_reflect_Constructor::set_modifiers(int32_t value)
+{
+       set(_handle, offset_modifiers, value);
+}
+
+inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value)
+{
+       set(_handle, offset_signature, value);
+}
+
+inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_annotations, value);
+}
+
+inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value)
+{
+       set(_handle, offset_parameterAnnotations, value);
+}
+
+
+inline methodinfo* java_lang_reflect_Constructor::get_method()
+{
+       classinfo*  c    = get_clazz();
+       int32_t     slot = get_slot();
+       methodinfo* m    = &(c->methods[slot]);
+       return m;
+}
+
+
+/**
+ * OpenJDK java/lang/reflect/Field
+ *
+ * Object layout:
+ *
+ * 0.  object header
+ * 1.  boolean                                         override;
+ * 2.  java.lang.Class                                 clazz;
+ * 3.  int                                             slot;
+ * 4.  java.lang.String                                name;
+ * 5.  java.lang.Class                                 type;
+ * 6.  int                                             modifiers;
+ * 7.  java.lang.String                                signature;
+ * 8.  sun.reflect.generics.repository.FieldRepository genericInfo;
+ * 9.  byte[]                                          annotations;
+ * 10. sun.reflect.FieldAccessor                       fieldAccessor;
+ * 11. sun.reflect.FieldAccessor                       overrideFieldAccessor;
+ * 12. java.lang.reflect.Field                         root;
+ * 13. java.lang.Class                                 securityCheckCache;
+ * 14. java.lang.Class                                 securityCheckTargetClassCache;
+ * 15. java.util.Map                                   declaredAnnotations;
+ */
+class java_lang_reflect_Field : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_override                      = MEMORY_ALIGN(sizeof(java_object_t),                                  sizeof(int32_t));
+       static const off_t offset_clazz                         = MEMORY_ALIGN(offset_override                      + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_slot                          = MEMORY_ALIGN(offset_clazz                         + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_name                          = MEMORY_ALIGN(offset_slot                          + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_type                          = MEMORY_ALIGN(offset_name                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_modifiers                     = MEMORY_ALIGN(offset_type                          + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_signature                     = MEMORY_ALIGN(offset_modifiers                     + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_genericInfo                   = MEMORY_ALIGN(offset_signature                     + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotations                   = MEMORY_ALIGN(offset_genericInfo                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_fieldAccessor                 = MEMORY_ALIGN(offset_annotations                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_overrideFieldAccessor         = MEMORY_ALIGN(offset_fieldAccessor                 + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_root                          = MEMORY_ALIGN(offset_overrideFieldAccessor         + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckCache            = MEMORY_ALIGN(offset_root                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations           = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Field(jobject h);
+       java_lang_reflect_Field(fieldinfo* f);
+
+       // Getters.
+       inline int32_t                  get_override   () const;
+       inline classinfo*               get_clazz      () const;
+       inline int32_t                  get_slot       () const;
+       inline java_handle_bytearray_t* get_annotations() const;
+
+       // Setters.
+       inline void set_clazz      (classinfo* value);
+       inline void set_slot       (int32_t value);
+       inline void set_name       (java_handle_t* value);
+       inline void set_type       (classinfo* value);
+       inline void set_modifiers  (int32_t value);
+       inline void set_signature  (java_handle_t* value);
+       inline void set_annotations(java_handle_bytearray_t* value);
+
+       // Convenience functions.
+       inline fieldinfo* get_field() const;
+};
+
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h)
+{
+       java_lang_reflect_Field((java_handle_t*) h);
+}
+
+inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f)
+{
+       _handle = builtin_new(class_java_lang_reflect_Field);
+
+       // OOME.
+       if (is_null())
+               return;
+
+       set_clazz(f->clazz);
+       set_slot(f - f->clazz->fields);
+       set_name(javastring_intern(javastring_new(f->name)));
+       set_type(field_get_type(f));
+       set_modifiers(f->flags);
+       set_signature(f->signature ? javastring_new(f->signature) : NULL);
+       set_annotations(field_get_annotations(f));
+}
+
+
+inline int32_t java_lang_reflect_Field::get_override() const
+{
+       return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Field::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Field::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+
+inline void java_lang_reflect_Field::set_clazz(classinfo* value)
 {
        set(_handle, offset_clazz, value);
 }
 
-inline void java_lang_reflect_VMConstructor::set_slot(int32_t value)
+inline void java_lang_reflect_Field::set_slot(int32_t value)
 {
        set(_handle, offset_slot, value);
 }
 
-inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value)
+inline void java_lang_reflect_Field::set_name(java_handle_t* value)
+{
+       set(_handle, offset_name, value);
+}
+
+inline void java_lang_reflect_Field::set_type(classinfo* value)
+{
+       set(_handle, offset_type, value);
+}
+
+inline void java_lang_reflect_Field::set_modifiers(int32_t value)
+{
+       set(_handle, offset_modifiers, value);
+}
+
+inline void java_lang_reflect_Field::set_signature(java_handle_t* value)
+{
+       set(_handle, offset_signature, value);
+}
+
+inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value)
 {
        set(_handle, offset_annotations, value);
 }
 
-inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value)
+
+inline fieldinfo* java_lang_reflect_Field::get_field() const
 {
-       set(_handle, offset_parameterAnnotations, value);
+       classinfo* c    = get_clazz();
+       int32_t    slot = get_slot();
+       fieldinfo* f    = &(c->fields[slot]);
+       return f;
 }
 
-inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value)
+
+/**
+ * OpenJDK java/lang/reflect/Method
+ *
+ * Object layout:
+ *
+ * 0.  object header
+ * 1.  boolean                                               override;
+ * 2.  java.lang.Class                                       clazz;
+ * 3.  int                                                   slot;
+ * 4.  java.lang.String                                      name;
+ * 5.  java.lang.Class                                       returnType;
+ * 6.  java.lang.Class[]                                     parameterTypes;
+ * 7.  java.lang.Class[]                                     exceptionTypes;
+ * 8.  int                                                   modifiers;
+ * 9.  java.lang.String                                      signature;
+ * 10  sun.reflect.generics.repository.ConstructorRepository genericInfo;
+ * 11. byte[]                                                annotations;
+ * 12. byte[]                                                parameterAnnotations;
+ * 13. byte[]                                                annotationDefault;
+ * 14. sun.reflect.MethodAccessor                            methodAccessor;
+ * 15. java.lang.reflect.Method                              root;
+ * 16. java.lang.Class                                       securityCheckCache;
+ * 17. java.lang.Class                                       securityCheckTargetClassCache;
+ * 18. java.util.Map                                         declaredAnnotations;
+ */
+class java_lang_reflect_Method : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_override                      = MEMORY_ALIGN(sizeof(java_object_t),                                  sizeof(int32_t));
+       static const off_t offset_clazz                         = MEMORY_ALIGN(offset_override                      + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_slot                          = MEMORY_ALIGN(offset_clazz                         + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_name                          = MEMORY_ALIGN(offset_slot                          + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_returnType                    = MEMORY_ALIGN(offset_name                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_parameterTypes                = MEMORY_ALIGN(offset_returnType                    + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_exceptionTypes                = MEMORY_ALIGN(offset_parameterTypes                + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_modifiers                     = MEMORY_ALIGN(offset_exceptionTypes                + SIZEOF_VOID_P,   sizeof(int32_t));
+       static const off_t offset_signature                     = MEMORY_ALIGN(offset_modifiers                     + sizeof(int32_t), SIZEOF_VOID_P);
+       static const off_t offset_genericInfo                   = MEMORY_ALIGN(offset_signature                     + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotations                   = MEMORY_ALIGN(offset_genericInfo                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_parameterAnnotations          = MEMORY_ALIGN(offset_annotations                   + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_annotationDefault             = MEMORY_ALIGN(offset_parameterAnnotations          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_methodAccessor                = MEMORY_ALIGN(offset_annotationDefault             + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_root                          = MEMORY_ALIGN(offset_methodAccessor                + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckCache            = MEMORY_ALIGN(offset_root                          + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache            + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+       static const off_t offset_declaredAnnotations           = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P,   SIZEOF_VOID_P);
+
+public:
+       java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {}
+       java_lang_reflect_Method(jobject h);
+       java_lang_reflect_Method(methodinfo* m);
+
+       java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args);
+
+       // Getters.
+       inline int32_t                  get_override            () const;
+       inline classinfo*               get_clazz               () const;
+       inline int32_t                  get_slot                () const;
+       inline java_handle_bytearray_t* get_annotations         () const;
+       inline java_handle_bytearray_t* get_parameterAnnotations() const;
+       inline java_handle_bytearray_t* get_annotationDefault   () const;
+
+       // Setters.
+
+       // Convenience functions.
+       inline methodinfo* get_method() const;
+};
+
+
+inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h)
 {
-       set(_handle, offset_declaredAnnotations, value);
+       java_lang_reflect_Method((java_handle_t*) h);
 }
 
-inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value)
+inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m)
 {
-       set(_handle, offset_cons, value);
+       _handle = builtin_new(class_java_lang_reflect_Method);
+
+       if (is_null())
+               return;
+
+       set(_handle, offset_clazz, m->clazz);
+       set(_handle, offset_slot,  m - m->clazz->methods);
+       set(_handle, offset_name,  javastring_intern(javastring_new(m->name)));
+       set(_handle, offset_returnType,           method_returntype_get(m));
+       set(_handle, offset_parameterTypes,       method_get_parametertypearray(m));
+       set(_handle, offset_exceptionTypes,       method_get_exceptionarray(m));
+       set(_handle, offset_modifiers,            m->flags & ACC_CLASS_REFLECT_MASK);
+       set(_handle, offset_signature,            m->signature ? javastring_new(m->signature) : NULL);
+       set(_handle, offset_annotations,          method_get_annotations(m));
+       set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m));
+       set(_handle, offset_annotationDefault,    method_get_annotationdefault(m));
 }
 
-inline methodinfo* java_lang_reflect_VMConstructor::get_method()
+
+inline int32_t java_lang_reflect_Method::get_override() const
+{
+       return get<int32_t>(_handle, offset_override);
+}
+
+inline classinfo* java_lang_reflect_Method::get_clazz() const
+{
+       return get<classinfo*>(_handle, offset_clazz);
+}
+
+inline int32_t java_lang_reflect_Method::get_slot() const
+{
+       return get<int32_t>(_handle, offset_slot);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_parameterAnnotations);
+}
+
+inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const
+{
+       return get<java_handle_bytearray_t*>(_handle, offset_annotationDefault);
+}
+
+
+inline methodinfo* java_lang_reflect_Method::get_method() const
 {
        classinfo*  c    = get_clazz();
        int32_t     slot = get_slot();
@@ -1900,8 +2555,46 @@ inline methodinfo* java_lang_reflect_VMConstructor::get_method()
        return m;
 }
 
+
+/**
+ * OpenJDK java/nio/Buffer
+ *
+ * Object layout:
+ *
+ * 0. object header
+ * 1. int  mark;
+ * 2. int  position;
+ * 3. int  limit;
+ * 4. int  capacity;
+ * 5. long address;
+ */
+class java_nio_Buffer : public java_lang_Object, private FieldAccess {
+private:
+       // Static offsets of the object's instance fields.
+       // TODO These offsets need to be checked on VM startup.
+       static const off_t offset_mark     = MEMORY_ALIGN(sizeof(java_object_t),          sizeof(int32_t));
+       static const off_t offset_position = MEMORY_ALIGN(offset_mark     + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_limit    = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_capacity = MEMORY_ALIGN(offset_limit    + sizeof(int32_t), sizeof(int32_t));
+       static const off_t offset_address  = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t));
+
+public:
+       java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {}
+       java_nio_Buffer(jobject h) : java_lang_Object(h) {}
+
+       // Getters.
+       inline void* get_address() const;
+};
+
+
+inline void* java_nio_Buffer::get_address() const
+{
+       return get<void*>(_handle, offset_address);
+}
+
 #endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK
 
+
 #if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1)
 
 /**