Merged revisions 8321-8342 via svnmerge from
authormichi <none@none>
Fri, 17 Aug 2007 21:39:32 +0000 (21:39 +0000)
committermichi <none@none>
Fri, 17 Aug 2007 21:39:32 +0000 (21:39 +0000)
svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk

........
  r8322 | twisti | 2007-08-16 17:54:38 +0200 (Thu, 16 Aug 2007) | 16 lines

  * src/vmcore/method.c (method_get_annotations): Always enable the
  method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code
  calling this function simpler.
  (method_get_parameterannotations): Likewise.
  (method_get_annotationdefault): Likewise.

  * src/vmcore/method.h (method_get_annotations): Removed
  ENABLE_ANNOTATIONS.
  (method_get_parameterannotations): Likewise.
  (method_get_annotationdefault): Likewise.

  * src/native/vm/reflect.c (reflect_constructor_new): Always call
  method-annotations functions.
  (reflect_field_new): Likewise.
  (reflect_method_new): Likewise.
........
  r8323 | twisti | 2007-08-16 18:01:05 +0200 (Thu, 16 Aug 2007) | 3 lines

  * src/native/vm/sun/jvm.c (JVM_FindPrimitiveClass): Use TRACEJVMCALLS
  and a better implementation.
........
  r8325 | twisti | 2007-08-16 19:25:47 +0200 (Thu, 16 Aug 2007) | 7 lines

  * src/vmcore/field.c (field_get_annotations): Always enable the
  method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code
  calling this function simpler.

  * src/vmcore/field.h (field_get_annotations): Removed
  ENABLE_ANNOTATIONS.
........
  r8326 | twisti | 2007-08-16 19:45:49 +0200 (Thu, 16 Aug 2007) | 12 lines

  * src/native/vm/gnu/java_lang_reflect_Constructor.c
  (declaredAnnotations): Use byte-array handle. Don't check for this ==
  NULL , this cannot happen.
  (getParameterAnnotations): Likewise.

  * src/native/vm/gnu/java_lang_reflect_Field.c (declaredAnnotations):
  Likewise.

  * src/native/vm/gnu/java_lang_reflect_Method.c (declaredAnnotations):
  Likewise.
  (getParameterAnnotations): Likewise.
........
  r8327 | twisti | 2007-08-16 19:52:48 +0200 (Thu, 16 Aug 2007) | 8 lines

  * src/vm/primitive.c (primitive_type_get_by_wrapperclass): New
  function.
  (primitive_unbox): Changed signature.
  * src/vm/primitive.h: Likewise.

  * src/vm/vm.c (vm_array_from_objectarray): Rewritten to use
  primitive-unbox function.
........
  r8328 | twisti | 2007-08-16 19:56:19 +0200 (Thu, 16 Aug 2007) | 3 lines

  * src/vm/vm.c (vm_array_from_objectarray): Use
  primitive_type_get_by_wrapperclass (typo). Removed debug output.
........
  r8329 | twisti | 2007-08-16 19:57:27 +0200 (Thu, 16 Aug 2007) | 3 lines

  * src/vm/vm.c (XXusage): Commented.  We don't use it anymore but we
  keep it to know which switches still need to be converted.
........
  r8330 | twisti | 2007-08-16 20:15:51 +0200 (Thu, 16 Aug 2007) | 25 lines

  * src/vm/array.c: New file.
  * src/vm/array.h: Likewise.

  * src/vm/Makefile.am (libvm_la_SOURCES): Added array.[ch].

  * src/vm/builtin.c,
  src/vm/string.c,
  src/vm/jit/verify/typecheck-typeinferer.c,
  src/vm/jit/verify/typecheck.c,
  src/vm/jit/verify/typecheck-stackbased.c,
  src/vm/jit/verify/typeinfo.c,
  src/vmcore/linker.c (vm/array.h): Added.

  * src/vm/primitive.h (ARRAYTYPE_*): Moved to vm/array.h

  * src/vmcore/class.c (class_get_componenttype): New function.
  * src/vmcore/class.h: Likewise.

  * src/native/vm/java_lang_Class.c (getComponentType): Removed.
  * src/native/vm/java_lang_Class.h: Likewise.

  * src/native/vm/gnu/java_lang_VMClass.c (getComponentType): Call
  class_get_componenttype.
  * src/native/vm/sun/jvm.c (JVM_GetComponentType): Likewise.
........
  r8331 | panzi | 2007-08-16 21:21:39 +0200 (Thu, 16 Aug 2007) | 16 lines

  * src/native/vm/sun/jvm.c
  (vm/array.h): Added include.
  (vm/global.h): Added include.
  (JVM_FindPrimitiveClass): Parameter name shadowed type utf.
  (JVM_GetComponentType): Missing variable classinfo* c.
  (JVM_GetClassAnnotations): java_bytearray -> java_handle_bytearray_t.
  (JVM_GetFieldAnnotations): java_bytearray -> java_handle_bytearray_t.
  (JVM_GetMethodAnnotations): java_bytearray -> java_handle_bytearray_t.
  (JVM_GetMethodDefaultAnnotationValue): java_bytearray -> java_handle_bytearray_t.
  (JVM_GetMethodParameterAnnotations): java_bytearray -> java_handle_bytearray_t.
  (JVM_GetArrayLength): java_arrayheader -> java_array_t.
  (JVM_GetArrayElement): Updated types, renamed wrong named variable.

  * src/vmcore/linker.h:
  (_vftbl): Fixed formatting of comment.
........
  r8332 | panzi | 2007-08-16 21:29:42 +0200 (Thu, 16 Aug 2007) | 5 lines

  * src/native/vm/sun/jvm.c
  (JVM_GetArrayElement): Used exceptions_new_arrayindexoutofboundsexception
  where exceptions_throw_arrayindexoutofboundsexception should have been used.
........
  r8333 | pm | 2007-08-16 23:46:32 +0200 (Thu, 16 Aug 2007) | 2 lines

  * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Return NULL as default.
........
  r8334 | ajordan | 2007-08-17 00:10:43 +0200 (Fri, 17 Aug 2007) | 5 lines

  * src/vm/jit/sparc64/codegen.h: Improved overflow checking.

  * src/vm/jit/sparc64/codegen.c (check_13bit_imm): Likewise.
  (codegen_emit): Fixed ICDM_TABLESWITCH for large negative values.
........
  r8338 | panzi | 2007-08-17 22:03:06 +0200 (Fri, 17 Aug 2007) | 10 lines

  * tests/regression/MinimalClassReflection.output: New file.
  * tests/regression/MinimalClassReflection.java: New file.
  This adds tests for some reflection methods like
  java.lang.Class.isLocal/.isMember/.isAnonymous/.getDeclaringClass etc.

  * tests/regression/Makefile.am
  (SOURCE_FILES): Added MinimalClassReflection.java.
  (EXTRA_DIST): Added MinimalClassReflection.output.
  (OUTPUT_JAVA_TESTS): Added MinimalClassReflection.
........
  r8339 | twisti | 2007-08-17 23:21:51 +0200 (Fri, 17 Aug 2007) | 37 lines

  * src/vm/global.h (ACC_CLASS_MEMBER): New define.
  (ACC_CLASS_ANONYMOUS): Likewise.

  * src/native/vm/java_lang_Class.c
  (_Jv_java_lang_Class_getEnclosingClass): Removed.
  (_Jv_java_lang_Class_getEnclosingMethod_intern): Use
  class_get_enclosingclass.

  * src/native/vm/java_lang_Class.h
  (_Jv_java_lang_Class_getEnclosingClass): Removed.

  * src/native/vm/gnu/java_lang_VMClass.c (stdint.h): Added.
  (vmcore/class.h): Likewise.
  (methods): Enabled isAnonymousClass, isLocalClass and isMemberClass.
  (Java_java_lang_VMClass_getEnclosingClass): Use
  class_get_enclosingclass.
  (isAnonymousClass): Implemented.
  (isLocalClass): Likewise.
  (isMemberClass): Likewise.

  * src/vmcore/class.c (class_load_attributes): Set ACC_CLASS_MEMBER and
  ACC_CLASS_ANONYMOUS flags.
  (class_is_anonymousclass): New function.
  (class_is_localclass): Likewise.
  (class_is_memberclass): Likewise.
  (class_get_declaredclasses): Check if outer is NULL.
  (class_get_declaringclass): Rewritten to use c->declaringclass.
  (class_get_enclosingclass): New function.

  * src/vmcore/class.h (classinfo): Added declaringclass.(
  (class_is_anonymousclass): New function.
  (class_is_localclass): Likewise.
  (class_is_memberclass): Likewise.
  (class_get_enclosingclass): Likewise.

  * NEWS: Added news.
........
  r8340 | twisti | 2007-08-17 23:28:29 +0200 (Fri, 17 Aug 2007) | 2 lines

  * src/native/vm/gnu/java_lang_VMClass.c (getEnclosingClass): Typo.
........
  r8341 | michi | 2007-08-17 23:32:01 +0200 (Fri, 17 Aug 2007) | 21 lines

  * src/native/llni.h (LLNI_classinfo_wrap, LLNI_classinfo_unwrap): Added new
  macros.

  Used above two LLNI macros throughout the codebase:
  * src/native/jni.c
  * src/native/vm/java_lang_ClassLoader.c
  * src/native/vm/cldc1.1/java_lang_Class.c
  * src/native/vm/cldc1.1/java_lang_Object.c
  * src/native/vm/java_lang_Class.c
  * src/native/vm/java_lang_Object.c
  * src/native/vm/gnu/java_lang_VMClassLoader.c
  * src/native/vm/gnu/java_lang_VMClass.c
  * src/native/vm/gnu/sun_reflect_ConstantPool.c
  * src/native/vm/gnu/java_lang_reflect_Method.c
  * src/native/vm/gnu/java_lang_reflect_Field.c
  * src/native/vm/gnu/java_lang_VMThrowable.c
  * src/native/vm/sun_misc_Unsafe.c
  * src/native/vm/sun/jvm.c
  * src/native/vm/reflect.c
  * src/vmcore/loader.c
........

--HG--
branch : exact-gc

46 files changed:
NEWS
src/native/jni.c
src/native/llni.h
src/native/vm/cldc1.1/java_lang_Class.c
src/native/vm/cldc1.1/java_lang_Object.c
src/native/vm/gnu/java_lang_VMClass.c
src/native/vm/gnu/java_lang_VMClassLoader.c
src/native/vm/gnu/java_lang_VMThrowable.c
src/native/vm/gnu/java_lang_reflect_Constructor.c
src/native/vm/gnu/java_lang_reflect_Field.c
src/native/vm/gnu/java_lang_reflect_Method.c
src/native/vm/gnu/sun_reflect_ConstantPool.c
src/native/vm/java_lang_Class.c
src/native/vm/java_lang_Class.h
src/native/vm/java_lang_ClassLoader.c
src/native/vm/java_lang_Object.c
src/native/vm/reflect.c
src/native/vm/sun/jvm.c
src/native/vm/sun_misc_Unsafe.c
src/vm/Makefile.am
src/vm/array.c [new file with mode: 0644]
src/vm/array.h [new file with mode: 0644]
src/vm/builtin.c
src/vm/global.h
src/vm/jit/sparc64/codegen.c
src/vm/jit/sparc64/codegen.h
src/vm/jit/verify/typecheck-stackbased.c
src/vm/jit/verify/typecheck-typeinferer.c
src/vm/jit/verify/typecheck.c
src/vm/jit/verify/typeinfo.c
src/vm/primitive.c
src/vm/primitive.h
src/vm/string.c
src/vm/vm.c
src/vmcore/class.c
src/vmcore/class.h
src/vmcore/field.c
src/vmcore/field.h
src/vmcore/linker.c
src/vmcore/linker.h
src/vmcore/loader.c
src/vmcore/method.c
src/vmcore/method.h
tests/regression/Makefile.am
tests/regression/MinimalClassReflection.java [new file with mode: 0644]
tests/regression/MinimalClassReflection.output [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 737fbc2ea1fa24c00d7bbee7e5a137ce3885a744..137b44178a7537a14368a3e9d0991abf6705d597 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ New in release 0.99 (August x, 2007)
   * Use 8-byte stack-slots on all architectures.
   * Faster C-to-Java calls.
   * Removed genoffsets, cross-compilation is now much easier.
+  * Implemented Class.isAnonymousClass(), isLocalClass() and
+    isMemberClass() for GNU Classpath.
 
 
 New in release 0.98 (June 6, 2007)
index d7dac000d7489f84db550cf10c29e72ffe3b5c39..294fee1ee4052e40e21a75cb83758c9f6ddce746 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jni.c 8335 2007-08-17 11:04:35Z michi $
+   $Id: jni.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -1053,7 +1053,7 @@ jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub)
 
        TRACEJNICALLS("_Jv_JNI_GetSuperclass(env=%p, sub=%p)", env, sub);
 
-       c = (classinfo *) sub;
+       c = LLNI_classinfo_unwrap(sub);
 
        if (c == NULL)
                return NULL;
@@ -1120,7 +1120,7 @@ jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg)
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        if (msg == NULL)
                msg = "";
        s = javastring_new_from_utf_string(msg);
@@ -1431,7 +1431,7 @@ jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz)
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
 
        if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) {
                exceptions_throw_instantiationexception(c);
@@ -1462,7 +1462,7 @@ jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        /* create object */
@@ -1501,7 +1501,7 @@ jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        /* create object */
@@ -1538,7 +1538,7 @@ jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        /* create object */
@@ -1775,7 +1775,7 @@ jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
 
        if (c == NULL)
                return NULL;
@@ -1991,7 +1991,7 @@ type _Jv_JNI_CallNonvirtual##name##Method(JNIEnv *env, jobject obj,         \
        type           ret;                                                     \
                                                                             \
        o = (java_handle_t *) obj;                                              \
-       c = (classinfo *) clazz;                                                \
+       c = LLNI_classinfo_unwrap(clazz);                                       \
        m = (methodinfo *) methodID;                                            \
                                                                             \
        va_start(ap, methodID);                                                 \
@@ -2022,7 +2022,7 @@ type _Jv_JNI_CallNonvirtual##name##MethodV(JNIEnv *env, jobject obj,         \
        type           ret;                                                      \
                                                                              \
        o = (java_handle_t *) obj;                                               \
-       c = (classinfo *) clazz;                                                 \
+       c = LLNI_classinfo_unwrap(clazz);                                        \
        m = (methodinfo *) methodID;                                             \
                                                                              \
        ret = _Jv_jni_CallIntMethod(o, c->vftbl, m, args);                       \
@@ -2070,7 +2070,7 @@ jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj,
        va_list        ap;
 
        o = (java_handle_t *) obj;
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        va_start(ap, methodID);
@@ -2091,7 +2091,7 @@ jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj,
        java_handle_t *r;
 
        o = (java_handle_t *) obj;
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args);
@@ -2119,7 +2119,7 @@ void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz,
        va_list        ap;
 
        o = (java_handle_t *) obj;
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        va_start(ap, methodID);
@@ -2136,7 +2136,7 @@ void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz,
        methodinfo    *m;
 
        o = (java_handle_t *) obj;
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        _Jv_jni_CallVoidMethod(o, c->vftbl, m, args);
@@ -2151,7 +2151,7 @@ void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz,
        methodinfo    *m;
 
        o = (java_handle_t *) obj;
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        m = (methodinfo *) methodID;
 
        _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args);
