1 /* src/native/vm/java_lang_ClassLoader.c - java/lang/ClassLoader
3 Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: java_lang_VMClass.c 6131 2006-12-06 22:15:57Z twisti $
37 #include "mm/memory.h"
39 #include "vm/global.h" /* required by native headers */
41 #include "native/jni.h"
43 #include "native/include/java_lang_Object.h"
45 #if defined(ENABLE_JAVASE)
46 # include "native/include/java_lang_String.h"/* required by java_lang_Class.h */
47 # include "native/include/java_lang_Class.h"
48 # include "native/include/java_lang_ClassLoader.h"
49 # include "native/include/java_security_ProtectionDomain.h"
52 #include "vm/exceptions.h"
53 #include "vm/stringlocal.h"
55 #include "vmcore/class.h"
56 #include "vmcore/classcache.h"
57 #include "vmcore/options.h"
59 #if defined(ENABLE_STATISTICS)
60 # include "vmcore/statistics.h"
65 * Class: java/lang/ClassLoader
67 * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;
69 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)
71 java_objectheader *loader;
75 #if defined(ENABLE_JVMTI)
76 jint new_class_data_len = 0;
77 unsigned char* new_class_data = NULL;
80 loader = (java_objectheader *) cl;
82 /* check if data was passed */
85 exceptions_throw_nullpointerexception();
89 /* check the indexes passed */
91 if ((offset < 0) || (len < 0) || ((offset + len) > data->header.size)) {
92 exceptions_throw_arrayindexoutofboundsexception();
97 /* convert '.' to '/' in java string */
99 utfname = javastring_toutf((java_objectheader *) name, true);
105 #if defined(ENABLE_JVMTI)
106 /* fire Class File Load Hook JVMTI event */
109 jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data,
110 loader, (java_objectheader *) pd,
111 &new_class_data_len, &new_class_data);
114 /* define the class */
116 #if defined(ENABLE_JVMTI)
117 /* check if the JVMTI wants to modify the class */
119 if (new_class_data == NULL)
120 c = class_define(utfname, loader, new_class_data_len, new_class_data);
123 c = class_define(utfname, loader, len, (u1 *) &data->data[offset]);
128 /* set ProtectionDomain */
130 o = (java_lang_Class *) c;
139 * These are local overrides for various environment variables in Emacs.
140 * Please do not remove this and leave it at the end of the file, where
141 * Emacs will automagically detect them.
142 * ---------------------------------------------------------------------
145 * indent-tabs-mode: t
149 * vim:noexpandtab:sw=4:ts=4: