* changed src/native/vm/sun/jvm.c: Throw IllegalArgumentException in all
[cacao.git] / src / native / vm / java_lang_Class.c
index bc6f69a2e636093db866d5a3f34cc1bae396acdf..5a905c4196bcdad4367b80d0d6eab1b9bda82173 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_Class.c 8341 2007-08-17 21:32:01Z michi $
-
 */
 
 
@@ -62,7 +60,6 @@
 #endif
 
 #include "native/vm/java_lang_Class.h"
-#include "native/vm/java_lang_String.h"
 
 #if defined(ENABLE_JAVASE)
 # include "native/vm/reflect.h"
 #include "vmcore/loader.h"
 
 #if defined(WITH_CLASSPATH_GNU) && defined(ENABLE_ANNOTATIONS)
+#include "native/include/sun_reflect_ConstantPool.h"
+
 #include "vm/vm.h"
+
 #include "vmcore/annotation.h"
-#include "native/include/sun_reflect_ConstantPool.h"
 #endif
 
 /*
  */
 java_lang_String *_Jv_java_lang_Class_getName(java_lang_Class *klass)
 {
-       classinfo        *c;
-       java_lang_String *s;
-       java_chararray_t *ca;
-       u4                i;
+       classinfo               *c;
+       java_lang_String        *s;
+       java_handle_chararray_t *ca;
+       u4                       i;
 
        c = LLNI_classinfo_unwrap(klass);
 
@@ -142,7 +141,7 @@ java_lang_Class *_Jv_java_lang_Class_forName(java_lang_String *name)
        s4           i;
 
 #if defined(ENABLE_JAVASE)
-       cl = (classloader *) loader;
+       cl = loader_hashtable_classloader_add((java_handle_t *) loader);
 #endif
 
        /* illegal argument */
@@ -360,24 +359,6 @@ s4 _Jv_java_lang_Class_getModifiers(java_lang_Class *klass, s4 ignoreInnerClasse
 }
 
 
-/*
- * Class:     java/lang/Class
- * Method:    getDeclaringClass
- * Signature: ()Ljava/lang/Class;
- */
-java_lang_Class *_Jv_java_lang_Class_getDeclaringClass(java_lang_Class *klass)
-{
-       classinfo *c;
-       classinfo *dc;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       dc = class_get_declaringclass(c);
-
-       return LLNI_classinfo_wrap(dc);
-}
-
-
 /*
  * Class:     java/lang/Class
  * Method:    getDeclaredClasses
@@ -563,40 +544,6 @@ java_handle_objectarray_t *_Jv_java_lang_Class_getDeclaredConstructors(java_lang
 }
 
 
-/*
- * Class:     java/lang/Class
- * Method:    getClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
- */
-java_lang_ClassLoader *_Jv_java_lang_Class_getClassLoader(java_lang_Class *klass)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(klass);
-
-       return (java_lang_ClassLoader *) c->classloader;
-}
-
-#endif /* defined(ENABLE_JAVASE) */
-
-
-/*
- * Class:     java/lang/Class
- * Method:    isArray
- * Signature: ()Z
- */
-JNIEXPORT int32_t JNICALL _Jv_java_lang_Class_isArray(JNIEnv *env, java_lang_Class *this)
-{
-       classinfo *c;
-
-       c = LLNI_classinfo_unwrap(this);
-
-       return class_is_array(c);
-}
-
-
-#if defined(ENABLE_JAVASE)
-
 /*
  * Class:     java/lang/Class
  * Method:    throwException
@@ -620,33 +567,23 @@ 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               = LLNI_classinfo_unwrap(klass);
+       classinfo                *c               = NULL;
        static methodinfo        *m_parseAnnotationsIntoArray   = NULL;
        utf                      *utf_parseAnnotationsIntoArray = NULL;
        utf                      *utf_desc        = NULL;
        java_handle_bytearray_t  *annotations     = NULL;
        sun_reflect_ConstantPool *constantPool    = NULL;
-       uint32_t                  size            = 0;
        java_lang_Object         *constantPoolOop = (java_lang_Object*)klass;
 
-       if (c == NULL) {
+       if (klass == NULL) {
                exceptions_throw_nullpointerexception();
                return NULL;
        }
        
-       /* Return null for arrays and primitives: */
-       if (class_is_primitive(c) || class_is_array(c)) {
-               return NULL;
-       }
-
-       if (c->annotations != NULL) {
-               size        = c->annotations->size;
-               annotations = builtin_newarray_byte(size);
+       c = LLNI_classinfo_unwrap(klass);
 
-               if(annotations != NULL) {
-                       MCOPY(annotations->data, c->annotations->data, uint8_t, size);
-               }
-       }
+       /* get annotations: */
+       annotations = class_get_annotations(c);
 
        constantPool = 
                (sun_reflect_ConstantPool*)native_new_and_init(