@@ -2179,7 +2179,7 @@ jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
 
        /* XXX NPE check? */
 
@@ -2297,7 +2297,7 @@ jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
 
        if (!c)
                return NULL;
@@ -2500,7 +2500,7 @@ jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
 
        uname = utf_new_char((char *) name);
        usig  = utf_new_char((char *) sig);
@@ -2530,7 +2530,7 @@ type _Jv_JNI_GetStatic##name##Field(JNIEnv *env, jclass clazz, \
                                                                \
        STATISTICS(jniinvokation());                               \
                                                                \
-       c = (classinfo *) clazz;                                   \
+       c = LLNI_classinfo_unwrap(clazz);                          \
        f = (fieldinfo *) fieldID;                                 \
                                                                \
        if (!(c->state & CLASS_INITIALIZED))                       \
@@ -2558,7 +2558,7 @@ jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        f = (fieldinfo *) fieldID;
 
        if (!(c->state & CLASS_INITIALIZED))
@@ -2586,7 +2586,7 @@ void _Jv_JNI_SetStatic##name##Field(JNIEnv *env, jclass clazz, \
                                                                \
        STATISTICS(jniinvokation());                               \
                                                                \
-       c = (classinfo *) clazz;                                   \
+       c = LLNI_classinfo_unwrap(clazz);                          \
        f = (fieldinfo *) fieldID;                                 \
                                                                \
        if (!(c->state & CLASS_INITIALIZED))                       \
@@ -2614,7 +2614,7 @@ void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
        f = (fieldinfo *) fieldID;
 
        if (!(c->state & CLASS_INITIALIZED))
@@ -2904,7 +2904,7 @@ jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) elementClass;
+       c = LLNI_classinfo_unwrap(elementClass);
        o = (java_handle_t *) initialElement;
 
        if (length < 0) {
@@ -3164,7 +3164,7 @@ jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz,
 
        STATISTICS(jniinvokation());
 
-       c = (classinfo *) clazz;
+       c = LLNI_classinfo_unwrap(clazz);
 
        /* XXX: if implemented this needs a call to jvmti_NativeMethodBind
        if (jvmti) jvmti_NativeMethodBind(method, address,  new_address_ptr);
index bde322aeb6a3ffa5903d1e3cbffd1a550f365b82..9795bd194d4db27ef35825b3f056c4127cf21e24 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: llni.h 8321 2007-08-16 11:37:25Z michi $
+   $Id: llni.h 8343 2007-08-17 21:39:32Z michi $
 
 */
 
 #define LLNI_class_get(obj, variable) \
        (variable) = LLNI_field_direct(obj, header.vftbl->class)
 
+
+/* LLNI classinfo wrapping / unwrapping macros *********************************
+
+   The following macros are used to wrap or unwrap a classinfo from
+   or into a handle (typically java_lang_Class).
+
+*******************************************************************************/
+
+#define LLNI_classinfo_wrap(classinfo) \
+       ((java_lang_Class *) (classinfo))
+
+#define LLNI_classinfo_unwrap(clazz) \
+       ((classinfo *) (clazz))
+
+
 /* XXX the direct macros have to be used inside a critical section!!! */
 
 #define LLNI_field_direct(obj, field) ((obj)->field) 
index 1a6a39af2679e759142579819fa103309655e444..84aa99b4b96c4e53999cba3f8771b81247e0c42a 100644 (file)
@@ -90,7 +90,7 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_Class_newInstance(JNIEnv *env
        classinfo     *c;
        java_handle_t *o;
 
-       c = (classinfo *) this;
+       c = LLNI_classinfo_unwrap(this);
 
        o = native_new_and_init(c);
 
index dc0c6c553402b5790338ce41fa0d43a5fa10e4bc..e6d7847d2545756799475446239743267463f369 100644 (file)
@@ -88,7 +88,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, j
 
        c = o->vftbl->class;
 
-       return (java_lang_Class *) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
index 4d8e4163447eebc8493c456b6d18d255156dd062..e1ab6e5147bf99851acccc4e0dd7e0f492ce5863 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMClass.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: java_lang_VMClass.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
 
 #include "config.h"
+
+#include <stdint.h>
+
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/llni.h"
 #include "native/native.h"
 
 #include "native/include/java_lang_Class.h"
@@ -44,6 +48,8 @@
 
 #include "native/vm/java_lang_Class.h"
 
+#include "vmcore/class.h"
+
 
 /* native methods implemented by this file ************************************/
 
@@ -73,11 +79,9 @@ static JNINativeMethod methods[] = {
        { "getEnclosingConstructor", "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;",            (void *) (ptrint) &Java_java_lang_VMClass_getEnclosingConstructor },
        { "getEnclosingMethod",      "(Ljava/lang/Class;)Ljava/lang/reflect/Method;",                 (void *) (ptrint) &Java_java_lang_VMClass_getEnclosingMethod      },
        { "getClassSignature",       "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (ptrint) &Java_java_lang_VMClass_getClassSignature       },
-#if 0
        { "isAnonymousClass",        "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isAnonymousClass        },
        { "isLocalClass",            "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isLocalClass            },
        { "isMemberClass",           "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isMemberClass           },
-#endif
 };
 
 
@@ -181,7 +185,14 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getInterface
  */
 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass)
 {
-       return _Jv_java_lang_Class_getComponentType(klass);
+       classinfo *c;
+       classinfo *component;
+       
+       c = LLNI_classinfo_unwrap(klass);
+       
+       component = class_get_componenttype(c);
+
+       return LLNI_classinfo_wrap(component);
 }
 
 
@@ -315,7 +326,14 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredA
  */
 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
 {
-       return _Jv_java_lang_Class_getEnclosingClass(klass);
+       classinfo *c;
+       classinfo *result;
+
+       c = LLNI_classinfo_unwrap(klass);
+
+       result = class_get_enclosingclass(c);
+
+       return LLNI_classinfo_wrap(result);
 }
 
 
@@ -352,13 +370,15 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getClassSignature(JNI
 }
 
 
-#if 0
 /*
  * Class:     java/lang/VMClass
  * Method:    isAnonymousClass
  * Signature: (Ljava/lang/Class;)Z
  */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return class_is_anonymousclass(LLNI_classinfo_unwrap(klass));
+}
 
 
 /*
@@ -366,7 +386,10 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass
  * Method:    isLocalClass
  * Signature: (Ljava/lang/Class;)Z
  */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return class_is_localclass(LLNI_classinfo_unwrap(klass));
+}
 
 
 /*
@@ -374,8 +397,10 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass cla
  * Method:    isMemberClass
  * Signature: (Ljava/lang/Class;)Z
  */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-#endif
+JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, java_lang_Class *klass)
+{
+       return class_is_memberclass(LLNI_classinfo_unwrap(klass));
+}
 
 
 /*
index 6f4c6a217557cb48357d5040da70eb822de33ea1..3c9b5ac16e978694869349cd35fb88d0aa600546 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMClassLoader.c 8335 2007-08-17 11:04:35Z michi $
+   $Id: java_lang_VMClassLoader.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -37,6 +37,7 @@
 #include "mm/memory.h"
 
 #include "native/jni.h"
+#include "native/llni.h"
 #include "native/native.h"
 #include "native/include/java_lang_Class.h"
 #include "native/include/java_lang_String.h"
@@ -129,7 +130,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_getPrimitiveClas
                return NULL;
        }
 
-       return (java_lang_Class *) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -142,7 +143,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jc
 {
        classinfo *ci;
 
-       ci = (classinfo *) c;
+       ci = LLNI_classinfo_unwrap(c);
 
        if (!ci) {
                exceptions_throw_nullpointerexception();
@@ -190,7 +191,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv
                if (!link_class(c))
                        return NULL;
 
-       return (java_lang_Class *) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -378,7 +379,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_findLoadedClass(
        if (c == NULL)
                c = classcache_lookup(cl, u);
 
-       return (java_lang_Class *) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
index 9da9db6c16ef6cdb812aadc6f1de25dd154a9f8a..bba9eab4d5250a96a89aeca75634343a10510de3 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMThrowable.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: java_lang_VMThrowable.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -253,7 +253,7 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMThrowable_getStack
                /* get declaring class name */
 
                declaringclass =
-                       _Jv_java_lang_Class_getName((java_lang_Class *) ste->method->class);
+                       _Jv_java_lang_Class_getName(LLNI_classinfo_wrap(ste->method->class));
 
                /* fill the java.lang.StackTraceElement element */
 
index f62cdbd2c897c2ffaaf343617083d655cb7d27e6..b7a2400c903e6b7c6c2665070ff0f333e1a58f53 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Constructor.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: java_lang_reflect_Constructor.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -49,8 +49,9 @@
 #include "native/include/java_lang_reflect_Constructor.h"
 
 #if defined(ENABLE_ANNOTATIONS)
-#include "native/include/sun_reflect_ConstantPool.h"
-#include "native/vm/reflect.h"
+# include "native/include/sun_reflect_ConstantPool.h"
+
+# include "native/vm/reflect.h"
 #endif
 
 #include "native/vm/java_lang_reflect_Constructor.h"
@@ -111,18 +112,13 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_construct
  * Method:    declaredAnnotations
  * Signature: ()Ljava/util/Map;
  */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this)
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this)
 {
-       java_handle_t        *o                   = (java_handle_t*)this;
-       struct java_util_Map *declaredAnnotations = NULL;
-       java_bytearray       *annotations         = NULL;
-       java_lang_Class      *declaringClass      = NULL;
-
-       if (this == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-       
+       java_handle_t           *o                   = (java_handle_t*)this;
+       struct java_util_Map    *declaredAnnotations = NULL;
+       java_handle_bytearray_t *annotations         = NULL;
+       java_lang_Class         *declaringClass      = NULL;
+
        LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
 
        if (declaredAnnotations == NULL) {
@@ -143,17 +139,12 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Constructor_decla
  * Method:    getParameterAnnotations
  * Signature: ()[[Ljava/lang/annotation/Annotation;
  */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, struct java_lang_reflect_Constructor* this)
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Constructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_Constructor *this)
 {
-       java_handle_t   *o                    = (java_handle_t*)this;
-       java_bytearray  *parameterAnnotations = NULL;
-       int32_t          slot                 = -1;
-       java_lang_Class *declaringClass       = NULL;
-
-       if (this == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
+       java_handle_t           *o                    = (java_handle_t*)this;
+       java_handle_bytearray_t *parameterAnnotations = NULL;
+       int32_t                  slot                 = -1;
+       java_lang_Class         *declaringClass       = NULL;
 
        LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
        LLNI_field_get_val(this, slot, slot);
index ed23f2eff4cb1734cf55c046ef777f2e620bc341..17f78367973352e45b020f0e7176be2e0ee2dfe0 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Field.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: java_lang_reflect_Field.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -230,7 +230,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Field_getType(JNIEnv *
        if (!resolve_class_from_typedesc(desc, true, false, &ret))
                return NULL;
        
-       return (java_lang_Class *) ret;
+       return LLNI_classinfo_wrap(ret);
 }
 
 
@@ -1251,17 +1251,12 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_Field_getSignature(JN
  * Method:    declaredAnnotations
  * Signature: ()Ljava/util/Map;
  */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Field_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Field* this)
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Field_declaredAnnotations(JNIEnv *env, java_lang_reflect_Field *this)
 {
-       java_handle_t        *o                   = (java_handle_t*)this;
-       struct java_util_Map *declaredAnnotations = NULL;
-       java_bytearray       *annotations         = NULL;
-       java_lang_Class      *declaringClass      = NULL;
-
-       if (this == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
+       java_handle_t           *o                   = (java_handle_t*)this;
+       struct java_util_Map    *declaredAnnotations = NULL;
+       java_handle_bytearray_t *annotations         = NULL;
+       java_lang_Class         *declaringClass      = NULL;
 
        LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
 
index 3882c4f29a2160f464c4e4ce5bafa3a3b992f20c..e8849592467bbee1101da8c5c91ae7806f72eda9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Method.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: java_lang_reflect_Method.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -135,7 +135,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_Method_getReturnType(J
 
        result = method_returntype_get(m);
 
-       return (java_lang_Class *) result;
+       return LLNI_classinfo_wrap(result);
 }
 
 
@@ -288,17 +288,12 @@ JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_Method_getDefa
  * Method:    declaredAnnotations
  * Signature: ()Ljava/util/Map;
  */
-JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAnnotations(JNIEnv *env, struct java_lang_reflect_Method* this)
+JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAnnotations(JNIEnv *env, java_lang_reflect_Method *this)
 {
-       java_handle_t        *o                   = (java_handle_t*)this;
-       struct java_util_Map *declaredAnnotations = NULL;
-       java_bytearray       *annotations         = NULL;
-       java_lang_Class      *declaringClass      = NULL;
-
-       if (this == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
+       java_handle_t           *o                   = (java_handle_t*)this;
+       struct java_util_Map    *declaredAnnotations = NULL;
+       java_handle_bytearray_t *annotations         = NULL;
+       java_lang_Class         *declaringClass      = NULL;
 
        LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations);
 
@@ -320,17 +315,12 @@ JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_Method_declaredAn
  * Method:    getParameterAnnotations
  * Signature: ()[[Ljava/lang/annotation/Annotation;
  */
-JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Method_getParameterAnnotations(JNIEnv *env, struct java_lang_reflect_Method* this)
+JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_Method_getParameterAnnotations(JNIEnv *env, java_lang_reflect_Method *this)
 {
-       java_handle_t   *o                    = (java_handle_t*)this;
-       java_bytearray  *parameterAnnotations = NULL;
-       int32_t          slot                 = -1;
-       java_lang_Class *declaringClass       = NULL;
-
-       if (this == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
+       java_handle_t           *o                    = (java_handle_t*)this;
+       java_handle_bytearray_t *parameterAnnotations = NULL;
+       int32_t                  slot                 = -1;
+       java_lang_Class         *declaringClass       = NULL;
 
        LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations);
        LLNI_field_get_val(this, slot, slot);
index b607fe2e7e97c85e5c0a18b1e79a62b18a248655..77030ca4ee5238663e9dbe482a869955b4a53e2c 100644 (file)
@@ -93,7 +93,7 @@ void _Jv_sun_reflect_ConstantPool_init(void)
  */
 JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool)
 {
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
        return cls->cpcount;
 }
 
@@ -106,7 +106,7 @@ JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, st
 JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        constant_classref *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_classref*)class_getconstant(
                cls, index, CONSTANT_Class);
@@ -115,7 +115,7 @@ JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClass
                return NULL;
        }
 
-       return (jclass)resolve_classref_eager(ref);
+       return LLNI_classinfo_wrap(resolve_classref_eager(ref));
 }
 
 
@@ -128,7 +128,7 @@ JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClass
 {
        constant_classref *ref;
        classinfo *c = NULL;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_classref*)class_getconstant(
                cls, index, CONSTANT_Class);
@@ -145,7 +145,7 @@ JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClass
                return NULL;
        }
        
-       return (jclass)c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -157,7 +157,7 @@ JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClass
 JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        constant_FMIref *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
        
        ref = (constant_FMIref*)class_getconstant(
                cls, index, CONSTANT_Methodref);
@@ -180,7 +180,7 @@ JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool
 {
        constant_FMIref *ref;
        classinfo *c = NULL;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_FMIref*)class_getconstant(
                cls, index, CONSTANT_Methodref);
@@ -209,7 +209,7 @@ JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool
 JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        constant_FMIref *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_FMIref*)class_getconstant(
                cls, index, CONSTANT_Fieldref);
@@ -231,7 +231,7 @@ JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_
 {
        constant_FMIref *ref;
        classinfo *c;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_FMIref*)class_getconstant(
                cls, index, CONSTANT_Fieldref);
@@ -272,7 +272,7 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_sun_reflect_ConstantPool_getMe
 JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        constant_integer *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_integer*)class_getconstant(
                cls, index, CONSTANT_Integer);
@@ -293,7 +293,7 @@ JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, s
 JNIEXPORT int64_t JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        constant_long *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_long*)class_getconstant(
                cls, index, CONSTANT_Long);
@@ -314,7 +314,7 @@ JNIEXPORT int64_t JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env,
 JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        constant_float *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_float*)class_getconstant(
                cls, index, CONSTANT_Float);
@@ -335,7 +335,7 @@ JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, s
 JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        constant_double *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (constant_double*)class_getconstant(
                cls, index, CONSTANT_Double);
@@ -356,7 +356,7 @@ JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env,
 JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        utf *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
        
        ref = (utf*)class_getconstant(cls, index, CONSTANT_String);
 
@@ -377,7 +377,7 @@ JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getStri
 JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index)
 {
        utf *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8);
 
index c89d5f8d0d8211bca299dd8c893beb9ab6297fb9..32366f0529939e2a353ad7ca92efc32c80c12c28 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_Class.c 8335 2007-08-17 11:04:35Z michi $
+   $Id: java_lang_Class.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -99,7 +99,7 @@ java_lang_String *_Jv_java_lang_Class_getName(java_lang_Class *klass)
        java_handle_chararray_t *ca;
        u4                       i;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        /* create a java string */
 
@@ -190,7 +190,7 @@ java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name)
                if (!initialize_class(c))
                        return NULL;
 
-       return (java_lang_Class *) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -204,7 +204,7 @@ s4 _Jv_java_lang_Class_isInstance(java_lang_Class *klass, java_lang_Object *o)
        classinfo     *c;
        java_handle_t *ob;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
        ob = (java_handle_t *) o;
 
        if (!(c->state & CLASS_LINKED))
@@ -225,8 +225,8 @@ s4 _Jv_java_lang_Class_isAssignableFrom(java_lang_Class *klass, java_lang_Class
        classinfo *kc;
        classinfo *cc;
 
-       kc = (classinfo *) klass;
-       cc = (classinfo *) c;
+       kc = LLNI_classinfo_unwrap(klass);
+       cc = LLNI_classinfo_unwrap(c);
 
        if (cc == NULL) {
                exceptions_throw_nullpointerexception();
@@ -254,7 +254,7 @@ JNIEXPORT int32_t JNICALL _Jv_java_lang_Class_isInterface(JNIEnv *env, java_lang
 {
        classinfo *c;
 
-       c = (classinfo *) this;
+       c = LLNI_classinfo_unwrap(this);
 
        return class_is_interface(c);
 }
@@ -271,7 +271,7 @@ s4 _Jv_java_lang_Class_isPrimitive(java_lang_Class *klass)
 {
        classinfo *c;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        return class_is_primitive(c);
 }
@@ -287,11 +287,11 @@ java_lang_Class *_Jv_java_lang_Class_getSuperclass(java_lang_Class *klass)
        classinfo *c;
        classinfo *super;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        super = class_get_superclass(c);
 
-       return (java_lang_Class *) super;
+       return LLNI_classinfo_wrap(super);
 }
 
 
@@ -305,7 +305,7 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getInterfaces(java_lang_Class *kl
        classinfo                 *c;
        java_handle_objectarray_t *oa;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        oa = class_get_interfaces(c);
 
@@ -313,40 +313,6 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getInterfaces(java_lang_Class *kl
 }
 
 
-/*
- * Class:     java/lang/Class
- * Method:    getComponentType
- * Signature: ()Ljava/lang/Class;
- */
-java_lang_Class *_Jv_java_lang_Class_getComponentType(java_lang_Class *klass)
-{
-       classinfo       *c;
-       classinfo       *comp;
-       arraydescriptor *desc;
-       
-       c = (classinfo *) klass;
-       
-       /* XXX maybe we could find a way to do this without linking. */
-       /* This way should be safe and easy, however.                */
-
-       if (!(c->state & CLASS_LINKED))
-               if (!link_class(c))
-                       return NULL;
-
-       desc = c->vftbl->arraydesc;
-       
-       if (desc == NULL)
-               return NULL;
-       
-       if (desc->arraytype == ARRAYTYPE_OBJECT)
-               comp = desc->componentvftbl->class;
-       else
-               comp = primitive_class_get_by_type(desc->arraytype);
-               
-       return (java_lang_Class *) comp;
-}
-
-
 /*
  * Class:     java/lang/Class
  * Method:    getModifiers
@@ -360,7 +326,7 @@ s4 _Jv_java_lang_Class_getModifiers(java_lang_Class *klass, s4 ignoreInnerClasse
        utf                   *innername;
        s4                     i;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        if (!ignoreInnerClassesAttrib && (c->innerclasscount != 0)) {
                /* search for passed class as inner class */
@@ -402,10 +368,13 @@ s4 _Jv_java_lang_Class_getModifiers(java_lang_Class *klass, s4 ignoreInnerClasse
 java_lang_Class *_Jv_java_lang_Class_getDeclaringClass(java_lang_Class *klass)
 {
        classinfo *c;
+       classinfo *dc;
+
+       c = LLNI_classinfo_unwrap(klass);
 
-       c = (classinfo *) klass;
+       dc = class_get_declaringclass(c);
 
-       return (java_lang_Class *) class_get_declaringclass(c);
+       return LLNI_classinfo_wrap(dc);
 }
 
 
@@ -419,7 +388,7 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredClasses(java_lang_Clas
        classinfo                 *c;
        java_handle_objectarray_t *oa;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        oa = class_get_declaredclasses(c, publicOnly);
 
@@ -442,7 +411,7 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredFields(java_lang_Class
        s4 pos;
        s4 i;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        /* determine number of fields */
 
@@ -493,7 +462,7 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredMethods(java_lang_Clas
        s4 pos;
        s4 i;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        public_methods = 0;
 
@@ -557,7 +526,7 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredConstructors(java_lang
        s4 pos;
        s4 i;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        /* determine number of constructors */
 
@@ -603,7 +572,7 @@ java_lang_ClassLoader *_Jv_java_lang_Class_getClassLoader(java_lang_Class *klass
 {
        classinfo *c;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        if (c->classloader == NULL)
                return NULL;
@@ -623,7 +592,7 @@ JNIEXPORT int32_t JNICALL _Jv_java_lang_Class_isArray(JNIEnv *env, java_lang_Cla
 {
        classinfo *c;
 
-       c = (classinfo *) this;
+       c = LLNI_classinfo_unwrap(this);
 
        return class_is_array(c);
 }
@@ -654,7 +623,7 @@ void _Jv_java_lang_Class_throwException(java_lang_Throwable *t)
  */
 java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass)
 {
-       classinfo                *c               = (classinfo*)klass;
+       classinfo                *c               = LLNI_classinfo_unwrap(klass);
        static methodinfo        *m_parseAnnotationsIntoArray   = NULL;
        utf                      *utf_parseAnnotationsIntoArray = NULL;
        utf                      *utf_desc        = NULL;
@@ -725,41 +694,6 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_
 #endif
 
 
-/*
- * Class:     java/lang/Class
- * Method:    getEnclosingClass
- * Signature: (Ljava/lang/Class;)Ljava/lang/Class;
- */
-java_lang_Class *_Jv_java_lang_Class_getEnclosingClass(java_lang_Class *klass)
-{
-       classinfo             *c;
-       classref_or_classinfo  cr;
-       classinfo             *ec;
-
-       c = (classinfo *) klass;
-
-       /* get enclosing class */
-
-       cr = c->enclosingclass;
-
-       if (cr.any == NULL)
-               return NULL;
-
-       /* resolve the class if necessary */
-
-       if (IS_CLASSREF(cr)) {
-               ec = resolve_classref_eager(cr.ref);
-
-               if (ec == NULL)
-                       return NULL;
-       }
-       else
-               ec = cr.cls;
-
-       return (java_lang_Class *) ec;
-}
-
-
 /* _Jv_java_lang_Class_getEnclosingMethod_intern *******************************
 
    Helper function for _Jv_java_lang_Class_getEnclosingConstructor and
@@ -769,35 +703,23 @@ java_lang_Class *_Jv_java_lang_Class_getEnclosingClass(java_lang_Class *klass)
 
 static methodinfo *_Jv_java_lang_Class_getEnclosingMethod_intern(classinfo *c)
 {
-       classref_or_classinfo     cr;
-       constant_nameandtype     *cn;
-       classinfo                *ec;
-       methodinfo               *m;
+       constant_nameandtype *cn;
+       classinfo            *ec;
+       methodinfo           *m;
 
        /* get enclosing class and method */
 
-       cr = c->enclosingclass;
+       ec = class_get_enclosingclass(c);
        cn = c->enclosingmethod;
 
        /* check for enclosing class and method */
 
-       if (cr.any == NULL)
+       if (ec == NULL)
                return NULL;
 
        if (cn == NULL)
                return NULL;
 
-       /* resolve the class if necessary */
-
-       if (IS_CLASSREF(cr)) {
-               ec = resolve_classref_eager(cr.ref);
-
-               if (ec == NULL)
-                       return NULL;
-       }
-       else
-               ec = cr.cls;
-
        /* find method in enclosing class */
 
        m = class_findmethod(ec, cn->name, cn->descriptor);
@@ -822,7 +744,7 @@ java_lang_reflect_Constructor *_Jv_java_lang_Class_getEnclosingConstructor(java_
        methodinfo                    *m;
        java_lang_reflect_Constructor *rc;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        /* get enclosing method */
 
@@ -855,7 +777,7 @@ java_lang_reflect_Method *_Jv_java_lang_Class_getEnclosingMethod(java_lang_Class
        methodinfo               *m;
        java_lang_reflect_Method *rm;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        /* get enclosing method */
 
@@ -887,7 +809,7 @@ java_lang_String *_Jv_java_lang_Class_getClassSignature(java_lang_Class* klass)
        classinfo     *c;
        java_handle_t *o;
 
-       c = (classinfo *) klass;
+       c = LLNI_classinfo_unwrap(klass);
 
        if (c->signature == NULL)
                return NULL;
@@ -899,32 +821,6 @@ java_lang_String *_Jv_java_lang_Class_getClassSignature(java_lang_Class* klass)
        return (java_lang_String *) o;
 }
 
-
-#if 0
-/*
- * Class:     java/lang/Class
- * Method:    isAnonymousClass
- * Signature: (Ljava/lang/Class;)Z
- */
-s4 _Jv_java_lang_Class_isAnonymousClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isLocalClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-
-
-/*
- * Class:     java/lang/VMClass
- * Method:    isMemberClass
- * Signature: (Ljava/lang/Class;)Z
- */
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-#endif
-
 #endif /* ENABLE_JAVASE */
 
 
index 759d9421c7734a835ba9cc44c68668f1ffd280ae..676d1d53a765bfaedf578f8bb9c008082238cf4b 100644 (file)
@@ -68,7 +68,6 @@ JNIEXPORT int32_t JNICALL      _Jv_java_lang_Class_isInterface(JNIEnv *env, java
 s4                             _Jv_java_lang_Class_isPrimitive(java_lang_Class *klass);
 java_lang_Class               *_Jv_java_lang_Class_getSuperclass(java_lang_Class *klass);
 java_handle_objectarray_t     *_Jv_java_lang_Class_getInterfaces(java_lang_Class *klass);
-java_lang_Class               *_Jv_java_lang_Class_getComponentType(java_lang_Class *klass);
 s4                             _Jv_java_lang_Class_getModifiers(java_lang_Class *klass, s4 ignoreInnerClassesAttrib);
 java_lang_Class               *_Jv_java_lang_Class_getDeclaringClass(java_lang_Class *klass);
 java_handle_objectarray_t     *_Jv_java_lang_Class_getDeclaredClasses(java_lang_Class *klass, s4 publicOnly);
@@ -87,19 +86,12 @@ void                           _Jv_java_lang_Class_throwException(java_lang_Thro
 java_handle_objectarray_t     *_Jv_java_lang_Class_getDeclaredAnnotations(java_lang_Class* klass);
 #endif
 
-java_lang_Class               *_Jv_java_lang_Class_getEnclosingClass(java_lang_Class *klass);
 java_lang_reflect_Constructor *_Jv_java_lang_Class_getEnclosingConstructor(java_lang_Class *klass);
 java_lang_reflect_Method      *_Jv_java_lang_Class_getEnclosingMethod(java_lang_Class *klass);
 
 java_lang_String              *_Jv_java_lang_Class_getClassSignature(java_lang_Class* klass);
 #endif
 
-#if 0
-s4                             _Jv_java_lang_Class_isAnonymousClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, struct java_lang_Class* par1);
-#endif
-
 #endif /* _JV_JAVA_LANG_CLASS_H */
 
 
index 0bb4034f1c05b8fd1aff296dafc12bc0d6536742..43a4f87b4f5c5e69e62aaafbed6dfd75e1b116f6 100644 (file)
@@ -141,7 +141,7 @@ java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl
 
        /* for convenience */
 
-       o = (java_lang_Class *) c;
+       o = LLNI_classinfo_wrap(c);
 
 #if defined(WITH_CLASSPATH_GNU)
        /* set ProtectionDomain */
index f5ff5afa73b568886b717826177d48ffffb6c5ce..191ed2448ebde4cd97625b352cb10c246c75af79 100644 (file)
@@ -78,7 +78,7 @@ java_lang_Class *_Jv_java_lang_Object_getClass(java_lang_Object *obj)
 
        LLNI_class_get(obj, c);
 
-       return (java_lang_Class *) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
index db374048f250782f48ddf3f1eae64e7477e6a7e3..c202319670f90742388e1999a67f3da9da37622f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: reflect.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: reflect.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -83,12 +83,10 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
        java_handle_t                 *o;
        java_lang_reflect_Constructor *rc;
        int32_t                        slot;
-       java_handle_bytearray_t       *annotations          = NULL;
-       java_handle_bytearray_t       *parameterAnnotations = NULL;
 
        /* get declaring class */
 
-       c = (classinfo *) m->class;
+       c = m->class;
 
        /* allocate a new object */
 
@@ -105,22 +103,12 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m)
 
        slot = m - c->methods;
 
-#if defined(ENABLE_ANNOTATIONS)
-       /* get annotations */
-
-       annotations = method_get_annotations(m);
-
-       /* get parameter annotations */
-
-       parameterAnnotations = method_get_parameterannotations(m);
-#endif
-
 #if defined(WITH_CLASSPATH_GNU)
 
        LLNI_field_set_cls(rc, clazz               , c);
        LLNI_field_set_val(rc, slot                , slot);
-       LLNI_field_set_ref(rc, annotations         , annotations);
-       LLNI_field_set_ref(rc, parameterAnnotations, parameterAnnotations);
+       LLNI_field_set_ref(rc, annotations         , method_get_annotations(m));
+       LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m));
 
 #elif defined(WITH_CLASSPATH_SUN)
 
@@ -130,8 +118,8 @@ java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *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         , annotations);
-       LLNI_field_set_ref(rc, parameterAnnotations, parameterAnnotations);
+       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
@@ -154,11 +142,10 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
        java_handle_t           *o;
        java_lang_reflect_Field *rf;
        int32_t                  slot;
-       java_handle_bytearray_t *annotations = NULL;
 
        /* get declaring class */
 
-       c = (classinfo *) f->class;
+       c = f->class;
 
        /* allocate a new object */
 
@@ -175,12 +162,6 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
 
        slot = f - c->fields;
 
-#if defined(ENABLE_ANNOTATIONS)
-       /* get annotations */
-
-       annotations = field_get_annotations(f);
-#endif
-
 #if defined(WITH_CLASSPATH_GNU)
 
        LLNI_field_set_cls(rf, clazz         , c);
@@ -190,7 +171,7 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *f)
 
        LLNI_field_set_ref(rf, name          , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(f->name)));
        LLNI_field_set_val(rf, slot          , slot);
-       LLNI_field_set_ref(rf, annotations   , annotations);
+       LLNI_field_set_ref(rf, annotations   , field_get_annotations(f));
 
 #elif defined(WITH_CLASSPATH_SUN)
 
@@ -204,7 +185,7 @@ java_lang_reflect_Field *reflect_field_new(fieldinfo *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   , annotations);
+       LLNI_field_set_ref(rf, annotations   , field_get_annotations(f));
 
 #else
 # error unknown classpath configuration
@@ -227,13 +208,10 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
        java_handle_t            *o;
        java_lang_reflect_Method *rm;
        int32_t                   slot;
-       java_handle_bytearray_t  *annotations          = NULL;
-       java_handle_bytearray_t  *parameterAnnotations = NULL;
-       java_handle_bytearray_t  *annotationDefault    = NULL;
 
        /* get declaring class */
 
-       c = (classinfo *) m->class;
+       c = m->class;
 
        /* allocate a new object */
 
@@ -250,20 +228,6 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
 
        slot = m - c->methods;
 
-#if defined(ENABLE_ANNOTATIONS)
-       /* get annotations */
-
-       annotations = method_get_annotations(m);
-
-       /* get parameter annotations */
-
-       parameterAnnotations = method_get_parameterannotations(m);
-
-       /* get annotation default value */
-
-       annotationDefault = method_get_annotationdefault(m);
-#endif
-
 #if defined(WITH_CLASSPATH_GNU)
 
        LLNI_field_set_cls(rm, clazz               , m->class);
@@ -273,9 +237,9 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *m)
 
        LLNI_field_set_ref(rm, name                , _Jv_java_lang_String_intern((java_lang_String *) javastring_new(m->name)));
        LLNI_field_set_val(rm, slot                , slot);
-       LLNI_field_set_ref(rm, annotations         , annotations);
-       LLNI_field_set_ref(rm, parameterAnnotations, parameterAnnotations);
-       LLNI_field_set_ref(rm, annotationDefault   , annotationDefault);
+       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));
 
 #elif defined(WITH_CLASSPATH_SUN)
 
@@ -291,9 +255,9 @@ java_lang_reflect_Method *reflect_method_new(methodinfo *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         , annotations);
-       LLNI_field_set_ref(rm, parameterAnnotations, parameterAnnotations);
-       LLNI_field_set_ref(rm, annotationDefault   , annotationDefault);
+       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));
 
 #else
 # error unknown classpath configuration
@@ -401,7 +365,7 @@ java_handle_objectarray_t* reflect_get_parameterannotations(
 
        /* get parameter count */
 
-       c = (classinfo *)declaringClass;
+       c = LLNI_classinfo_unwrap(declaringClass);
        m = &(c->methods[slot]);
 
        numParameters = method_get_parametercount(m);
index 2394c9a25bc9e33a064e6b56aecfdcc2be5e6f60..86a77e541fd7d27f27bb2305a64fb08eff36e60e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jvm.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: jvm.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
 
 #include "toolbox/logging.h"
 
+#include "vm/array.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
+#include "vm/global.h"
 #include "vm/initialize.h"
 #include "vm/primitive.h"
 #include "vm/properties.h"
@@ -464,7 +466,7 @@ jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index)
        /* get declaring class name */
 
        declaringclass =
-               _Jv_java_lang_Class_getName((java_lang_Class *) ste->method->class);
+               _Jv_java_lang_Class_getName(LLNI_classinfo_wrap(ste->method->class));
 
        /* fill the java.lang.StackTraceElement element */
 
@@ -652,12 +654,17 @@ jclass JVM_GetCallerClass(JNIEnv* env, int depth)
 
 /* JVM_FindPrimitiveClass */
 
-jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* utf)
+jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* s)
 {
-#if PRINTVM
-       log_println("JVM_FindPrimitiveClass: utf=%s", utf);
-#endif
-       return (jclass) primitive_class_get_by_name(utf_new_char(utf));
+       classinfo *c;
+       utf       *u;
+
+       TRACEJVMCALLS("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s);
+
+       u = utf_new_char(s);
+       c = primitive_class_get_by_name(u);
+
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -689,7 +696,7 @@ jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init
                        if (!initialize_class(c))
                                return NULL;
 
-       return (jclass) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -718,7 +725,7 @@ jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader,
 #endif
        /* XXX do something with pd and source */
 
-       return (jclass) class_define(utf_new_char(name), (classloader *) loader, len, (u1 *) buf);
+       return LLNI_classinfo_wrap( class_define(utf_new_char(name), (classloader *) loader, len, (u1 *) buf) );
 
 }
 
@@ -740,7 +747,7 @@ jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)
        u = javastring_toutf((java_handle_t *) name, true);
        c = classcache_lookup(cl, u);
 
