From da1416cd2d90960e1b600cdb36c7d9e3b5a344ae Mon Sep 17 00:00:00 2001 From: apbianco Date: Wed, 17 Jan 2001 08:13:06 +0000 Subject: 2001-01-16 Alexandre Petit-Bianco * prims.cc (init_prim_class): Deleted. (DECLARE_PRIM_TYPE): Rewritten. * java/lang/Class.h (stdio.h): Include removed. (stddef.h): Included. (java/lang/reflect/Modifier.h): Likewise. (Class): Contructor now takes arguments, initializes fields. (initializePrim): Prototype deleted. * java/lang/natClass.cc (initializePrim): Deleted. (http://sources.redhat.com/ml/java-patches/2001-q1/msg00081.html) git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39088 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/lang/Class.h | 56 ++++++++++++++++--------------------------- libjava/java/lang/natClass.cc | 23 ------------------ 2 files changed, 20 insertions(+), 59 deletions(-) (limited to 'libjava/java') diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h index 9793a5698dd..febe74816f9 100644 --- a/libjava/java/lang/Class.h +++ b/libjava/java/lang/Class.h @@ -14,10 +14,11 @@ details. */ #pragma interface -#include +#include #include #include #include +#include // We declare these here to avoid including gcj/cni.h. extern "C" void _Jv_InitClass (jclass klass); @@ -173,7 +174,10 @@ public: jboolean isAssignableFrom (jclass cls); jboolean isInstance (jobject obj); - jboolean isInterface (void); + jboolean isInterface (void) + { + return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0; + } inline jboolean isPrimitive (void) { @@ -192,52 +196,32 @@ public: // finalization void finalize (); - // For the initialization of primitive types: some constructors as - // required by prims.cc:init_prim_class(), and the prototype of - // method to perform a lightweight initialization of a Class object. - Class (void) {} - Class (const Class& x) : Object () { + // This constructor is used to create Class object for the primitive + // types. + Class (jobject cname, jbyte sig, jint len, jobject array_vtable) { + using namespace java::lang::reflect; + _Jv_Utf8Const *_Jv_makeUtf8Const (char *s, int len); + // C++ ctors are fixing the vtbl in a way that doesn't fit Java. // We can fix the C++ compiler, or we can hack our runtime. What's // below fix the vtable so that it starts at -2. void *p = ((void **)this)[0]; ((void **)this)[0] = (void *)((char *)p-2*sizeof (void *)); - _Jv_VTable *avtable = x.vtable; - - // We must initialize every field of the class. We do this in - // the same order they are declared in Class.h. - next = NULL; - name = x.name; - accflags = x.accflags; - superclass = NULL; - constants.size = 0; - constants.tags = NULL; - constants.data = NULL; - methods = NULL; - method_count = x.method_count; - vtable_method_count = 0; - fields = NULL; - size_in_bytes = x.size_in_bytes; - field_count = 0; - static_field_count = 0; + // 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. + name = _Jv_makeUtf8Const ((char *) cname, -1); + accflags = Modifier::PUBLIC | Modifier::FINAL | Modifier::ABSTRACT; + method_count = sig; + size_in_bytes = len; vtable = JV_PRIMITIVE_VTABLE; - interfaces = NULL; - loader = NULL; - interface_count = 0; state = JV_STATE_DONE; - thread = NULL; depth = -1; - ancestors = NULL; - idt = NULL; - if (method_count != 'V') - _Jv_NewArrayClass (this, NULL, avtable); - else - arrayclass = NULL; + _Jv_NewArrayClass (this, NULL, (_Jv_VTable *) array_vtable); } - void initializePrim (jobject cname, jbyte sig, jint len, jobject avtable); static java::lang::Class class$; diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc index 0e5479154b4..2d8a1254542 100644 --- a/libjava/java/lang/natClass.cc +++ b/libjava/java/lang/natClass.cc @@ -633,12 +633,6 @@ java::lang::Class::isInstance (jobject obj) return _Jv_IsAssignableFrom (this, JV_CLASS (obj)); } -jboolean -java::lang::Class::isInterface (void) -{ - return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0; -} - jobject java::lang::Class::newInstance (void) { @@ -1408,20 +1402,3 @@ java::lang::Class::getPrivateMethod (jstring name, JArray *param_types) } JvThrow (new java::lang::NoSuchMethodException); } - -// Perform a lightweight initialization of a Class object, for the -// purpose of creating the Class object of primitive types. - -void -java::lang::Class::initializePrim (jobject cname, jbyte sig, jint len, jobject avtable) -{ - using namespace java::lang::reflect; - - name = _Jv_makeUtf8Const ((char *) cname, -1); - accflags = Modifier::PUBLIC | Modifier::FINAL | Modifier::ABSTRACT; - method_count = sig; - size_in_bytes = len; - // We temporarily store `avtable' in the `vtable' field, so that the - // copy constructor can correctly invoke _Jv_FindArrayClass. - vtable = (_Jv_VTable *) avtable; -} -- cgit v1.2.1