All files with updated copyright.
2001-01-07 Alexandre Petit-Bianco <apbianco@cygnus.com> All files with updated copyright. * prims.cc (class _Jv_PrimClass): Removed. (init_prim_class): New function. (DECLARE_PRIM_TYPE): Rewritten. `java::lang::Class' replaces `_Jv_PrimClass' in primitive type declarations. Assign to the value returned by `init_prim_class.' * gcj/array.h: `java::lang::Class' replaces `_Jv_PrimClass' in primitive type declarations. (JvPrimClass): Cast to `jclass' removed. * java/lang/Class.h (Class): New constructor. (Class): New copy constructor. (initializePrim): New prototype. (_Jv_PrimClass): Field removed. * java/lang/Object.h (struct _JvObjectPrefix): New virtuals nacd_1 and nacd_2 (for compatibility with the new C++ ABI.) (class java::lang::Object): `finalize' moved up front. * java/lang/natClass.cc (isAssignableFrom): Turned outline. (isInstance): Likewise. (isInterface): Likewise, fixed indentation. (initializePrim): New function. (New C++ ABI compatibility patch: http://sources.redhat.com/ml/java-patches/2001-q1/msg00065.html) From-SVN: r39032
This commit is contained in:
parent
dc08e60389
commit
2feccc205e
6 changed files with 121 additions and 73 deletions
|
@ -116,6 +116,30 @@
|
||||||
from the c++ compiler.
|
from the c++ compiler.
|
||||||
* Makefile.in: Rebuilt.
|
* Makefile.in: Rebuilt.
|
||||||
|
|
||||||
|
2001-01-07 Alexandre Petit-Bianco <apbianco@cygnus.com>
|
||||||
|
|
||||||
|
All files with updated copyright.
|
||||||
|
* prims.cc (class _Jv_PrimClass): Removed.
|
||||||
|
(init_prim_class): New function.
|
||||||
|
(DECLARE_PRIM_TYPE): Rewritten. `java::lang::Class' replaces
|
||||||
|
`_Jv_PrimClass' in primitive type declarations. Assign to the
|
||||||
|
value returned by `init_prim_class.'
|
||||||
|
* gcj/array.h: `java::lang::Class' replaces `_Jv_PrimClass' in
|
||||||
|
primitive type declarations.
|
||||||
|
(JvPrimClass): Cast to `jclass' removed.
|
||||||
|
* java/lang/Class.h (Class): New constructor.
|
||||||
|
(Class): New copy constructor.
|
||||||
|
(initializePrim): New prototype.
|
||||||
|
(_Jv_PrimClass): Field removed.
|
||||||
|
* java/lang/Object.h (struct _JvObjectPrefix): New virtuals
|
||||||
|
nacd_1 and nacd_2 (for compatibility with the new C++ ABI.)
|
||||||
|
(class java::lang::Object): `finalize' moved up front.
|
||||||
|
* java/lang/natClass.cc
|
||||||
|
(isAssignableFrom): Turned outline.
|
||||||
|
(isInstance): Likewise.
|
||||||
|
(isInterface): Likewise, fixed indentation.
|
||||||
|
(initializePrim): New function.
|
||||||
|
|
||||||
2001-01-07 Anthony Green <green@redhat.com>
|
2001-01-07 Anthony Green <green@redhat.com>
|
||||||
|
|
||||||
* Makefile.am (texinfo): Add texinfo target for generating texinfo
|
* Makefile.am (texinfo): Add texinfo target for generating texinfo
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// array.h - Header file for CNI arrays. -*- c++ -*-
|
// array.h - Header file for CNI arrays. -*- c++ -*-
|
||||||
|
|
||||||
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
|
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ typedef JArray<jfloat> *jfloatArray;
|
||||||
typedef JArray<jdouble> *jdoubleArray;
|
typedef JArray<jdouble> *jdoubleArray;
|
||||||
typedef JArray<jstring> *jstringArray;
|
typedef JArray<jstring> *jstringArray;
|
||||||
|
|
||||||
extern class _Jv_PrimClass _Jv_byteClass, _Jv_shortClass, _Jv_intClass,
|
extern java::lang::Class _Jv_byteClass, _Jv_shortClass, _Jv_intClass,
|
||||||
_Jv_longClass, _Jv_booleanClass, _Jv_charClass, _Jv_floatClass,
|
_Jv_longClass, _Jv_booleanClass, _Jv_charClass, _Jv_floatClass,
|
||||||
_Jv_doubleClass, _Jv_voidClass;
|
_Jv_doubleClass, _Jv_voidClass;
|
||||||
#define JvPrimClass(TYPE) ((jclass) & _Jv_##TYPE##Class)
|
#define JvPrimClass(TYPE) (& _Jv_##TYPE##Class)
|
||||||
|
|
||||||
extern "C" jobjectArray _Jv_NewObjectArray(jsize length, jclass, jobject init);
|
extern "C" jobjectArray _Jv_NewObjectArray(jsize length, jclass, jobject init);
|
||||||
extern "C" jobject _Jv_NewPrimArray (jclass eltype, jint count);
|
extern "C" jobject _Jv_NewPrimArray (jclass eltype, jint count);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Class.h - Header file for java.lang.Class. -*- c++ -*-
|
// Class.h - Header file for java.lang.Class. -*- c++ -*-
|
||||||
|
|
||||||
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
|
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ details. */
|
||||||
|
|
||||||
#pragma interface
|
#pragma interface
|
||||||
|
|
||||||
|
#include <stdio.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>
|
||||||
|
@ -191,6 +192,53 @@ public:
|
||||||
// finalization
|
// finalization
|
||||||
void finalize ();
|
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 () {
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
void initializePrim (jobject cname, jbyte sig, jint len, jobject avtable);
|
||||||
|
|
||||||
static java::lang::Class class$;
|
static java::lang::Class class$;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -237,8 +285,6 @@ private:
|
||||||
friend jint JvNumMethods (jclass);
|
friend jint JvNumMethods (jclass);
|
||||||
friend jmethodID JvGetFirstMethod (jclass);
|
friend jmethodID JvGetFirstMethod (jclass);
|
||||||
|
|
||||||
friend class _Jv_PrimClass;
|
|
||||||
|
|
||||||
// Friends classes and functions to implement the ClassLoader
|
// Friends classes and functions to implement the ClassLoader
|
||||||
friend class java::lang::ClassLoader;
|
friend class java::lang::ClassLoader;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Object.h - Header file for java.lang.Object. -*- c++ -*-
|
// Object.h - Header file for java.lang.Object. -*- c++ -*-
|
||||||
|
|
||||||
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
|
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
|
@ -15,23 +15,22 @@ details. */
|
||||||
|
|
||||||
#include <gcj/javaprims.h>
|
#include <gcj/javaprims.h>
|
||||||
|
|
||||||
// This class is mainly here as a kludge to get G++ to allocate
|
// This class is mainly here as a kludge to get G++ to allocate two
|
||||||
// vtable pointer as the *first* word of each Object, instead of
|
// extra entries in the vtable. We will use them to store data. This
|
||||||
// the second word (following sync_info). Note that various pieces of
|
// allows us to support the new C++ ABI.
|
||||||
// code know that finalize() is the first method. For instance,
|
|
||||||
// Object.java knows this, as does _Jv_AllocObject.
|
|
||||||
|
|
||||||
struct _JvObjectPrefix
|
struct _JvObjectPrefix
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// This is disguised as the C++ vtbl.
|
// New ABI Compatibility Dummy, #1 and 2.
|
||||||
// _Jv_VTable* vtable;
|
virtual void nacd_1 (void) {};
|
||||||
|
virtual void nacd_2 (void) {};
|
||||||
virtual void finalize () = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class java::lang::Object : public _JvObjectPrefix
|
class java::lang::Object : public _JvObjectPrefix
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
virtual void finalize (void);
|
||||||
public:
|
public:
|
||||||
// Order must match order in Object.java.
|
// Order must match order in Object.java.
|
||||||
jclass getClass (void);
|
jclass getClass (void);
|
||||||
|
@ -61,7 +60,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual jobject clone (void);
|
virtual jobject clone (void);
|
||||||
virtual void finalize (void);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This does not actually refer to a Java object. Instead it is a
|
// This does not actually refer to a Java object. Instead it is a
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// natClass.cc - Implementation of java.lang.Class native methods.
|
// natClass.cc - Implementation of java.lang.Class native methods.
|
||||||
|
|
||||||
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
|
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ java::lang::Class::getMethods (void)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline jboolean
|
jboolean
|
||||||
java::lang::Class::isAssignableFrom (jclass klass)
|
java::lang::Class::isAssignableFrom (jclass klass)
|
||||||
{
|
{
|
||||||
// Arguments may not have been initialized, given ".class" syntax.
|
// Arguments may not have been initialized, given ".class" syntax.
|
||||||
|
@ -624,7 +624,7 @@ java::lang::Class::isAssignableFrom (jclass klass)
|
||||||
return _Jv_IsAssignableFrom (this, klass);
|
return _Jv_IsAssignableFrom (this, klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline jboolean
|
jboolean
|
||||||
java::lang::Class::isInstance (jobject obj)
|
java::lang::Class::isInstance (jobject obj)
|
||||||
{
|
{
|
||||||
if (__builtin_expect (! obj || isPrimitive (), false))
|
if (__builtin_expect (! obj || isPrimitive (), false))
|
||||||
|
@ -633,7 +633,7 @@ java::lang::Class::isInstance (jobject obj)
|
||||||
return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
|
return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline jboolean
|
jboolean
|
||||||
java::lang::Class::isInterface (void)
|
java::lang::Class::isInterface (void)
|
||||||
{
|
{
|
||||||
return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
|
return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
|
||||||
|
@ -1409,3 +1409,19 @@ 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;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// prims.cc - Code for core of runtime environment.
|
// prims.cc - Code for core of runtime environment.
|
||||||
|
|
||||||
/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
|
/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
|
||||||
|
|
||||||
This file is part of libgcj.
|
This file is part of libgcj.
|
||||||
|
|
||||||
|
@ -510,57 +510,21 @@ _Jv_NewMultiArray (jclass array_type, jint dimensions, ...)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class _Jv_PrimClass : public java::lang::Class
|
// 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)
|
||||||
{
|
{
|
||||||
public:
|
static java::lang::Class iclass;
|
||||||
// FIXME: calling convention is weird. If we use the natural types
|
iclass.initializePrim (cname, sig, len, array_vtable);
|
||||||
// then the compiler will complain because they aren't Java types.
|
return iclass;
|
||||||
_Jv_PrimClass (jobject cname, jbyte sig, jint len, jobject array_vtable)
|
}
|
||||||
{
|
|
||||||
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.
|
|
||||||
next = NULL;
|
|
||||||
name = _Jv_makeUtf8Const ((char *) cname, -1);
|
|
||||||
accflags = Modifier::PUBLIC | Modifier::FINAL | Modifier::ABSTRACT;
|
|
||||||
superclass = NULL;
|
|
||||||
constants.size = 0;
|
|
||||||
constants.tags = NULL;
|
|
||||||
constants.data = NULL;
|
|
||||||
methods = NULL;
|
|
||||||
method_count = sig;
|
|
||||||
vtable_method_count = 0;
|
|
||||||
fields = NULL;
|
|
||||||
size_in_bytes = len;
|
|
||||||
field_count = 0;
|
|
||||||
static_field_count = 0;
|
|
||||||
vtable = JV_PRIMITIVE_VTABLE;
|
|
||||||
interfaces = NULL;
|
|
||||||
loader = NULL;
|
|
||||||
interface_count = 0;
|
|
||||||
state = JV_STATE_DONE;
|
|
||||||
thread = NULL;
|
|
||||||
depth = -1;
|
|
||||||
ancestors = NULL;
|
|
||||||
idt = NULL;
|
|
||||||
|
|
||||||
// Note that we have to set `methods' to NULL.
|
|
||||||
if (sig != 'V')
|
|
||||||
_Jv_NewArrayClass (this, NULL, (_Jv_VTable *) array_vtable);
|
|
||||||
else
|
|
||||||
arrayclass = NULL;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// We use this to define both primitive classes and the vtables for
|
|
||||||
// arrays of primitive classes. The latter are given names so that we
|
|
||||||
// can refer to them from the compiler, allowing us to construct
|
|
||||||
// arrays of primitives statically.
|
|
||||||
#define DECLARE_PRIM_TYPE(NAME, SIG, LEN) \
|
#define DECLARE_PRIM_TYPE(NAME, SIG, LEN) \
|
||||||
_Jv_ArrayVTable _Jv_##NAME##VTable; \
|
_Jv_ArrayVTable _Jv_##NAME##VTable; \
|
||||||
_Jv_PrimClass _Jv_##NAME##Class((jobject) #NAME, (jbyte) SIG, (jint) LEN, \
|
java::lang::Class _Jv_##NAME##Class = \
|
||||||
(jobject) &_Jv_##NAME##VTable)
|
init_prim_class ((jobject) #NAME, (jbyte) SIG, \
|
||||||
|
(jint) LEN, (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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue