mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-17 18:59:42 +08:00
For PR java/5088:
* java/lang/natClassLoader.cc (_Jv_InitNewClassFields): New function. (_Jv_NewClass): Use it. (defineClass0): Use it. * prims.cc (_Jv_InitPrimClass): Adjust vtable here. (_Jv_InitPrimClass): Use _Jv_InitNewClassFields. (_Jv_NewArray): Don't abort; just throw exception. Include InternalError.h. * java/lang/Class.h (Class::Class): Declare, don't define. (Class): Declare _Jv_InitNewClassFields as a friend. (union _Jv_Self): Removed. From-SVN: r48081
This commit is contained in:
parent
495513eea6
commit
68940f3f3c
@ -1,5 +1,18 @@
|
||||
2001-12-16 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
For PR java/5088:
|
||||
* java/lang/natClassLoader.cc (_Jv_InitNewClassFields): New
|
||||
function.
|
||||
(_Jv_NewClass): Use it.
|
||||
(defineClass0): Use it.
|
||||
* prims.cc (_Jv_InitPrimClass): Adjust vtable here.
|
||||
(_Jv_InitPrimClass): Use _Jv_InitNewClassFields.
|
||||
(_Jv_NewArray): Don't abort; just throw exception.
|
||||
Include InternalError.h.
|
||||
* java/lang/Class.h (Class::Class): Declare, don't define.
|
||||
(Class): Declare _Jv_InitNewClassFields as a friend.
|
||||
(union _Jv_Self): Removed.
|
||||
|
||||
* Makefile.in: Rebuilt.
|
||||
* Makefile.am (ordinary_java_source_files): Removed old file;
|
||||
added new file.
|
||||
|
@ -109,13 +109,6 @@ struct _Jv_ifaces
|
||||
jshort count;
|
||||
};
|
||||
|
||||
// Used for vtable pointer manipulation.
|
||||
union _Jv_Self
|
||||
{
|
||||
char *vtable_ptr;
|
||||
jclass self;
|
||||
};
|
||||
|
||||
struct _Jv_MethodSymbol
|
||||
{
|
||||
_Jv_Utf8Const *class_name;
|
||||
@ -232,12 +225,7 @@ public:
|
||||
|
||||
// This constructor is used to create Class object for the primitive
|
||||
// types. See prims.cc.
|
||||
Class ()
|
||||
{
|
||||
// C++ ctors set the vtbl pointer to point at an offset inside the vtable
|
||||
// object. That doesn't work for Java, so this hack adjusts it back.
|
||||
((_Jv_Self *)this)->vtable_ptr -= 2 * sizeof (void *);
|
||||
}
|
||||
Class ();
|
||||
|
||||
static java::lang::Class class$;
|
||||
|
||||
@ -307,6 +295,7 @@ private:
|
||||
_Jv_VTable *array_vtable = 0);
|
||||
friend jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
|
||||
java::lang::ClassLoader *loader);
|
||||
friend void _Jv_InitNewClassFields (jclass klass);
|
||||
|
||||
// in prims.cc
|
||||
friend void _Jv_InitPrimClass (jclass, char *, char, int, _Jv_ArrayVTable *);
|
||||
|
@ -61,6 +61,7 @@ java::lang::ClassLoader::defineClass0 (jstring name,
|
||||
#ifdef INTERPRETER
|
||||
jclass klass;
|
||||
klass = (jclass) JvAllocObject (&ClassClass, sizeof (_Jv_InterpClass));
|
||||
_Jv_InitNewClassFields (klass);
|
||||
|
||||
// synchronize on the class, so that it is not
|
||||
// attempted initialized until we're done loading.
|
||||
@ -549,16 +550,13 @@ _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
|
||||
return klass;
|
||||
}
|
||||
|
||||
jclass
|
||||
_Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
|
||||
java::lang::ClassLoader *loader)
|
||||
void
|
||||
_Jv_InitNewClassFields (jclass ret)
|
||||
{
|
||||
jclass ret = (jclass) JvAllocObject (&ClassClass);
|
||||
|
||||
ret->next = NULL;
|
||||
ret->name = name;
|
||||
ret->name = NULL;
|
||||
ret->accflags = 0;
|
||||
ret->superclass = superclass;
|
||||
ret->superclass = NULL;
|
||||
ret->constants.size = 0;
|
||||
ret->constants.tags = NULL;
|
||||
ret->constants.data = NULL;
|
||||
@ -571,7 +569,7 @@ _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
|
||||
ret->static_field_count = 0;
|
||||
ret->vtable = NULL;
|
||||
ret->interfaces = NULL;
|
||||
ret->loader = loader;
|
||||
ret->loader = NULL;
|
||||
ret->interface_count = 0;
|
||||
ret->state = JV_STATE_NOTHING;
|
||||
ret->thread = NULL;
|
||||
@ -579,6 +577,17 @@ _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
|
||||
ret->ancestors = NULL;
|
||||
ret->idt = NULL;
|
||||
ret->arrayclass = NULL;
|
||||
}
|
||||
|
||||
jclass
|
||||
_Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
|
||||
java::lang::ClassLoader *loader)
|
||||
{
|
||||
jclass ret = (jclass) JvAllocObject (&ClassClass);
|
||||
_Jv_InitNewClassFields (ret);
|
||||
ret->name = name;
|
||||
ret->superclass = superclass;
|
||||
ret->loader = loader;
|
||||
|
||||
_Jv_RegisterClass (ret);
|
||||
|
||||
|
@ -56,6 +56,7 @@ details. */
|
||||
#include <java/lang/ArrayIndexOutOfBoundsException.h>
|
||||
#include <java/lang/ArithmeticException.h>
|
||||
#include <java/lang/ClassFormatError.h>
|
||||
#include <java/lang/InternalError.h>
|
||||
#include <java/lang/NegativeArraySizeException.h>
|
||||
#include <java/lang/NullPointerException.h>
|
||||
#include <java/lang/OutOfMemoryError.h>
|
||||
@ -533,8 +534,8 @@ _Jv_NewArray (jint type, jint size)
|
||||
case 10: return JvNewIntArray (size);
|
||||
case 11: return JvNewLongArray (size);
|
||||
}
|
||||
JvFail ("newarray - bad type code");
|
||||
return NULL; // Placate compiler.
|
||||
throw new java::lang::InternalError
|
||||
(JvNewStringLatin1 ("invalid type code in _Jv_NewArray"));
|
||||
}
|
||||
|
||||
// Allocate a possibly multi-dimensional array but don't check that
|
||||
@ -613,9 +614,14 @@ _Jv_InitPrimClass (jclass cl, char *cname, char sig, int len,
|
||||
{
|
||||
using namespace java::lang::reflect;
|
||||
|
||||
// We must initialize every field of the class. We do this in the
|
||||
// same order they are declared in Class.h, except for fields that
|
||||
// are initialized to NULL.
|
||||
_Jv_InitNewClassFields (cl);
|
||||
|
||||
// We must set the vtable for the class; the Java constructor
|
||||
// doesn't do this.
|
||||
(*(_Jv_VTable **) cl) = java::lang::Class::class$.vtable;
|
||||
|
||||
// Initialize the fields we care about. We do this in the same
|
||||
// order they are declared in Class.h.
|
||||
cl->name = _Jv_makeUtf8Const ((char *) cname, -1);
|
||||
cl->accflags = Modifier::PUBLIC | Modifier::FINAL | Modifier::ABSTRACT;
|
||||
cl->method_count = sig;
|
||||
|
Loading…
Reference in New Issue
Block a user