* src/native/vm/java_lang_ClassLoader.c: New file.
authortwisti <none@none>
Mon, 26 Feb 2007 22:11:38 +0000 (22:11 +0000)
committertwisti <none@none>
Mon, 26 Feb 2007 22:11:38 +0000 (22:11 +0000)
* src/native/vm/java_lang_ClassLoader.h: Likewise.

* src/native/vm/gnu/java_lang_VMClassLoader.c
(native/vm/java_lang_ClassLoader.h): Added.
(defineClass): Removed code and call
_Jv_java_lang_ClassLoader_defineClass.

* src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added
java_lang_ClassLoader.[ch].

* src/native/jni.c [ENABLE_JAVASE]
(native/vm/java_lang_ClassLoader.h): Added.
(_Jv_JNI_DefineClass): Removed env and NULL arguments.

12 files changed:
src/native/jni.c
src/native/vm/Makefile.am
src/native/vm/gnu/java_lang_VMClassLoader.c
src/native/vm/java_lang_ClassLoader.c [new file with mode: 0644]
src/native/vm/java_lang_ClassLoader.h [new file with mode: 0644]
src/vm/jit/codegen-common.c
src/vm/jit/s390/asmpart.S
src/vm/jit/s390/codegen.c
src/vm/jit/s390/codegen.h
src/vm/jit/s390/md-abi.c
src/vm/jit/s390/md-asm.h
src/vmcore/zip.c

index b81c1b2c5b456beab58364282bef6ac5a097c9af..ef5327e2ec0d08f2897a8b22fe70fb29e8d83281 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jni.c 7384 2007-02-21 22:17:16Z twisti $
+   $Id: jni.c 7408 2007-02-26 22:11:38Z twisti $
 
 */
 
 
 #include "native/vm/java_lang_Class.h"
 
+#if defined(ENABLE_JAVASE)
+# include "native/vm/java_lang_ClassLoader.h"
+#endif
+
 #if defined(ENABLE_THREADS)
 # include "threads/native/lock.h"
 # include "threads/native/threads.h"
@@ -1093,8 +1097,8 @@ jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader,
        s  = javastring_new_from_utf_string(name);
        ba = (java_bytearray *) buf;
 
-       c = (jclass) _Jv_java_lang_ClassLoader_defineClass(env, NULL, cl, s, ba,
-                                                                                                          0, bufLen, NULL);
+       c = (jclass) _Jv_java_lang_ClassLoader_defineClass(cl, s, ba, 0, bufLen,
+                                                                                                          NULL);
 
        return (jclass) _Jv_JNI_NewLocalRef(env, (jobject) c);
 #else
index a00b0e564b9c78de7e69c7c1984d41123ff3a8de..75fc37462ceebb7affbf9f3dc1c483076c53736b 100644 (file)
@@ -56,6 +56,8 @@ noinst_LTLIBRARIES = \
 libnativevm_la_SOURCES = \
        java_lang_Class.c \
        java_lang_Class.h \
+       java_lang_ClassLoader.c \
+       java_lang_ClassLoader.h \
        java_lang_Object.c \
        java_lang_Object.h \
        java_lang_Runtime.c \
index 23f01d6d1f22d1f4590c8a7ae966c9bf607a7702..5897448bfaf98142ee69c6a4319a5b247b1930fa 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMClassLoader.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: java_lang_VMClassLoader.c 7408 2007-02-26 22:11:38Z twisti $
 
 */
 
@@ -43,6 +43,8 @@
 #include "native/include/java_lang_ClassLoader.h"
 #include "native/include/java_util_Vector.h"
 
+#include "native/vm/java_lang_ClassLoader.h"
+
 #include "toolbox/logging.h"
 
 #include "vm/builtin.h"
  */
 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name, java_bytearray *data, s4 offset, s4 len, java_security_ProtectionDomain *pd)
 {
-       classinfo       *c;
-       classinfo       *r;
-       classbuffer     *cb;
-       utf             *utfname;
-       java_lang_Class *co;
-#if defined(ENABLE_JVMTI)
-       jint new_class_data_len = 0;
-       unsigned char* new_class_data = NULL;
-#endif
-
-       /* check if data was passed */
-
-       if (data == NULL) {
-               exceptions_throw_nullpointerexception();
-               return NULL;
-       }
-
-       /* check the indexes passed */
-
-       if ((offset < 0) || (len < 0) || ((offset + len) > data->header.size)) {
-               exceptions_throw_arrayindexoutofboundsexception();
-               return NULL;
-       }
-
-       if (name != NULL) {
-               /* convert '.' to '/' in java string */
-
-               utfname = javastring_toutf(name, true);
-               
-               /* check if this class has already been defined */
-
-               c = classcache_lookup_defined_or_initiated((java_objectheader *) cl, utfname);
-               if (c != NULL) {
-                       exceptions_throw_linkageerror("duplicate class definition: ", c);
-                       return NULL;
-               }
-       } 
-       else {
-               utfname = NULL;
-       }
-
-
-#if defined(ENABLE_JVMTI)
-       /* fire Class File Load Hook JVMTI event */
-       if (jvmti) jvmti_ClassFileLoadHook(utfname, len, (unsigned char*)data->data, 
-                                                       (java_objectheader *)cl, (java_objectheader *)pd, 
-                                                       &new_class_data_len, &new_class_data);
-#endif
-
-
-       /* create a new classinfo struct */
-
-       c = class_create_classinfo(utfname);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_start();
-#endif
-
-       /* build a classbuffer with the given data */
-
-       cb = NEW(classbuffer);
-       cb->class = c;
-#if defined(ENABLE_JVMTI)
-       /* check if the JVMTI wants to modify the class */
-       if (new_class_data == NULL) {
-#endif
-       cb->size  = len;
-       cb->data  = (u1 *) &data->data[offset];
-#if defined(ENABLE_JVMTI)
-       } else {
-               cb->size  = new_class_data_len;
-               cb->data  = (u1 *) new_class_data;
-       }
-#endif
-       cb->pos   = cb->data;
-
-       /* preset the defining classloader */
-
-       c->classloader = (java_objectheader *) cl;
-
-       /* load the class from this buffer */
-
-       r = load_class_from_classbuffer(cb);
-
-       /* free memory */
-
-       FREE(cb, classbuffer);
-
-#if defined(ENABLE_STATISTICS)
-       /* measure time */
-
-       if (opt_getloadingtime)
-               loadingtime_stop();
-#endif
-
-       if (r == NULL) {
-               /* If return value is NULL, we had a problem and the class is
-                  not loaded.  Now free the allocated memory, otherwise we
-                  could run into a DOS. */
-
-               class_free(c);
-
-               return NULL;
-       }
-
-       /* set ProtectionDomain */
-
-       co = (java_lang_Class *) c;
-
-       co->pd = pd;
-
-       /* Store the newly defined class in the class cache. This call also       */
-       /* checks whether a class of the same name has already been defined by    */
-       /* the same defining loader, and if so, replaces the newly created class  */
-       /* by the one defined earlier.                                            */
-       /* Important: The classinfo given to classcache_store must be             */
-       /*            fully prepared because another thread may return this       */
-       /*            pointer after the lookup at to top of this function         */
-       /*            directly after the class cache lock has been released.      */
-
-       c = classcache_store((java_objectheader *) cl, c, true);
-
-       return (java_lang_Class *) c;
+       return _Jv_java_lang_ClassLoader_defineClass(cl, name, data, offset, len, pd);
 }
 
 
diff --git a/src/native/vm/java_lang_ClassLoader.c b/src/native/vm/java_lang_ClassLoader.c
new file mode 100644 (file)
index 0000000..1202747
--- /dev/null
@@ -0,0 +1,205 @@
+/* src/native/vm/java_lang_ClassLoader.c - java/lang/ClassLoader
+
+   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: java_lang_VMClass.c 6131 2006-12-06 22:15:57Z twisti $
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include "vm/types.h"
+
+#include "mm/memory.h"
+
+#include "vm/global.h"                          /* required by native headers */
+
+#include "native/include/java_lang_Object.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_String.h"/* required by java_lang_Class.h */
+# include "native/include/java_lang_Class.h"
+# include "native/include/java_lang_ClassLoader.h"
+# include "native/include/java_security_ProtectionDomain.h"
+#endif
+
+#include "vm/exceptions.h"
+
+#include "vmcore/class.h"
+#include "vmcore/classcache.h"
+#include "vmcore/options.h"
+
+
+/*
+ * Class:     java/lang/ClassLoader
+ * Method:    defineClass
+ * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;
+ */
+java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl, java_lang_String *name, java_bytearray *data, s4 offset, s4 len, java_security_ProtectionDomain *pd)
+{
+       classinfo       *c;
+       classinfo       *r;
+       classbuffer     *cb;
+       utf             *utfname;
+       java_lang_Class *co;
+#if defined(ENABLE_JVMTI)
+       jint new_class_data_len = 0;
+       unsigned char* new_class_data = NULL;
+#endif
+
+       /* check if data was passed */
+
+       if (data == NULL) {
+               exceptions_throw_nullpointerexception();
+               return NULL;
+       }
+
+       /* check the indexes passed */
+
+       if ((offset < 0) || (len < 0) || ((offset + len) > data->header.size)) {
+               exceptions_throw_arrayindexoutofboundsexception();
+               return NULL;
+       }
+
+       if (name != NULL) {
+               /* convert '.' to '/' in java string */
+
+               utfname = javastring_toutf(name, true);
+               
+               /* check if this class has already been defined */
+
+               c = classcache_lookup_defined_or_initiated((java_objectheader *) cl, utfname);
+               if (c != NULL) {
+                       exceptions_throw_linkageerror("duplicate class definition: ", c);
+                       return NULL;
+               }
+       } 
+       else {
+               utfname = NULL;
+       }
+
+
+#if defined(ENABLE_JVMTI)
+       /* fire Class File Load Hook JVMTI event */
+       if (jvmti) jvmti_ClassFileLoadHook(utfname, len, (unsigned char*)data->data, 
+                                                       (java_objectheader *)cl, (java_objectheader *)pd, 
+                                                       &new_class_data_len, &new_class_data);
+#endif
+
+
+       /* create a new classinfo struct */
+
+       c = class_create_classinfo(utfname);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_start();
+#endif
+
+       /* build a classbuffer with the given data */
+
+       cb = NEW(classbuffer);
+       cb->class = c;
+#if defined(ENABLE_JVMTI)
+       /* check if the JVMTI wants to modify the class */
+       if (new_class_data == NULL) {
+#endif
+       cb->size  = len;
+       cb->data  = (u1 *) &data->data[offset];
+#if defined(ENABLE_JVMTI)
+       } else {
+               cb->size  = new_class_data_len;
+               cb->data  = (u1 *) new_class_data;
+       }
+#endif
+       cb->pos   = cb->data;
+
+       /* preset the defining classloader */
+
+       c->classloader = (java_objectheader *) cl;
+
+       /* load the class from this buffer */
+
+       r = load_class_from_classbuffer(cb);
+
+       /* free memory */
+
+       FREE(cb, classbuffer);
+
+#if defined(ENABLE_STATISTICS)
+       /* measure time */
+
+       if (opt_getloadingtime)
+               loadingtime_stop();
+#endif
+
+       if (r == NULL) {
+               /* If return value is NULL, we had a problem and the class is
+                  not loaded.  Now free the allocated memory, otherwise we
+                  could run into a DOS. */
+
+               class_free(c);
+
+               return NULL;
+       }
+
+       /* set ProtectionDomain */
+
+       co = (java_lang_Class *) c;
+
+       co->pd = pd;
+
+       /* Store the newly defined class in the class cache. This call also       */
+       /* checks whether a class of the same name has already been defined by    */
+       /* the same defining loader, and if so, replaces the newly created class  */
+       /* by the one defined earlier.                                            */
+       /* Important: The classinfo given to classcache_store must be             */
+       /*            fully prepared because another thread may return this       */
+       /*            pointer after the lookup at to top of this function         */
+       /*            directly after the class cache lock has been released.      */
+
+       c = classcache_store((java_objectheader *) cl, c, true);
+
+       return (java_lang_Class *) c;
+}
+
+
+/*
+ * 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/native/vm/java_lang_ClassLoader.h b/src/native/vm/java_lang_ClassLoader.h
new file mode 100644 (file)
index 0000000..0127dd3
--- /dev/null
@@ -0,0 +1,71 @@
+/* src/native/vm/java_lang_ClassLoader.h - java/lang/ClassLoader 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: java_lang_VMClass.c 6131 2006-12-06 22:15:57Z twisti $
+
+*/
+
+
+#ifndef _JV_JAVA_LANG_CLASSLOADER_H
+#define _JV_JAVA_LANG_CLASSLOADER_H
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "native/jni.h"
+
+#include "native/include/java_lang_Object.h"
+
+#if defined(ENABLE_JAVASE)
+# include "native/include/java_lang_String.h"/* required by java_lang_Class.h */
+# include "native/include/java_lang_Class.h"
+# include "native/include/java_lang_ClassLoader.h"
+# include "native/include/java_security_ProtectionDomain.h"
+#endif
+
+#include "vm/global.h"
+
+
+/* function prototypes ********************************************************/
+
+#if defined(ENABLE_JAVASE)
+java_lang_Class *_Jv_java_lang_ClassLoader_defineClass(java_lang_ClassLoader *cl, java_lang_String *name, java_bytearray *data, s4 offset, s4 len, java_security_ProtectionDomain *pd);
+#endif
+
+#endif /* _JV_JAVA_LANG_CLASSLOADER_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 f46d0d9cab33ec174a5b454e736fc4d823593f6f..7496334bfe433a2e565c69c267835dc137db518b 100644 (file)
@@ -39,7 +39,7 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen-common.c 7403 2007-02-25 21:31:58Z pm $
+   $Id: codegen-common.c 7407 2007-02-26 19:12:03Z michi $
 
 */
 
