diff options
author | Andrew Haley <aph@redhat.com> | 2006-06-16 08:56:29 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2006-06-16 08:56:29 +0000 |
commit | e046c56eee0e7308f8704c8c13aa6ca5230201f1 (patch) | |
tree | ff9074d933a019a660cdd900d098b48311aea034 /libjava/java/lang/natClassLoader.cc | |
parent | 47392a21de0f9488d598ecfb6aac3e6d45a7457a (diff) | |
download | gcc-e046c56eee0e7308f8704c8c13aa6ca5230201f1.zip gcc-e046c56eee0e7308f8704c8c13aa6ca5230201f1.tar.gz gcc-e046c56eee0e7308f8704c8c13aa6ca5230201f1.tar.bz2 |
class.c (make_class_data): When using flag_indirect_classes, don't initialize the vtable of Class instances.
2006-06-16 Andrew Haley <aph@redhat.com>
* class.c (make_class_data): When using flag_indirect_classes,
don't initialize the vtable of Class instances.
2006-06-16 Andrew Haley <aph@redhat.com>
* java/lang/natClassLoader.cc (_Jv_NewClassFromInitializer): Don't
copy the whole Class instance from the initializer: instead, copy
everything but the first word (the vtable pointer).
Change prototype to (const char* class_initializer).
(_Jv_RegisterNewClasses): Change prototype to (const char**).
* java/lang/Class.h (_Jv_RegisterNewClasses): Change prototype to
(const char**).
From-SVN: r114714
Diffstat (limited to 'libjava/java/lang/natClassLoader.cc')
-rw-r--r-- | libjava/java/lang/natClassLoader.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index 6b3c3ef..b05c0b1 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -218,11 +218,20 @@ _Jv_RegisterClasses_Counted (const jclass * classes, size_t count) // Create a class on the heap from an initializer struct. jclass -_Jv_NewClassFromInitializer (const jclass class_initializer) +_Jv_NewClassFromInitializer (const char *class_initializer) { - jclass new_class = (jclass)_Jv_AllocObj (sizeof *new_class, - &java::lang::Class::class$); - memcpy ((void*)new_class, (void*)class_initializer, sizeof *new_class); + /* We create an instance of java::lang::Class and copy all of its + fields except the first word (the vtable pointer) from + CLASS_INITIALIZER. This first word is pre-initialized by + _Jv_AllocObj, and we don't want to overwrite it. */ + + jclass new_class + = (jclass)_Jv_AllocObj (sizeof (java::lang::Class), + &java::lang::Class::class$); + const char *src = class_initializer + sizeof (void*); + char *dst = (char*)new_class + sizeof (void*); + size_t len = sizeof (*new_class) - sizeof (void*); + memcpy (dst, src, len); new_class->engine = &_Jv_soleIndirectCompiledEngine; @@ -240,13 +249,13 @@ _Jv_NewClassFromInitializer (const jclass class_initializer) // heap) and we write the address of the new class into the address // pointed to by the second word. void -_Jv_RegisterNewClasses (void **classes) +_Jv_RegisterNewClasses (char **classes) { _Jv_InitGC (); - jclass initializer; + const char *initializer; - while ((initializer = (jclass)*classes++)) + while ((initializer = *classes++)) { jclass *class_ptr = (jclass *)*classes++; *class_ptr = _Jv_NewClassFromInitializer (initializer); |