-       return (jclass) c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -764,7 +771,7 @@ jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls)
 
        TRACEJVMCALLS("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls);
 
-       c = (classinfo *) cls;
+       c = LLNI_classinfo_unwrap(cls);
 
        oa = class_get_interfaces(c);
 
@@ -793,7 +800,7 @@ jboolean JVM_IsInterface(JNIEnv *env, jclass cls)
        log_println("JVM_IsInterface: cls=%p", cls);
 #endif
 
-       c = (classinfo *) cls;
+       c = LLNI_classinfo_unwrap(cls);
 
        return class_is_interface(c);
 }
@@ -825,7 +832,7 @@ jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls)
        log_println("JVM_GetProtectionDomain: cls=%p");
 #endif
 
-       c = (classinfo *) cls;
+       c = LLNI_classinfo_unwrap(cls);
 
        if (c == NULL) {
                exceptions_throw_nullpointerexception();
@@ -836,6 +843,8 @@ jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls)
 
        if (class_is_primitive(c))
                return NULL;
+
+       return NULL;
 }
 
 
@@ -918,7 +927,7 @@ jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls)
 #if PRINTJVM
        log_println("JVM_IsArrayClass: cls=%p", cls);
 #endif
-       return class_is_array((classinfo *) cls);
+       return class_is_array(LLNI_classinfo_unwrap(cls));
 }
 
 
@@ -928,7 +937,7 @@ jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)
 {
        classinfo *c;
 
-       c = (classinfo *) cls;
+       c = LLNI_classinfo_unwrap(cls);
 
 #if PRINTJVM
        log_println("JVM_IsPrimitiveClass(cls=%p)", cls);
@@ -942,10 +951,16 @@ jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls)
 
 jclass JVM_GetComponentType(JNIEnv *env, jclass cls)
 {
-#if PRINTJVM
-       log_println("JVM_GetComponentType: cls=%p", cls);
-#endif
-       return (jclass) _Jv_java_lang_Class_getComponentType((java_lang_Class *) cls);
+       classinfo *component;
+       classinfo *c;
+       
+       TRACEJVMCALLS("JVM_GetComponentType(env=%p, cls=%p)", env, cls);
+
+       c = LLNI_classinfo_unwrap(cls);
+       
+       component = class_get_componenttype(c);
+
+       return LLNI_classinfo_wrap(component);
 }
 
 
@@ -959,7 +974,7 @@ jint JVM_GetClassModifiers(JNIEnv *env, jclass cls)
        log_println("JVM_GetClassModifiers: cls=%p", cls);
 #endif
 
-       c = (classinfo *) cls;
+       c = LLNI_classinfo_unwrap(cls);
 
        /* XXX is this correct? */
 
@@ -976,7 +991,7 @@ jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)
 
        TRACEJVMCALLS("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass);
 
-       c = (classinfo *) ofClass;
+       c = LLNI_classinfo_unwrap(ofClass);
 
        oa = class_get_declaredclasses(c, false);
 
@@ -988,7 +1003,7 @@ jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)
 
 jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)
 {
-       classinfo *c = (classinfo*)ofClass;
+       classinfo *c = LLNI_classinfo_unwrap(ofClass);
 
        TRACEJVMCALLS("JVM_GetDeclaringClass: ofClass=%p", ofClass);
 
@@ -997,7 +1012,7 @@ jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass)
                return NULL;
        }
 
-       return (jclass)class_get_declaringclass(c);
+       return LLNI_classinfo_wrap(class_get_declaringclass(c));
 }
 
 
@@ -1014,8 +1029,8 @@ jstring JVM_GetClassSignature(JNIEnv *env, jclass cls)
 jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
 {
 #if defined(ENABLE_ANNOTATIONS)
-       classinfo *c = (classinfo*)cls;
-       java_bytearray *annotations = NULL;
+       classinfo *c = LLNI_classinfo_unwrap(cls);
+       java_handle_bytearray_t *annotations = NULL;
 
        TRACEJVMCALLS("JVM_GetClassAnnotations: cls=%p", cls);
 
@@ -1054,7 +1069,7 @@ jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls)
 jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
 {
        java_lang_reflect_Field *rf = (java_lang_reflect_Field*)field;
-       java_bytearray          *ba = NULL;
+       java_handle_bytearray_t *ba = NULL;
 
        TRACEJVMCALLS("JVM_GetFieldAnnotations: field=%p", field);
 
@@ -1074,7 +1089,7 @@ jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field)
 jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
 {
        java_lang_reflect_Method *rm = (java_lang_reflect_Method*)method;
-       java_bytearray           *ba = NULL;
+       java_handle_bytearray_t  *ba = NULL;
 
        TRACEJVMCALLS("JVM_GetMethodAnnotations: method=%p", method);
 
@@ -1094,7 +1109,7 @@ jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method)
 jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
 {
        java_lang_reflect_Method *rm = (java_lang_reflect_Method*)method;
-       java_bytearray           *ba = NULL;
+       java_handle_bytearray_t  *ba = NULL;
 
        TRACEJVMCALLS("JVM_GetMethodDefaultAnnotationValue: method=%p", method);
 
@@ -1114,7 +1129,7 @@ jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method)
 jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method)
 {
        java_lang_reflect_Method *rm = (java_lang_reflect_Method*)method;
-       java_bytearray           *ba = NULL;
+       java_handle_bytearray_t  *ba = NULL;
 
        TRACEJVMCALLS("JVM_GetMethodParameterAnnotations: method=%p", method);
 
@@ -1172,7 +1187,7 @@ jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)
        log_println("JVM_GetClassAccessFlags: cls=%p", cls);
 #endif
 
-       c = (classinfo *) cls;
+       c = LLNI_classinfo_unwrap(cls);
 
        return c->flags & ACC_CLASS_REFLECT_MASK;
 }
@@ -1213,7 +1228,7 @@ jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls)
 
 jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
 {
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
        TRACEJVMCALLS("JVM_ConstantPoolGetSize: jcpool=%p", jcpool);
        return cls->cpcount;
 }
@@ -1224,7 +1239,7 @@ jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool)
 jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        constant_classref *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
        
        TRACEJVMCALLS("JVM_ConstantPoolGetClassAt: jcpool=%p, index=%d", jcpool, index);
 
@@ -1234,7 +1249,7 @@ jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, j
                return NULL;
        }
 
-       return (jclass)resolve_classref_eager(ref);
+       return LLNI_classinfo_wrap(resolve_classref_eager(ref));
 }
 
 
@@ -1244,7 +1259,7 @@ jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject j
 {
        constant_classref *ref;
        classinfo *c = NULL;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetClassAtIfLoaded: jcpool=%p, index=%d", jcpool, index);
 
@@ -1262,7 +1277,7 @@ jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject j
                return NULL;
        }
        
-       return (jclass)c;
+       return LLNI_classinfo_wrap(c);
 }
 
 
@@ -1271,7 +1286,7 @@ jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject j
 jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        constant_FMIref *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
        
        TRACEJVMCALLS("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index);
 
@@ -1292,7 +1307,7 @@ jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject
 {
        constant_FMIref *ref;
        classinfo *c = NULL;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index);
 
@@ -1319,7 +1334,7 @@ jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject
 jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        constant_FMIref *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
        
        TRACEJVMCALLS("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index);
 
@@ -1339,12 +1354,11 @@ jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject
 {
        constant_FMIref *ref;
        classinfo *c;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index);
 
-       ref = (constant_FMIref*)class_getconstant(
-               (classinfo*)cls, index, CONSTANT_Fieldref);
+       ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref);
 
        if (ref == NULL) {
                return NULL;
@@ -1376,7 +1390,7 @@ jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, job
 jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        constant_integer *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index);
 
@@ -1395,7 +1409,7 @@ jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint
 jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        constant_long *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index);
 
@@ -1414,7 +1428,7 @@ jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jin
 jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        constant_float *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index);
 
@@ -1433,7 +1447,7 @@ jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, j
 jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        constant_double *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index);
 
@@ -1452,7 +1466,7 @@ jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool,
 jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        utf *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index);
        