index 5fa8c603575f1bf609ed1d232bf8c5d9adb2dce1..5fb0292ea54b79dad319c521aea94440d9c5e93b 100644 (file)
@@ -30,7 +30,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: asmpart.S 7405 2007-02-25 22:34:27Z pm $
+   $Id: asmpart.S 7407 2007-02-26 19:12:03Z michi $
 
 */
 
index 9c58f14238e0ade71463e3a876e0892101ee17ce..87c88ade2df5957611677eba6da18855c77ef81b 100644 (file)
@@ -29,7 +29,7 @@
             Christian Ullrich
             Edwin Steiner
 
-   $Id: codegen.c 7405 2007-02-25 22:34:27Z pm $
+   $Id: codegen.c 7407 2007-02-26 19:12:03Z michi $
 
 */
 
index bdd636cd95f25b18c0a3e94723a27fc64556e10e..d0561983d0efcdc6056f978f7f4a6e7ba9ed919b 100644 (file)
@@ -27,7 +27,7 @@
    Authors: Andreas Krall
             Christian Thalinger
 
-   $Id: codegen.h 7403 2007-02-25 21:31:58Z pm $
+   $Id: codegen.h 7407 2007-02-26 19:12:03Z michi $
 
 */
 
index 5b5ad67d2ece3916ea0df0ce75e7419cd3874340..a644ef7e81a6d461f3ae4d96bfe845f4003c40ad 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md-abi.c 7403 2007-02-25 21:31:58Z pm $
+   $Id: md-abi.c 7407 2007-02-26 19:12:03Z michi $
 
 */
 
index c3e0a6db119e8e20d3c576fe112019adca5303d2..d0158d260938e581edfc62617566d0d9e98e7e95 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md-asm.h 7403 2007-02-25 21:31:58Z pm $
+   $Id: md-asm.h 7407 2007-02-26 19:12:03Z michi $
 
 */
 
index 96ca8d432933fb002b5781778575929f77519696..2ee7f2b60a606bdd9f81c9562deff5a7af61f670 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: zip.c 7402 2007-02-24 14:47:12Z twisti $
+   $Id: zip.c 7407 2007-02-26 19:12:03Z michi $
 
 */