Commit ed8cc5fd by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

prims.cc (init_prim_class): Deleted.

2001-01-16  Alexandre Petit-Bianco  <apbianco@cygnus.com>

	* 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)

From-SVN: r39088
parent d34786e3
2001-01-16 Alexandre Petit-Bianco <apbianco@cygnus.com>
* 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.
2001-01-16 Warren Levy <warrenl@redhat.com> 2001-01-16 Warren Levy <warrenl@redhat.com>
* java/math/BigInteger.java: Update Copyright year. * java/math/BigInteger.java: Update Copyright year.
......
...@@ -14,10 +14,11 @@ details. */ ...@@ -14,10 +14,11 @@ details. */
#pragma interface #pragma interface
#include <stdio.h> #include <stddef.h>
#include <java/lang/Object.h> #include <java/lang/Object.h>
#include <java/lang/String.h> #include <java/lang/String.h>
#include <java/net/URL.h> #include <java/net/URL.h>
#include <java/lang/reflect/Modifier.h>
// We declare these here to avoid including gcj/cni.h. // We declare these here to avoid including gcj/cni.h.
extern "C" void _Jv_InitClass (jclass klass); extern "C" void _Jv_InitClass (jclass klass);
...@@ -173,7 +174,10 @@ public: ...@@ -173,7 +174,10 @@ public:
jboolean isAssignableFrom (jclass cls); jboolean isAssignableFrom (jclass cls);
jboolean isInstance (jobject obj); jboolean isInstance (jobject obj);
jboolean isInterface (void); jboolean isInterface (void)
{
return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
}
inline jboolean isPrimitive (void) inline jboolean isPrimitive (void)
{ {
...@@ -192,52 +196,32 @@ public: ...@@ -192,52 +196,32 @@ public:
// finalization // finalization
void finalize (); void finalize ();
// For the initialization of primitive types: some constructors as // This constructor is used to create Class object for the primitive
// required by prims.cc:init_prim_class(), and the prototype of // types.
// method to perform a lightweight initialization of a Class object. Class (jobject cname, jbyte sig, jint len, jobject array_vtable) {
Class (void) {}
Class (const Class& x) : Object () {
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. // 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 // We can fix the C++ compiler, or we can hack our runtime. What's
// below fix the vtable so that it starts at -2. // below fix the vtable so that it starts at -2.
void *p = ((void **)this)[0]; void *p = ((void **)this)[0];
((void **)this)[0] = (void *)((char *)p-2*sizeof (void *)); ((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, except for fields that
// We must initialize every field of the class. We do this in // are initialized to NULL.
// the same order they are declared in Class.h. name = _Jv_makeUtf8Const ((char *) cname, -1);
next = NULL; accflags = Modifier::PUBLIC | Modifier::FINAL | Modifier::ABSTRACT;
name = x.name; method_count = sig;
accflags = x.accflags; size_in_bytes = len;
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;
vtable = JV_PRIMITIVE_VTABLE; vtable = JV_PRIMITIVE_VTABLE;
interfaces = NULL;
loader = NULL;
interface_count = 0;
state = JV_STATE_DONE; state = JV_STATE_DONE;
thread = NULL;
depth = -1; depth = -1;
ancestors = NULL;
idt = NULL;
if (method_count != 'V') if (method_count != 'V')
_Jv_NewArrayClass (this, NULL, avtable); _Jv_NewArrayClass (this, NULL, (_Jv_VTable *) array_vtable);
else
arrayclass = NULL;
} }
void initializePrim (jobject cname, jbyte sig, jint len, jobject avtable);
static java::lang::Class class$; static java::lang::Class class$;
......
...@@ -633,12 +633,6 @@ java::lang::Class::isInstance (jobject obj) ...@@ -633,12 +633,6 @@ java::lang::Class::isInstance (jobject obj)
return _Jv_IsAssignableFrom (this, JV_CLASS (obj)); return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
} }
jboolean
java::lang::Class::isInterface (void)
{
return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
}
jobject jobject
java::lang::Class::newInstance (void) java::lang::Class::newInstance (void)
{ {
...@@ -1408,20 +1402,3 @@ java::lang::Class::getPrivateMethod (jstring name, JArray<jclass> *param_types) ...@@ -1408,20 +1402,3 @@ java::lang::Class::getPrivateMethod (jstring name, JArray<jclass> *param_types)
} }
JvThrow (new java::lang::NoSuchMethodException); 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;
}
...@@ -510,21 +510,11 @@ _Jv_NewMultiArray (jclass array_type, jint dimensions, ...) ...@@ -510,21 +510,11 @@ _Jv_NewMultiArray (jclass array_type, jint dimensions, ...)
// Initialize Class object for primitive types. The `return' statement
// does the actuall job.
static java::lang::Class
init_prim_class (jobject cname, jbyte sig, jint len, jobject array_vtable)
{
static java::lang::Class iclass;
iclass.initializePrim (cname, sig, len, array_vtable);
return iclass;
}
#define DECLARE_PRIM_TYPE(NAME, SIG, LEN) \ #define DECLARE_PRIM_TYPE(NAME, SIG, LEN) \
_Jv_ArrayVTable _Jv_##NAME##VTable; \ _Jv_ArrayVTable _Jv_##NAME##VTable; \
java::lang::Class _Jv_##NAME##Class = \ java::lang::Class _Jv_##NAME##Class ((jobject) #NAME, \
init_prim_class ((jobject) #NAME, (jbyte) SIG, \ (jbyte) SIG, (jint) LEN, \
(jint) LEN, (jobject) &_Jv_##NAME##VTable); (jobject) &_Jv_##NAME##VTable);
DECLARE_PRIM_TYPE(byte, 'B', 1); DECLARE_PRIM_TYPE(byte, 'B', 1);
DECLARE_PRIM_TYPE(short, 'S', 2); DECLARE_PRIM_TYPE(short, 'S', 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment