java_objectheader *loader;
utf *utfname;
classinfo *c;
- classinfo *r;
- classbuffer *cb;
- java_lang_Class *co;
+ java_lang_Class *o;
#if defined(ENABLE_JVMTI)
jint new_class_data_len = 0;
unsigned char* new_class_data = NULL;
/* convert '.' to '/' in java string */
utfname = javastring_toutf((java_objectheader *) name, true);
-
- /* check if this class has already been defined */
-
- c = classcache_lookup_defined_or_initiated(loader, utfname);
-
- if (c != NULL) {
- exceptions_throw_linkageerror("duplicate class definition: ", c);
- return NULL;
- }
}
else {
utfname = NULL;
&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
+ /* define the class */
- /* 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 = loader;
-
- /* 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();
+ if (new_class_data == NULL)
+ c = class_define(utfname, loader, new_class_data_len, new_class_data);
+ else
#endif
+ c = class_define(utfname, loader, len, (u1 *) &data->data[offset]);
- 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);
-
+ if (c == NULL)
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. */
+ o = (java_lang_Class *) c;
- c = classcache_store(loader, c, true);
+ o->pd = pd;
- return (java_lang_Class *) c;
+ return o;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.c 8042 2007-06-07 17:43:29Z twisti $
+ $Id: class.c 8049 2007-06-07 23:30:45Z twisti $
*/
}
}
+/* class_define ****************************************************************
+
+ Calls the loader and defines a class in the VM.
+
+*******************************************************************************/
+
+classinfo *class_define(utf *name, java_objectheader *cl, s4 length, u1 *data)
+{
+ classinfo *c;
+ classinfo *r;
+ classbuffer *cb;
+
+ if (name != NULL) {
+ /* check if this class has already been defined */
+
+ c = classcache_lookup_defined_or_initiated(cl, name);
+
+ if (c != NULL) {
+ exceptions_throw_linkageerror("duplicate class definition: ", c);
+ return NULL;
+ }
+ }
+
+ /* create a new classinfo struct */
+
+ c = class_create_classinfo(name);
+
+#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;
+ cb->size = length;
+ cb->data = data;
+ cb->pos = cb->data;
+
+ /* preset the defining classloader */
+
+ c->classloader = 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;
+ }
+
+ /* 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(cl, c, true);
+
+ return c;
+}
+
/* class_load_attribute_sourcefile *********************************************
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: class.h 8042 2007-06-07 17:43:29Z twisti $
+ $Id: class.h 8049 2007-06-07 23:30:45Z twisti $
*/
/* postset's the header.vftbl */
void class_postset_header_vftbl(void);
+classinfo *class_define(utf *name, java_objectheader *cl, s4 length, u1 *data);
+
/* set the package name after the name has been set */
void class_set_packagename(classinfo *c);