@@ -1472,7 +1486,7 @@ jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool,
 jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index)
 {
        utf *ref;
-       classinfo *cls = (classinfo*)jcpool;
+       classinfo *cls = LLNI_classinfo_unwrap(jcpool);
 
        TRACEJVMCALLS("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index);
 
@@ -2165,11 +2179,11 @@ jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring c
 
 jint JVM_GetArrayLength(JNIEnv *env, jobject arr)
 {
-       java_arrayheader *a;
+       java_array_t *a;
 
        TRACEJVMCALLS("JVM_GetArrayLength(arr=%p)", arr);
 
-       a = (java_arrayheader *) arr;
+       a = (java_array_t *) arr;
 
        if (a == NULL) {
                exceptions_throw_nullpointerexception();
@@ -2190,14 +2204,12 @@ jint JVM_GetArrayLength(JNIEnv *env, jobject arr)
 
 jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
 {
-/*     log_println("JVM_GetArrayElement: IMPLEMENT ME!"); */
+       java_array_t *a;
+       int           elementtype;
 
-       java_arrayheader *a = NULL;
-       int32_t elementtype = 0;
+       TRACEJVMCALLS("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index);
 
-       TRACEJVMCALLS("JVM_GetArrayElement: arr=%p, index=%d", arr, index);
-
-       a = (java_arrayheader *) arr;
+       a = (java_array_t *) arr;
 
        if (a == NULL) {
                exceptions_throw_nullpointerexception();
@@ -2210,7 +2222,7 @@ jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
        }
        
        if (index < 0 || index > a->size) {
-               exceptions_new_arrayindexoutofboundsexception(index);
+               exceptions_throw_arrayindexoutofboundsexception();
                return NULL;
        }
        
@@ -2218,23 +2230,23 @@ jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index)
 
        switch (elementtype) {
        case ARRAYTYPE_INT:
-               return (jobject)primitive_box_int(((java_intarray*)a)->data[index]);
+               return (jobject)primitive_box_int(((java_handle_intarray_t*)a)->data[index]);
        case ARRAYTYPE_LONG:
-               return (jobject)primitive_box_long(((java_longarray*)a)->data[index]);
+               return (jobject)primitive_box_long(((java_handle_longarray_t*)a)->data[index]);
        case ARRAYTYPE_FLOAT:
-               return (jobject)primitive_box_float(((java_floatarray*)a)->data[index]);
+               return (jobject)primitive_box_float(((java_handle_floatarray_t*)a)->data[index]);
        case ARRAYTYPE_DOUBLE:
-               return (jobject)primitive_box_double(((java_doublearray*)a)->data[index]);
+               return (jobject)primitive_box_double(((java_handle_doublearray_t*)a)->data[index]);
        case ARRAYTYPE_BYTE:
-               return (jobject)primitive_box_byte(((java_bytearray*)a)->data[index]);
+               return (jobject)primitive_box_byte(((java_handle_bytearray_t*)a)->data[index]);
        case ARRAYTYPE_CHAR:
-               return (jobject)primitive_box_char(((java_chararray*)a)->data[index]);
+               return (jobject)primitive_box_char(((java_handle_chararray_t*)a)->data[index]);
        case ARRAYTYPE_SHORT:
-               return (jobject)primitive_box_short(((java_shortarray*)a)->data[index]);
+               return (jobject)primitive_box_short(((java_handle_shortarray_t*)a)->data[index]);
        case ARRAYTYPE_BOOLEAN:
-               return (jobject)primitive_box_boolean(((java_booleanarray*)a)->data[index]);
+               return (jobject)primitive_box_boolean(((java_handle_booleanarray_t*)a)->data[index]);
        case ARRAYTYPE_OBJECT:
-               return (jobject)((java_objectarray*)a)->data[index];
+               return (jobject)((java_handle_objectarray_t*)a)->data[index];
        default:
                /* invalid element type */
                exceptions_throw_internalerror("invalid element type code in array descriptor: %d", elementtype);
@@ -2278,7 +2290,7 @@ jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length)
 
        TRACEJVMCALLS("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length);
 
-       c = (classinfo *) eltClass;
+       c = LLNI_classinfo_unwrap(eltClass);
 
        /* create primitive or object array */
 
index 46b30edc16ebbd2d946894f14fac295658df9936..496cff0de88d807c98fea597a7af12da7b5edc41 100644 (file)
@@ -466,7 +466,7 @@ JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env,
 {
        classinfo *c;
 
-       c = (classinfo *) class;
+       c = LLNI_classinfo_unwrap(class);
 
        if (!(c->state & CLASS_INITIALIZED))
                initialize_class(c);
@@ -483,7 +483,7 @@ JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, sun_
        classinfo       *c;
        arraydescriptor *ad;
 
-       c  = (classinfo *) arrayClass;
+       c  = LLNI_classinfo_unwrap(arrayClass);
        ad = c->vftbl->arraydesc;
 
        if (ad == NULL) {
@@ -506,7 +506,7 @@ JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, sun_
        classinfo       *c;
        arraydescriptor *ad;
 
-       c  = (classinfo *) arrayClass;
+       c  = LLNI_classinfo_unwrap(arrayClass);
        ad = c->vftbl->arraydesc;
 
        if (ad == NULL) {
@@ -576,7 +576,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_
 
        /* for convenience */
 
-       o = (java_lang_Class *) c;
+       o = LLNI_classinfo_wrap(c);
 
 #if defined(WITH_CLASSPATH_GNU)
        /* set ProtectionDomain */
index bd2e663622b910afb0854ef4c3b4706ff81acafc..6a6e8d8c5a9acba79edad620b7713485e760c106 100644 (file)
@@ -22,7 +22,7 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 8299 2007-08-13 08:41:18Z michi $
+## $Id: Makefile.am 8343 2007-08-17 21:39:32Z michi $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -48,6 +48,8 @@ noinst_LTLIBRARIES = \
 libvm_la_SOURCES = \
        access.c \
        access.h \
+       array.c \
+       array.h \
        builtin.c \
        builtin.h \
        builtintable.inc \
diff --git a/src/vm/array.c b/src/vm/array.c
new file mode 100644 (file)
index 0000000..2f7abe9
--- /dev/null
@@ -0,0 +1,137 @@
+/* src/vm/array.c - array functions
+
+   Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   $Id: access.c 8318 2007-08-16 10:05:34Z michi $
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "native/llni.h"
+
+#include "vm/array.h"
+#include "vm/global.h"
+#include "vm/vm.h"
+
+
+/* array_element_primitive_get *************************************************
+
+   Returns a primitive element of the given Java array.
+
+*******************************************************************************/
+
+imm_union array_element_primitive_get(java_handle_t *a, int32_t index)
+{
+       vftbl_t  *v;
+       int       elementtype;
+       imm_union value;
+
+       v = LLNI_vftbl_direct(a);
+
+       elementtype = v->arraydesc->elementtype;
+
+       switch (elementtype) {
+       case ARRAYTYPE_BOOLEAN:
+               value.i = array_booleanarray_element_get(a, index);
+               break;
+       case ARRAYTYPE_BYTE:
+               value.i = array_bytearray_element_get(a, index);
+               break;
+       case ARRAYTYPE_CHAR:
+               value.i = array_chararray_element_get(a, index);
+               break;
+       case ARRAYTYPE_SHORT:
+               value.i = array_shortarray_element_get(a, index);
+               break;
+       case ARRAYTYPE_INT:
+               value.i = array_intarray_element_get(a, index);
+               break;
+       case ARRAYTYPE_LONG:
+               value.l = array_longarray_element_get(a, index);
+               break;
+       case ARRAYTYPE_FLOAT:
+               value.f = array_floatarray_element_get(a, index);
+               break;
+       case ARRAYTYPE_DOUBLE:
+               value.d = array_doublearray_element_get(a, index);
+               break;
+       case ARRAYTYPE_OBJECT:
+               value.a = array_objectarray_element_get(a, index);
+               break;
+
+       default:
+               vm_abort("array_element_primitive_get: invalid array element type %d",
+                                elementtype);
+       }
+
+       return value;
+}
+
+
+/* array_xxxarray_element_get **************************************************
+
+   Returns a primitive element of the given Java array.
+
+*******************************************************************************/
+
+#define ARRAY_TYPEARRAY_ELEMENT_GET(name, type)                       \
+type array_##name##array_element_get(java_handle_t *a, int32_t index) \
+{                                                                     \
+       java_handle_##name##array_t *ja;                                  \
+       type                         value;                               \
+                                                                      \
+       ja = (java_handle_##name##array_t *) a;                           \
+                                                                      \
+       value = LLNI_array_direct(ja, index);                             \
+                                                                      \
+       return value;                                                     \
+}
+
+ARRAY_TYPEARRAY_ELEMENT_GET(boolean, uint8_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(byte,    int8_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(char,    uint16_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(short,   int16_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(int,     int32_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(long,    int64_t)
+ARRAY_TYPEARRAY_ELEMENT_GET(float,   float)
+ARRAY_TYPEARRAY_ELEMENT_GET(double,  double)
+ARRAY_TYPEARRAY_ELEMENT_GET(object,  java_handle_t*)
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/vm/array.h b/src/vm/array.h
new file mode 100644 (file)
index 0000000..02b20d1
--- /dev/null
@@ -0,0 +1,87 @@
+/* src/vm/array.h - array functions
+
+   Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   $Id: access.c 8318 2007-08-16 10:05:34Z michi $
+
+*/
+
+
+#ifndef _VM_ARRAY_H
+#define _VM_ARRAY_H
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/global.h"
+#include "vm/primitive.h"
+
+
+/* array types ****************************************************************/
+
+/* CAUTION: Don't change the numerical values! These constants (with
+   the exception of ARRAYTYPE_OBJECT) are used as indices in the
+   primitive type table. */
+
+#define ARRAYTYPE_INT         PRIMITIVETYPE_INT
+#define ARRAYTYPE_LONG        PRIMITIVETYPE_LONG
+#define ARRAYTYPE_FLOAT       PRIMITIVETYPE_FLOAT
+#define ARRAYTYPE_DOUBLE      PRIMITIVETYPE_DOUBLE
+#define ARRAYTYPE_BYTE        PRIMITIVETYPE_BYTE
+#define ARRAYTYPE_CHAR        PRIMITIVETYPE_CHAR
+#define ARRAYTYPE_SHORT       PRIMITIVETYPE_SHORT
+#define ARRAYTYPE_BOOLEAN     PRIMITIVETYPE_BOOLEAN
+#define ARRAYTYPE_OBJECT      PRIMITIVETYPE_VOID     /* don't use as index! */
+
+
+/* function prototypes ********************************************************/
+
+imm_union      array_element_primitive_get(java_handle_t *a, int32_t index);
+
+uint8_t        array_booleanarray_element_get(java_handle_t *a, int32_t index);
+int8_t         array_bytearray_element_get(java_handle_t *a, int32_t index);
+uint16_t       array_chararray_element_get(java_handle_t *a, int32_t index);
+int16_t        array_shortarray_element_get(java_handle_t *a, int32_t index);
+int32_t        array_intarray_element_get(java_handle_t *a, int32_t index);
+int64_t        array_longarray_element_get(java_handle_t *a, int32_t index);
+float          array_floatarray_element_get(java_handle_t *a, int32_t index);
+double         array_doublearray_element_get(java_handle_t *a, int32_t index);
+java_handle_t *array_objectarray_element_get(java_handle_t *a, int32_t index);
+
+#endif /* _VM_ARRAY_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 2286c40f7499f94b5adc8a477c3d35f6713d114a..69e93ed57d68ba4f94865e348124903e6abec89d 100644 (file)
@@ -28,7 +28,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: builtin.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -64,6 +64,7 @@
 #include "toolbox/logging.h"
 #include "toolbox/util.h"
 
+#include "vm/array.h"
 #include "vm/builtin.h"
 #include "vm/cycles-stats.h"
 #include "vm/exceptions.h"
index 2649ead6d1fcdac61567404c53014b6f57f52ea3..c256be90c1d4926480de0eaeda3ebf55b2681ec5 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: global.h 8324 2007-08-16 16:48:12Z michi $
+   $Id: global.h 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -177,14 +177,16 @@ typedef struct java_objectarray_t java_objectarray_t;
 
 #define ACC_CLASS_REFLECT_MASK      0x0000ffff/* flags reported by reflection */
 
-#define ACC_CLASS_PRIMITIVE         0x00010000/* class is a primitive class   */
+#define ACC_CLASS_PRIMITIVE         0x00010000
+#define ACC_CLASS_MEMBER            0x00020000
+#define ACC_CLASS_ANONYMOUS         0x00040000
 
-#define ACC_CLASS_HAS_POINTERS      0x00020000/* instance contains pointers   */
+#define ACC_CLASS_HAS_POINTERS      0x00080000/* instance contains pointers   */
 
-#define ACC_CLASS_REFERENCE_MASK    0x001c0000
-#define ACC_CLASS_REFERENCE_SOFT    0x00040000
-#define ACC_CLASS_REFERENCE_WEAK    0x00080000
-#define ACC_CLASS_REFERENCE_PHANTOM 0x00100000
+#define ACC_CLASS_REFERENCE_MASK    0x00700000
+#define ACC_CLASS_REFERENCE_SOFT    0x00100000
+#define ACC_CLASS_REFERENCE_WEAK    0x00200000
+#define ACC_CLASS_REFERENCE_PHANTOM 0x00400000
 
 
 /* special flags used in methodinfo *******************************************/
index 3b6fc16e094bffad188d697562767067ad6e0202..bee77ffc880e6fe72638e3f382ef868389e04d0f 100644 (file)
@@ -102,11 +102,15 @@ s4 get_lopart_disp(disp)
 #ifndef NDEBUG
 bool check_13bit_imm(s8 imm)
 {
-       s4 check = imm & ~0x1fff;
-       if (check == 0) return true; /* pos imm. */
-       if (check + 0x1fff == -1) return true; /* neg imm. */
+       s4 sign = (imm >> 12) & 0x1;
+
+       if (sign == 0) {
+               if ((imm & ~0xfff) == 0) return true; /* pos imm. */
+       }
+       else
+               if ((imm & ~0xfff) + 0xfff == -1) return true; /* neg imm. */
        
-       printf("immediate out-of-bounds: %d\n", imm);
+       printf("immediate out-of-bounds: %ld\n", imm);
        return false;
 }
 #endif
@@ -2336,15 +2340,15 @@ nowperformreturn:
                        if (l == 0) {
                                M_INTMOVE(s1, REG_ITMP1);
                        }
-                       else if (l <= 4095) {
+                       else if (-l >= 4096 && -l <= 4095) {
                                M_ADD_IMM(s1, -l, REG_ITMP1);
                        }
                        else {
                                ICONST(REG_ITMP2, l);
-                               /* XXX: do I need to truncate s1 to 32-bit ? */
                                M_SUB(s1, REG_ITMP2, REG_ITMP1);
                        }
-                       i = i - l + 1;
+
+                       i = i - l + 1; /* number of targets (>0) */
 
 
                        /* range check */
index 6686a772b726c5c74793860e769ef8f9e021a406..e46299737c42277f3a3c52e83d91668c46a739e3 100644 (file)
@@ -41,9 +41,9 @@
 
 /* debug defines **************************************************************/
 #ifndef NDEBUG
-# define PASS13BIT(imm) (imm) & 0x1fff
+# define PASS13BIT(imm) ((((s4)(imm)&0x1fff)<<19)>>19)
 #else
-# define PASS13BIT(imm)
+# define PASS13BIT(imm) imm
 #endif
 
 
@@ -470,7 +470,7 @@ s4   get_lopart_disp(s4 disp);
         } \
         else { \
                DO_SETHI_PART(disp,rs,rd); \
-               M_LDX_INTERN(rd,rd,get_lopart_disp(disp)); \
+               M_LDX_INTERN(rd,rd,PASS13BIT(get_lopart_disp(disp))); \
         } \
     } while (0)
 
@@ -482,7 +482,7 @@ s4   get_lopart_disp(s4 disp);
        } \
         else { \
             DO_SETHI_PART(disp,rs,rd); \
-            M_ILD_INTERN(rd,rd,get_lopart_disp(disp)); \
+            M_ILD_INTERN(rd,rd,PASS13BIT(get_lopart_disp(disp))); \
         } \
     } while (0)
 
@@ -503,7 +503,7 @@ s4   get_lopart_disp(s4 disp);
         } \
         else { \
             DO_SETHI_PART(disp,rs,REG_ITMP3); \
-            M_STX_INTERN(rd,REG_ITMP3,get_lopart_disp(disp)); \
+            M_STX_INTERN(rd,REG_ITMP3,PASS13BIT(get_lopart_disp(disp))); \
         } \
     } while (0)
 
@@ -516,7 +516,7 @@ s4   get_lopart_disp(s4 disp);
        } \
         else { \
             DO_SETHI_PART(disp,rs,REG_ITMP3); \
-            M_IST_INTERN(rd,REG_ITMP3,get_lopart_disp(disp)); \
+            M_IST_INTERN(rd,REG_ITMP3,PASS13BIT(get_lopart_disp(disp))); \
         } \
     } while (0)
 
index 0a8007e4ade3c5d31288fab3c20b92130fdacf32..20ae99134a10504d109d5026c9cb36a3b468c7de 100644 (file)
@@ -36,6 +36,7 @@
 #include "vm/builtin.h"
 #include "mm/memory.h"
 
+#include "vm/array.h"
 #include "vm/global.h"
 #include "vm/primitive.h"
 
index 2dacbd54d559ba9efd34a49763f2abd176a76e4c..ef1498669307df5215ba5a85842db1920ccf398c 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "toolbox/logging.h"
 
+#include "vm/array.h"
 #include "vm/access.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
index 8728151d3a84ee8c432b5af8c8c4f51fa53a2d76..98883754754e50ff94c1aebef3cf51daea8ab025 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: typecheck.c 8299 2007-08-13 08:41:18Z michi $
+   $Id: typecheck.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -152,6 +152,7 @@ error reporting.
 #include "toolbox/logging.h"
 
 #include "vm/access.h"
+#include "vm/array.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
index c8694375a70e39abfdf3fe27eb058059f09cf040..aa35b4a9215c88be13feeefc1f7c570da7aecd25 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: typeinfo.c 8299 2007-08-13 08:41:18Z michi $
+   $Id: typeinfo.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
 #include <string.h>
 
 #include "mm/memory.h"
+
 #include "toolbox/logging.h"
 
+#include "vm/array.h"
 #include "vm/exceptions.h"
 #include "vm/primitive.h"
 #include "vm/resolve.h"
index 93eac1d737b8848e2019057cd2c7891b0496daa9..81a0d34fcce5f6406d8312d222c70e0f0f0b54bb 100644 (file)
@@ -168,6 +168,28 @@ classinfo *primitive_arrayclass_get_by_type(int type)
 }
 
 
+/* primitive_type_get_by_wrapperclass ******************************************
+
+   Returns the primitive type of the given wrapper-class.
+
+*******************************************************************************/
+
+int primitive_type_get_by_wrapperclass(classinfo *c)
+{
+       int i;
+
+       /* Search primitive table. */
+
+       for (i = 0; i < PRIMITIVETYPE_COUNT; i++)
+               if (primitivetype_table[i].class_wrap == c)
+                       return i;
+
+       /* Invalid primitive wrapper-class. */
+
+       return -1;
+}
+
+
 /* primitive_box ***************************************************************
 
    Box a primitive of the given type.
@@ -217,9 +239,15 @@ java_handle_t *primitive_box(int type, imm_union value)
 
 *******************************************************************************/
 
-imm_union primitive_unbox(int type, java_handle_t *o)
+imm_union primitive_unbox(java_handle_t *o)
 {
-       imm_union value;
+       classinfo *c;
+       int        type;
+       imm_union  value;
+
+       c = o->vftbl->class;
+
+       type = primitive_type_get_by_wrapperclass(c);
 
        switch (type) {
        case PRIMITIVETYPE_BOOLEAN:
index 5695f8fdde78a59e26911140be24b3f06700dfd5..6aa09df77657042a467070d6bd86d4e3519aced8 100644 (file)
 #define PRIMITIVETYPE_VOID    TYPE_VOID
 
 
-/* CAUTION: Don't change the numerical values! These constants (with
-   the exception of ARRAYTYPE_OBJECT) are used as indices in the
-   primitive type table. */
-
-#define ARRAYTYPE_INT         PRIMITIVETYPE_INT
-#define ARRAYTYPE_LONG        PRIMITIVETYPE_LONG
-#define ARRAYTYPE_FLOAT       PRIMITIVETYPE_FLOAT
-#define ARRAYTYPE_DOUBLE      PRIMITIVETYPE_DOUBLE
-#define ARRAYTYPE_BYTE        PRIMITIVETYPE_BYTE
-#define ARRAYTYPE_CHAR        PRIMITIVETYPE_CHAR
-#define ARRAYTYPE_SHORT       PRIMITIVETYPE_SHORT
-#define ARRAYTYPE_BOOLEAN     PRIMITIVETYPE_BOOLEAN
-#define ARRAYTYPE_OBJECT      PRIMITIVETYPE_VOID     /* don't use as index! */
-
-
 /* primitivetypeinfo **********************************************************/
 
 struct primitivetypeinfo {
@@ -110,11 +95,14 @@ bool       primitive_init(void);
 classinfo *primitive_class_get_by_name(utf *name);
 classinfo *primitive_class_get_by_type(int type);
 classinfo *primitive_class_get_by_char(char ch);
+
 classinfo *primitive_arrayclass_get_by_name(utf *name);
 classinfo *primitive_arrayclass_get_by_type(int type);
 
+int        primitive_type_get_by_wrapperclass(classinfo *c);
+
 java_handle_t *primitive_box(int type, imm_union value);
-imm_union      primitive_unbox(int type, java_handle_t *o);
+imm_union      primitive_unbox(java_handle_t *o);
 
 java_handle_t *primitive_box_boolean(int32_t value);
 java_handle_t *primitive_box_byte(int32_t value);
index d4d57ae13583c4ca4192cebebc2001af93d9047c..837d27e90f409426a536e3c05b66cecba0f0fdf9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: string.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: string.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -44,6 +44,7 @@
 
 #include "threads/lock-common.h"
 
+#include "vm/array.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/primitive.h"
index 0dbe62b71234e31455a248a4157563d82e39c244..093a9c11768257454939ab9cd25688b478d358fc 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: vm.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: vm.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -532,6 +532,7 @@ static void Xusage(void)
 }   
 
 
+#if 0
 static void XXusage(void)
 {
        puts("    -v                       write state-information");
@@ -610,6 +611,7 @@ static void XXusage(void)
 
        exit(1);
 }
+#endif
 
 
 /* version *********************************************************************
@@ -2720,6 +2722,7 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_object_t *o,
        uint64_t      *array;
        java_handle_t *param;
        classinfo     *c;
+       int            type;
        int32_t        i;
        int32_t        j;
        imm_union      value;
@@ -2757,54 +2760,69 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_object_t *o,
 
                        /* convert the value according to its declared type */
 
-                       c = param->vftbl->class;
+                       c    = param->vftbl->class;
+                       type = primitive_type_get_by_wrapperclass(c);
 
                        switch (td->decltype) {
                        case PRIMITIVETYPE_BOOLEAN:
-                               if (c == class_java_lang_Boolean)
-                                       LLNI_field_get_val((java_lang_Boolean *) param, value, value.i);
-                               else
+                               switch (type) {
+                               case PRIMITIVETYPE_BOOLEAN:
+                                       /* This type is OK. */
+                                       break;
+                               default:
                                        goto illegal_arg;
+                               }
                                break;
 
                        case PRIMITIVETYPE_BYTE:
-                               if (c == class_java_lang_Byte)
-                                       LLNI_field_get_val((java_lang_Byte *) param, value, value.i);
-                               else
+                               switch (type) {
+                               case PRIMITIVETYPE_BYTE:
+                                       /* This type is OK. */
+                                       break;
+                               default:
                                        goto illegal_arg;
+                               }
                                break;
 
                        case PRIMITIVETYPE_CHAR:
-                               if (c == class_java_lang_Character)
-                                       LLNI_field_get_val((java_lang_Character *) param, value, value.i);
-                               else
+                               switch (type) {
+                               case PRIMITIVETYPE_CHAR:
+                                       /* This type is OK. */
+                                       break;
+                               default:
                                        goto illegal_arg;
+                               }
                                break;
 
                        case PRIMITIVETYPE_SHORT:
-                               if (c == class_java_lang_Short)
-                                       LLNI_field_get_val((java_lang_Short *) param, value, value.i);
-                               else if (c == class_java_lang_Byte)
-                                       LLNI_field_get_val((java_lang_Byte *) param, value, value.i);
-                               else
+                               switch (type) {
+                               case PRIMITIVETYPE_BYTE:
+                               case PRIMITIVETYPE_SHORT:
+                                       /* These types are OK. */
+                                       break;
+                               default:
                                        goto illegal_arg;
+                               }
                                break;
 
                        case PRIMITIVETYPE_INT:
-                               if (c == class_java_lang_Integer)
-                                       LLNI_field_get_val((java_lang_Integer *) param, value, value.i);
-                               else if (c == class_java_lang_Short)
-                                       LLNI_field_get_val((java_lang_Short *) param, value, value.i);
-                               else if (c == class_java_lang_Byte)
-                                       LLNI_field_get_val((java_lang_Byte *) param, value, value.i);
-                               else
+                               switch (type) {
+                               case PRIMITIVETYPE_BYTE:
+                               case PRIMITIVETYPE_SHORT:
+                               case PRIMITIVETYPE_INT:
+                                       /* These types are OK. */
+                                       break;
+                               default:
                                        goto illegal_arg;
+                               }
                                break;
 
                        default:
-                               goto illegal_arg;
+                               vm_abort("vm_array_from_objectarray: invalid type %d",
+                                                td->decltype);
                        }
 
+                       value = primitive_unbox(param);
                        vm_array_store_int(array, pd, value.i);
                        break;
 
@@ -2812,28 +2830,23 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_object_t *o,
                        if (param == NULL)
                                goto illegal_arg;
 
-                       /* convert the value according to its declared type */
+                       c    = param->vftbl->class;
+                       type = primitive_type_get_by_wrapperclass(c);
 
-                       c = param->vftbl->class;
+                       assert(td->decltype == PRIMITIVETYPE_LONG);
 
-                       switch (td->decltype) {
+                       switch (type) {
+                       case PRIMITIVETYPE_BYTE:
+                       case PRIMITIVETYPE_SHORT:
+                       case PRIMITIVETYPE_INT:
                        case PRIMITIVETYPE_LONG:
-                               if (c == class_java_lang_Long)
-                                       LLNI_field_get_val((java_lang_Long *) param, value, value.l);
-                               else if (c == class_java_lang_Integer)
-                                       value.l = (int64_t) LLNI_field_direct(((java_lang_Integer *) param), value);
-                               else if (c == class_java_lang_Short)
-                                       value.l = (int64_t) LLNI_field_direct(((java_lang_Short *) param), value);
-                               else if (c == class_java_lang_Byte)
-                                       value.l = (int64_t) LLNI_field_direct(((java_lang_Byte *) param), value);
-                               else
-                                       goto illegal_arg;
+                               /* These types are OK. */
                                break;
-
                        default:
                                goto illegal_arg;
                        }
 
+                       value = primitive_unbox(param);
                        vm_array_store_lng(array, pd, value.l);
                        break;
 
@@ -2841,22 +2854,20 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_object_t *o,
                        if (param == NULL)
                                goto illegal_arg;
 
-                       /* convert the value according to its declared type */
+                       c    = param->vftbl->class;
+                       type = primitive_type_get_by_wrapperclass(c);
 
-                       c = param->vftbl->class;
+                       assert(td->decltype == PRIMITIVETYPE_FLOAT);
 
-                       switch (td->decltype) {
+                       switch (type) {
                        case PRIMITIVETYPE_FLOAT:
-                               if (c == class_java_lang_Float)
-                                       LLNI_field_get_val((java_lang_Float *) param, value, value.f);
-                               else
-                                       goto illegal_arg;
+                               /* This type is OK. */
                                break;
-
                        default:
                                goto illegal_arg;
                        }
 
+                       value = primitive_unbox(param);
                        vm_array_store_flt(array, pd, value.l);
                        break;
 
@@ -2864,24 +2875,21 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_object_t *o,
                        if (param == NULL)
                                goto illegal_arg;
 
-                       /* convert the value according to its declared type */
+                       c    = param->vftbl->class;
+                       type = primitive_type_get_by_wrapperclass(c);
 
-                       c = param->vftbl->class;
+                       assert(td->decltype == PRIMITIVETYPE_DOUBLE);
 
-                       switch (td->decltype) {
+                       switch (type) {
+                       case PRIMITIVETYPE_FLOAT:
                        case PRIMITIVETYPE_DOUBLE:
-                               if (c == class_java_lang_Double)
-                                       LLNI_field_get_val((java_lang_Double *) param, value, value.d);
-                               else if (c == class_java_lang_Float)
-                                       LLNI_field_get_val((java_lang_Float *) param, value, value.f);
-                               else
-                                       goto illegal_arg;
+                               /* These types are OK. */
                                break;
-
                        default:
                                goto illegal_arg;
                        }
 
+                       value = primitive_unbox(param);
                        vm_array_store_dbl(array, pd, value.l);
                        break;
                
@@ -2904,7 +2912,7 @@ uint64_t *vm_array_from_objectarray(methodinfo *m, java_object_t *o,
                        break;
 
                default:
-                       goto illegal_arg;
+                       vm_abort("vm_array_from_objectarray: invalid type %d", td->type);
                }
        }
 
index d00a40953523f5fb670db565ebdaa1d64236e8ff..27b9739c82b55ff75ee9db1ebe284eaca6eb0733 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: class.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: class.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -46,6 +46,7 @@
 
 #include "toolbox/logging.h"
 
+#include "vm/array.h"
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
@@ -523,11 +524,16 @@ static bool class_load_attribute_enclosingmethod(classbuffer *cb)
 
 bool class_load_attributes(classbuffer *cb)
 {
-       classinfo *c;
-       u4         i, j;
-       u2         attributes_count;
-       u2         attribute_name_index;
-       utf       *attribute_name;
+       classinfo             *c;
+       uint16_t               attributes_count;
+       uint16_t               attribute_name_index;
+       utf                   *attribute_name;
+       innerclassinfo        *info;
+       classref_or_classinfo  inner;
+       classref_or_classinfo  outer;
+       utf                   *name;
+       uint16_t               flags;
+       int                    i, j;
 
        c = cb->class;
 
@@ -577,19 +583,45 @@ bool class_load_attributes(classbuffer *cb)
                        for (j = 0; j < c->innerclasscount; j++) {
                                /* The innerclass structure contains a class with an encoded
                                   name, its defining scope, its simple name and a bitmask of
-                                  the access flags. If an inner class is not a member, its
-                                  outer_class is NULL, if a class is anonymous, its name is
-                                  NULL. */
+                                  the access flags. */
                                                                
-                               innerclassinfo *info = c->innerclass + j;
-
-                               info->inner_class.ref =
-                                       innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
-                               info->outer_class.ref =
-                                       innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
-                               info->name =
-                                       innerclass_getconstant(c, suck_u2(cb), CONSTANT_Utf8);
-                               info->flags = suck_u2(cb);
+                               info = c->innerclass + j;
+
+                               inner.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
+                               outer.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class);
+                               name      = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Utf8);
+                               flags     = suck_u2(cb);
+
+                               /* If the current inner-class is the currently loaded
+                                  class check for some special flags. */
+
+                               if (inner.ref->name == c->name) {
+                                       /* If an inner-class is not a member, its
+                                          outer-class is NULL. */
+
+                                       if (outer.ref != NULL) {
+                                               c->flags |= ACC_CLASS_MEMBER;
+
+                                               /* A member class doesn't have an
+                                                  EnclosingMethod attribute, so set the
+                                                  enclosing-class to be the same as the
+                                                  declaring-class. */
+
+                                               c->declaringclass = outer;
+                                               c->enclosingclass = outer;
+                                       }
+
+                                       /* If an inner-class is anonymous, its name is
+                                          NULL. */
+
+                                       if (name == NULL)
+                                               c->flags |= ACC_CLASS_ANONYMOUS;
+                               }
+
+                               info->inner_class = inner;
+                               info->outer_class = outer;
+                               info->name        = name;
+                               info->flags       = flags;
                        }
                }
                else if (attribute_name == utf_SourceFile) {
@@ -1608,6 +1640,21 @@ bool class_is_primitive(classinfo *c)
 }
 
 
+/* class_is_anonymousclass *****************************************************
+
+   Checks if the given class is an anonymous class.
+
+*******************************************************************************/
+
+bool class_is_anonymousclass(classinfo *c)
+{
+       if (c->flags & ACC_CLASS_ANONYMOUS)
+               return true;
+
+       return false;
+}
+
+
 /* class_is_array **************************************************************
 
    Checks if the given class is an array class.
@@ -1639,6 +1686,36 @@ bool class_is_interface(classinfo *c)
 }
 
 
+/* class_is_localclass *********************************************************
+
+   Checks if the given class is a local class.
+
+*******************************************************************************/
+
+bool class_is_localclass(classinfo *c)
+{
+       if ((c->enclosingmethod != NULL) && !class_is_anonymousclass(c))
+               return true;
+
+       return false;
+}
+
+
+/* class_is_memberclass ********************************************************
+
+   Checks if the given class is a member class.
+
+*******************************************************************************/
+
+bool class_is_memberclass(classinfo *c)
+{
+       if (c->flags & ACC_CLASS_MEMBER)
+               return true;
+
+       return false;
+}
+
+
 /* class_get_superclass ********************************************************
 
    Return the super class of the given class.  If the super-field is a
@@ -1669,6 +1746,39 @@ classinfo *class_get_superclass(classinfo *c)
 }
 
 
+/* class_get_componenttype *****************************************************
+
+   Return the component class of the given class.  If the given class
+   is not an array, return NULL.
+
+*******************************************************************************/
+
+classinfo *class_get_componenttype(classinfo *c)
+{
+       classinfo       *component;
+       arraydescriptor *ad;
+       
+       /* XXX maybe we could find a way to do this without linking. */
+       /* This way should be safe and easy, however.                */
+
+       if (!(c->state & CLASS_LINKED))
+               if (!link_class(c))
+                       return NULL;
+
+       ad = c->vftbl->arraydesc;
+       
+       if (ad == NULL)
+               return NULL;
+       
+       if (ad->arraytype == ARRAYTYPE_OBJECT)
+               component = ad->componentvftbl->class;
+       else
+               component = primitive_class_get_by_type(ad->arraytype);
+               
+       return component;
+}
+
+
 /* class_get_declaredclasses ***************************************************
 
    Return an array of declared classes of the given class.
@@ -1692,9 +1802,15 @@ java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOn
                /* Determine number of declared classes. */
 
                for (i = 0; i < c->innerclasscount; i++) {
+                       /* Get outer-class.  If the inner-class is not a member
+                          class, the outer-class is NULL. */
+
                        outer = c->innerclass[i].outer_class;
 
-                       /* Check if outer_class is a classref or a real class and
+                       if (outer.any == NULL)
+                               continue;
+
+                       /* Check if outer-class is a classref or a real class and
                get the class name from the structure. */
 
                        outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name;
@@ -1718,6 +1834,12 @@ java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOn
                inner = c->innerclass[i].inner_class;
                outer = c->innerclass[i].outer_class;
 
+               /* Get outer-class.  If the inner-class is not a member class,
+                  the outer-class is NULL. */
+
+               if (outer.any == NULL)
+                       continue;
+
                /* Check if outer_class is a classref or a real class and get
                   the class name from the structure. */
 
@@ -1755,52 +1877,71 @@ java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOn
 
 classinfo *class_get_declaringclass(classinfo *c)
 {
-       classref_or_classinfo  innercr;
-       utf                   *innername;
-       classref_or_classinfo  outercr;
-       classinfo             *outer;
-       int16_t                i;
+       classref_or_classinfo  cr;
+       classinfo             *dc;
+
+       /* Get declaring class. */
 
-       /* return NULL for arrayclasses and primitive classes */
+       cr = c->declaringclass;
 
-       if (class_is_primitive(c) || (c->name->text[0] == '['))
+       if (cr.any == NULL)
                return NULL;
 
-       /* no innerclasses exist */
+       /* Resolve the class if necessary. */
 
-       if (c->innerclasscount == 0)
-               return NULL;
+       if (IS_CLASSREF(cr)) {
+/*             dc = resolve_classref_eager(cr.ref); */
+               dc = resolve_classref_or_classinfo_eager(cr, true);
 
-       for (i = 0; i < c->innerclasscount; i++) {
-               /* Check if inner_class is a classref or a real class and get
-                  the class name from the structure. */
+               if (dc == NULL)
+                       return NULL;
 
-               innercr = c->innerclass[i].inner_class;
+               /* Store the resolved class in the class structure. */
 
-               innername = IS_CLASSREF(innercr) ?
-                       innercr.ref->name : innercr.cls->name;
+               cr.cls = dc;
+       }
 
-               /* Is the current innerclass this class? */
+       dc = cr.cls;
 
-               if (innername == c->name) {
-                       /* Maybe the outer class is not loaded yet. */
+       return dc;
+}
 
-                       outercr = c->innerclass[i].outer_class;
 
-                       outer = resolve_classref_or_classinfo_eager(outercr, false);
+/* class_get_enclosingclass ****************************************************
 
-                       if (outer == NULL)
-                               return NULL;
+   Return the enclosing class for the given class.
 
-                       if (!(outer->state & CLASS_LINKED))
-                               if (!link_class(outer))
-                                       return NULL;
+*******************************************************************************/
 
-                       return outer;
-               }
+classinfo *class_get_enclosingclass(classinfo *c)
+{
+       classref_or_classinfo  cr;
+       classinfo             *ec;
+
+       /* Get enclosing class. */
+
+       cr = c->enclosingclass;
+
+       if (cr.any == NULL)
+               return NULL;
+
+       /* Resolve the class if necessary. */
+
+       if (IS_CLASSREF(cr)) {
+/*             ec = resolve_classref_eager(cr.ref); */
+               ec = resolve_classref_or_classinfo_eager(cr, true);
+
+               if (ec == NULL)
+                       return NULL;
+
+               /* Store the resolved class in the class structure. */
+
+               cr.cls = ec;
        }
 
-       return NULL;
+       ec = cr.cls;
+
+       return ec;
 }
 
 
index 9ca6b0f6c27cdf394e6d3aa6cc8dae67575b6022..2f6de435f4b97c6046830222158160d2162b1f21 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: class.h 8336 2007-08-17 11:09:20Z michi $
+   $Id: class.h 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -138,6 +138,8 @@ struct classinfo {                /* class structure                          */
        u2          innerclasscount;  /* number of inner classes                  */
        innerclassinfo *innerclass;
 
+       classref_or_classinfo  declaringclass;
+
 #if defined(ENABLE_JAVASE)
        classref_or_classinfo  enclosingclass;  /* enclosing class                */
        constant_nameandtype  *enclosingmethod; /* enclosing method               */
@@ -357,19 +359,25 @@ methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
 methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
 methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception);
 
-bool              class_issubclass(classinfo *sub, classinfo *super);
-bool              class_isanysubclass(classinfo *sub, classinfo *super);
-bool              class_is_primitive(classinfo *c);
-bool              class_is_array(classinfo *c);
-bool              class_is_interface(classinfo *c);
+bool class_issubclass(classinfo *sub, classinfo *super);
+bool class_isanysubclass(classinfo *sub, classinfo *super);
+
+bool                       class_is_primitive(classinfo *c);
+bool                       class_is_anonymousclass(classinfo *c);
+bool                       class_is_array(classinfo *c);
+bool                       class_is_interface(classinfo *c);
+bool                       class_is_localclass(classinfo *c);
+bool                       class_is_memberclass(classinfo *c);
 
 classinfo                 *class_get_superclass(classinfo *c);
+classinfo                 *class_get_componenttype(classinfo *c);
 java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly);
 classinfo                 *class_get_declaringclass(classinfo *c);
+classinfo                 *class_get_enclosingclass(classinfo *c);
 java_handle_objectarray_t *class_get_interfaces(classinfo *c);
 
 #if defined(ENABLE_JAVASE)
-utf              *class_get_signature(classinfo *c);
+utf                       *class_get_signature(classinfo *c);
 #endif
 
 /* some debugging functions */
index 0b41cf43d6ed903815f76308a81b50376b1d4990..570c6958507f58e3d3ddbe9522a6c9dd71602dd9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: field.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: field.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -386,19 +386,23 @@ void field_free(fieldinfo *f)
 }
 
 
-#if defined(ENABLE_ANNOTATIONS)
 /* field_get_annotations ******************************************************
 
    Gets a fields' annotations (or NULL if none).
 
 *******************************************************************************/
 
-java_bytearray *field_get_annotations(fieldinfo *f)
+java_handle_bytearray_t *field_get_annotations(fieldinfo *f)
 {
-       classinfo              *c           = f->class;
-       int                     slot        = f - c->fields;
-       annotation_bytearray_t *ba          = NULL;
-       java_bytearray         *annotations = NULL;
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;
+       int                      slot;
+       annotation_bytearray_t  *ba;
+       java_handle_bytearray_t *annotations;
+
+       c           = f->class;
+       slot        = f - c->fields;
+       annotations = NULL;
        
        if (c->field_annotations != NULL && c->field_annotations->size > slot) {
                ba = c->field_annotations->data[slot];
@@ -413,8 +417,10 @@ java_bytearray *field_get_annotations(fieldinfo *f)
        }
        
        return annotations;
-}
+#else
+       return NULL;
 #endif
+}
 
 
 /* field_printflags ************************************************************
index 6470d2580b663590b6c5aa93536235bff1c5bd8f..3a97ab976c207c5194f1ba56ac95e76160ee4748 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: field.h 8321 2007-08-16 11:37:25Z michi $
+   $Id: field.h 8343 2007-08-17 21:39:32Z michi $
 */
 
 
@@ -76,9 +76,7 @@ bool       field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool);
 classinfo *field_get_type(fieldinfo *f);
 void       field_free(fieldinfo *f);
 
-#if defined(ENABLE_ANNOTATIONS)
-java_bytearray *field_get_annotations(fieldinfo *f);
-#endif
+java_handle_bytearray_t *field_get_annotations(fieldinfo *f);
 
 #if !defined(NDEBUG)
 void field_printflags(fieldinfo *f);
index 6c8d2d81cab40b3c2ed3b6e61ffacc018548cd05..7e7cd867a06b5d809aafe8f2dcf4303da47cddf7 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: linker.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: linker.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -42,6 +42,7 @@
 #include "toolbox/logging.h"
 
 #include "vm/access.h"
+#include "vm/array.h"
 #include "vm/exceptions.h"
 #include "vm/primitive.h"
 #include "vm/stringlocal.h"
index f605863c3d9fecf2ab3af2116c9fbe4c1bd5acdb..2f5c17d7b87a632f862ce3f8f72d56f816274be2 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: linker.h 8299 2007-08-13 08:41:18Z michi $
+   $Id: linker.h 8343 2007-08-17 21:39:32Z michi $
 */
 
 
@@ -82,22 +82,22 @@ typedef struct primitivetypeinfo primitivetypeinfo;
    interfacetablelength = 4
 
                   | ...       |            +----------+
-                     +-----------+            | method 2 |---> method z
-                     | class     |            | method 1 |---> method y
-                     +-----------+            | method 0 |---> method x
-                     | ivftbl  0 |----------> +----------+
-       vftblptr ---> +-----------+
+                  +-----------+            | method 2 |---> method z
+                  | class     |            | method 1 |---> method y
+                  +-----------+            | method 0 |---> method x
+                  | ivftbl  0 |----------> +----------+
+    vftblptr ---> +-----------+
                   | ivftbl -1 |--> NULL    +----------+
                   | ivftbl -2 |--> NULL    | method 1 |---> method x
                   | ivftbl -3 |-----+      | method 0 |---> method a
                   +-----------+     +----> +----------+
      
                               +---------------+
-                                 | length 3 = 2  |
-                                 | length 2 = 0  |
-                                 | length 1 = 0  |
-                                 | length 0 = 3  |
-       interfacevftbllength ---> +---------------+
+                              | length 3 = 2  |
+                              | length 2 = 0  |
+                              | length 1 = 0  |
+                              | length 0 = 3  |
+    interfacevftbllength ---> +---------------+
 
 *******************************************************************************/
 
index 13d48042daed337f1bdbfc780749d53c42ce4688..4981f74f5c6691f8c694a93e3ef9ed40348f1d35 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: loader.c 8335 2007-08-17 11:04:35Z michi $
+   $Id: loader.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -1148,7 +1148,7 @@ classinfo *load_class_from_classloader(utf *name, classloader *cl)
 
                RT_TIMING_GET_TIME(time_java);
 
-               c = (classinfo *) o;
+               c = LLNI_classinfo_unwrap(o);
 
                if (c != NULL) {
                        /* Store this class in the loaded class cache. If another
index 40063ff9d8378fd724f1edad4a4dd20d183efe78..a9e90c3f9296469193c0533807f3eb1361b4a1cd 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: method.c 8321 2007-08-16 11:37:25Z michi $
+   $Id: method.c 8343 2007-08-17 21:39:32Z michi $
 
 */
 
@@ -776,19 +776,23 @@ s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
 }
 
 
-#if defined(ENABLE_ANNOTATIONS)
 /* method_get_annotations ******************************************************
 
    Gets a methods' annotations (or NULL if none).
 
 *******************************************************************************/
 
-java_bytearray *method_get_annotations(methodinfo *m)
+java_handle_bytearray_t *method_get_annotations(methodinfo *m)
 {
-       classinfo              *c           = m->class;
-       int                     slot        = m - c->methods;
-       annotation_bytearray_t *ba          = NULL;
-       java_bytearray         *annotations = NULL;
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;
+       int                      slot;
+       annotation_bytearray_t  *ba;
+       java_handle_bytearray_t *annotations;
+
+       c           = m->class;
+       slot        = m - c->methods;
+       annotations = NULL;
        
        if (c->method_annotations != NULL && c->method_annotations->size > slot) {
                ba = c->method_annotations->data[slot];
@@ -803,6 +807,9 @@ java_bytearray *method_get_annotations(methodinfo *m)
        }
        
        return annotations;
+#else
+       return NULL;
+#endif
 }
 
 
@@ -812,12 +819,17 @@ java_bytearray *method_get_annotations(methodinfo *m)
 
 *******************************************************************************/
 
-java_bytearray *method_get_parameterannotations(methodinfo *m)
+java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m)
 {
-       classinfo              *c                    = m->class;
-       int                     slot                 = m - c->methods;
-       annotation_bytearray_t *ba                   = NULL;
-       java_bytearray         *parameterAnnotations = NULL;
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;
+       int                      slot;
+       annotation_bytearray_t  *ba;
+       java_handle_bytearray_t *parameterAnnotations;
+
+       c                    = m->class;
+       slot                 = m - c->methods;
+       parameterAnnotations = NULL;
 
        if (c->method_parameterannotations != NULL &&
                c->method_parameterannotations->size > slot) {
@@ -833,6 +845,9 @@ java_bytearray *method_get_parameterannotations(methodinfo *m)
        }
        
        return parameterAnnotations;
+#else
+       return NULL;
+#endif
 }
 
 
@@ -842,12 +857,17 @@ java_bytearray *method_get_parameterannotations(methodinfo *m)
 
 *******************************************************************************/
 
-java_bytearray *method_get_annotationdefault(methodinfo *m)
+java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m)
 {
-       classinfo              *c                 = m->class;
-       int                     slot              = m - c->methods;
-       annotation_bytearray_t *ba                = NULL;
-       java_bytearray         *annotationDefault = NULL;
+#if defined(ENABLE_ANNOTATIONS)
+       classinfo               *c;
+       int                      slot;
+       annotation_bytearray_t  *ba;
+       java_handle_bytearray_t *annotationDefault;
+
+       c                 = m->class;
+       slot              = m - c->methods;
+       annotationDefault = NULL;
 
        if (c->method_annotationdefaults != NULL &&
                c->method_annotationdefaults->size > slot) {
@@ -863,8 +883,10 @@ java_bytearray *method_get_annotationdefault(methodinfo *m)
        }
        
        return annotationDefault;
-}
+#else
+       return NULL;
 #endif
+}
 
 
 /* method_add_to_worklist ******************************************************
index 74daec71de74c02bf2aaae0f70091d42b33f9e28..724cc14ba5ea9d0d640a3a2d9e2e03fee1836ff8 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: method.h 8321 2007-08-16 11:37:25Z michi $
+   $Id: method.h 8343 2007-08-17 21:39:32Z michi $
 */
 
 
@@ -174,11 +174,9 @@ void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
 
 s4   method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found);
 
-#if defined(ENABLE_ANNOTATIONS)
-java_bytearray *method_get_annotations(methodinfo *m);
-java_bytearray *method_get_parameterannotations(methodinfo *m);
-java_bytearray *method_get_annotationdefault(methodinfo *m);
-#endif
+java_handle_bytearray_t *method_get_annotations(methodinfo *m);
+java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m);
+java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m);
 
 #if !defined(NDEBUG)
 void method_printflags(methodinfo *m);
index 6a32c19c729b5aecb32c238a3df6d7dff52d5ce3..e94e9cf723941c4b9e1f695f824f5d5f55317223 100644 (file)
@@ -26,7 +26,7 @@
 ##
 ## Authors: Christian Thalinger
 ##
-## $Id: Makefile.am 7441 2007-03-02 23:13:10Z michi $
+## $Id: Makefile.am 8343 2007-08-17 21:39:32Z michi $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -54,7 +54,8 @@ SOURCE_FILES = \
        $(srcdir)/clinitexception.java \
        $(srcdir)/LoadDisplacementOverflow.java \
        $(srcdir)/FieldDisplacementOverflow.java \
-       $(srcdir)/StackDisplacementOverflow.java
+       $(srcdir)/StackDisplacementOverflow.java \
+       $(srcdir)/MinimalClassReflection.java
 
 EXTRA_DIST = \
        $(SOURCE_FILES) \
@@ -67,7 +68,8 @@ EXTRA_DIST = \
        clinitexception.2output \
        LoadDisplacementOverflow.output \
        FieldDisplacementOverflow.output \
-       StackDisplacementOverflow.output
+       StackDisplacementOverflow.output \
+       MinimalClassReflection.output
 
 CLEANFILES = \
        *.class \
@@ -85,7 +87,8 @@ OUTPUT_JAVA_TESTS = \
        clinitexception \
        LoadDisplacementOverflow \
        FieldDisplacementOverflow \
-       StackDisplacementOverflow
+       StackDisplacementOverflow \
+       MinimalClassReflection
 
 check: build $(SIMPLE_JAVA_TESTS) $(OUTPUT_JAVA_TESTS)
 
diff --git a/tests/regression/MinimalClassReflection.java b/tests/regression/MinimalClassReflection.java
new file mode 100644 (file)
index 0000000..1a198e0
--- /dev/null
@@ -0,0 +1,137 @@
+/* tests/regression/MinimalClassReflection.java - checks most some of the
+   reflective methods onto java.lang.Class
+
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Contact: cacao@cacaojvm.org
+
+   Authors: Mathias Panzenböck
+
+   $Id$
+
+*/
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Constructor;
+
+public class MinimalClassReflection {
+       public static void printClassInfo(String header, Class<?> cls) {
+               Class<?>       clazz;
+               Constructor<?> constr;
+               Method         method;
+               
+               p("---------------------- %s ----------------------", header);
+               p("is local:              %s", cls.isLocalClass());
+               p("is anonymous:          %s", cls.isAnonymousClass());
+               p("is member:             %s", cls.isMemberClass());
+               p("name:                  %s", cls.getName());
+               p("simple name:           %s", cls.getSimpleName());
+               p("canonical name:        %s", cls.getCanonicalName());
+               
+               clazz = cls.getSuperclass();
+               p("super class:           %s",
+                               (clazz == null ? "null" : clazz.getName()));
+               
+               clazz = cls.getDeclaringClass();
+               p("declaring class:       %s",
+                               (clazz == null ? "null" : clazz.getName()));
+               
+               clazz = cls.getEnclosingClass();
+               p("enclosing class:       %s",
+                               (clazz == null ? "null" : clazz.getName()));
+               
+               constr = cls.getEnclosingConstructor();
+               p("enclosing constructor: %s",
+                               (constr == null ? "null" :
+                                       constr.getDeclaringClass().getName() +
+                                       "." + constr.getName()));
+               
+               method = cls.getEnclosingMethod();
+               p("enclosing method:      %s",
+                               (method == null ? "null" :
+                                       method.getDeclaringClass().getName() +
+                                       "." + method.getName()));
+               
+               p();
+       }
+       
+       public static void main(String[] args) {
+               class ALocalClass {
+                       class AMemberClass {
+                       }
+                       
+                       public ALocalClass() {
+                               class AnotherLocalClass {
+                               }
+
+                               printClassInfo(
+                                               "test a member class",
+                                               AMemberClass.class);
+                               
+                               printClassInfo(
+                                               "test a anonymous class derived from a member class",
+                                               new AMemberClass() {}.getClass());
+                               
+                               printClassInfo(
+                                               "test a local class (local to a constructor)",
+                                               AnotherLocalClass.class);
+                               
+                               printClassInfo(
+                                               "test a anonymous class derived from a local " +
+                                               "class (local to a constructor)",
+                                               new AnotherLocalClass() {}.getClass());
+                       }
+               }
+               
+               printClassInfo(
+                               "test a normal class",
+                               MinimalClassReflection.class);
+               
+               printClassInfo(
+                               "test a local class (local to a method)",
+                               ALocalClass.class);
+               
+               printClassInfo(
+                               "test a anonymous class",
+                               new Object() {}.getClass());
+               
+               printClassInfo(
+                               "test a anonymous class derived from a local class" +
+                               " (local to a method)",
+                               new ALocalClass() {}.getClass());
+               
+               new ALocalClass();
+       }
+       
+       public static void p(String fmt, Object... args) {
+               System.out.printf(fmt + "\n", args);
+       }
+       
+       public static <T> void p(T o) {
+               System.out.println(o);
+       }
+       
+       public static void p() {
+               System.out.println();
+       }
+}
diff --git a/tests/regression/MinimalClassReflection.output b/tests/regression/MinimalClassReflection.output
new file mode 100644 (file)
index 0000000..d51c393
--- /dev/null
@@ -0,0 +1,156 @@
+---------------------- test a normal class ----------------------
+is local:              false
+is anonymous:          false
+is member:             false
+name:                  MinimalClassReflection
+simple name:           MinimalClassReflection
+canonical name:        MinimalClassReflection
+super class:           java.lang.Object
+declaring class:       null
+enclosing class:       null
+enclosing constructor: null
+enclosing method:      null
+
+---------------------- test a local class (local to a method) ----------------------
+is local:              true
+is anonymous:          false
+is member:             false
+name:                  MinimalClassReflection$1ALocalClass
+simple name:           ALocalClass
+canonical name:        null
+super class:           java.lang.Object
+declaring class:       null
+enclosing class:       MinimalClassReflection
+enclosing constructor: null
+enclosing method:      MinimalClassReflection.main
+
+---------------------- test a anonymous class ----------------------
+is local:              false
+is anonymous:          true
+is member:             false
+name:                  MinimalClassReflection$1
+simple name:           
+canonical name:        null
+super class:           java.lang.Object
+declaring class:       null
+enclosing class:       MinimalClassReflection
+enclosing constructor: null
+enclosing method:      MinimalClassReflection.main
+
+---------------------- test a member class ----------------------
+is local:              false
+is anonymous:          false
+is member:             true
+name:                  MinimalClassReflection$1ALocalClass$AMemberClass
+simple name:           AMemberClass
+canonical name:        null
+super class:           java.lang.Object
+declaring class:       MinimalClassReflection$1ALocalClass
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: null
+enclosing method:      null
+
+---------------------- test a anonymous class derived from a member class ----------------------
+is local:              false
+is anonymous:          true
+is member:             false
+name:                  MinimalClassReflection$1ALocalClass$1
+simple name:           
+canonical name:        null
+super class:           MinimalClassReflection$1ALocalClass$AMemberClass
+declaring class:       null
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: MinimalClassReflection$1ALocalClass.MinimalClassReflection$1ALocalClass
+enclosing method:      null
+
+---------------------- test a local class (local to a constructor) ----------------------
+is local:              true
+is anonymous:          false
+is member:             false
+name:                  MinimalClassReflection$1ALocalClass$1AnotherLocalClass
+simple name:           AnotherLocalClass
+canonical name:        null
+super class:           java.lang.Object
+declaring class:       null
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: MinimalClassReflection$1ALocalClass.MinimalClassReflection$1ALocalClass
+enclosing method:      null
+
+---------------------- test a anonymous class derived from a local class (local to a constructor) ----------------------
+is local:              false
+is anonymous:          true
+is member:             false
+name:                  MinimalClassReflection$1ALocalClass$2
+simple name:           
+canonical name:        null
+super class:           MinimalClassReflection$1ALocalClass$1AnotherLocalClass
+declaring class:       null
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: MinimalClassReflection$1ALocalClass.MinimalClassReflection$1ALocalClass
+enclosing method:      null
+
+---------------------- test a anonymous class derived from a local class (local to a method) ----------------------
+is local:              false
+is anonymous:          true
+is member:             false
+name:                  MinimalClassReflection$2
+simple name:           
+canonical name:        null
+super class:           MinimalClassReflection$1ALocalClass
+declaring class:       null
+enclosing class:       MinimalClassReflection
+enclosing constructor: null
+enclosing method:      MinimalClassReflection.main
+
+---------------------- test a member class ----------------------
+is local:              false
+is anonymous:          false
+is member:             true
+name:                  MinimalClassReflection$1ALocalClass$AMemberClass
+simple name:           AMemberClass
+canonical name:        null
+super class:           java.lang.Object
+declaring class:       MinimalClassReflection$1ALocalClass
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: null
+enclosing method:      null
+
+---------------------- test a anonymous class derived from a member class ----------------------
+is local:              false
+is anonymous:          true
+is member:             false
+name:                  MinimalClassReflection$1ALocalClass$1
+simple name:           
+canonical name:        null
+super class:           MinimalClassReflection$1ALocalClass$AMemberClass
+declaring class:       null
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: MinimalClassReflection$1ALocalClass.MinimalClassReflection$1ALocalClass
+enclosing method:      null
+
+---------------------- test a local class (local to a constructor) ----------------------
+is local:              true
+is anonymous:          false
+is member:             false
+name:                  MinimalClassReflection$1ALocalClass$1AnotherLocalClass
+simple name:           AnotherLocalClass
+canonical name:        null
+super class:           java.lang.Object
+declaring class:       null
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: MinimalClassReflection$1ALocalClass.MinimalClassReflection$1ALocalClass
+enclosing method:      null
+
+---------------------- test a anonymous class derived from a local class (local to a constructor) ----------------------
+is local:              false
+is anonymous:          true
+is member:             false
+name:                  MinimalClassReflection$1ALocalClass$2
+simple name:           
+canonical name:        null
+super class:           MinimalClassReflection$1ALocalClass$1AnotherLocalClass
+declaring class:       null
+enclosing class:       MinimalClassReflection$1ALocalClass
+enclosing constructor: MinimalClassReflection$1ALocalClass.MinimalClassReflection$1ALocalClass
+enclosing method:      null
+