aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@cygnus.com>2001-01-15 08:11:40 +0000
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>2001-01-15 00:11:40 -0800
commit2feccc205e3371b3fb3037e50567ca357f783390 (patch)
tree0f67eae624079d38f268d0277b1b5f7310768fa4 /libjava/java
parentdc08e603899b1ac1ea91a9ee641853b20521d61e (diff)
downloadgcc-2feccc205e3371b3fb3037e50567ca357f783390.zip
gcc-2feccc205e3371b3fb3037e50567ca357f783390.tar.gz
gcc-2feccc205e3371b3fb3037e50567ca357f783390.tar.bz2
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
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/lang/Class.h52
-rw-r--r--libjava/java/lang/Object.h20
-rw-r--r--libjava/java/lang/natClass.cc26
3 files changed, 79 insertions, 19 deletions
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
index 12e3ed5..9793a56 100644
--- a/libjava/java/lang/Class.h
+++ b/libjava/java/lang/Class.h
@@ -1,6 +1,6 @@
// 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.
@@ -14,6 +14,7 @@ details. */
#pragma interface
+#include <stdio.h>
#include <java/lang/Object.h>
#include <java/lang/String.h>
#include <java/net/URL.h>
@@ -191,6 +192,53 @@ 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 () {
+
+ // 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$;
private:
@@ -237,8 +285,6 @@ private:
friend jint JvNumMethods (jclass);
friend jmethodID JvGetFirstMethod (jclass);
- friend class _Jv_PrimClass;
-
// Friends classes and functions to implement the ClassLoader
friend class java::lang::ClassLoader;
diff --git a/libjava/java/lang/Object.h b/libjava/java/lang/Object.h
index 21e8fb0..81b5a66 100644
--- a/libjava/java/lang/Object.h
+++ b/libjava/java/lang/Object.h
@@ -1,6 +1,6 @@
// 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.
@@ -15,23 +15,22 @@ details. */
#include <gcj/javaprims.h>
-// This class is mainly here as a kludge to get G++ to allocate
-// vtable pointer as the *first* word of each Object, instead of
-// the second word (following sync_info). Note that various pieces of
-// code know that finalize() is the first method. For instance,
-// Object.java knows this, as does _Jv_AllocObject.
+// This class is mainly here as a kludge to get G++ to allocate two
+// extra entries in the vtable. We will use them to store data. This
+// allows us to support the new C++ ABI.
struct _JvObjectPrefix
{
protected:
- // This is disguised as the C++ vtbl.
- // _Jv_VTable* vtable;
-
- virtual void finalize () = 0;
+ // New ABI Compatibility Dummy, #1 and 2.
+ virtual void nacd_1 (void) {};
+ virtual void nacd_2 (void) {};
};
class java::lang::Object : public _JvObjectPrefix
{
+protected:
+ virtual void finalize (void);
public:
// Order must match order in Object.java.
jclass getClass (void);
@@ -61,7 +60,6 @@ public:
protected:
virtual jobject clone (void);
- virtual void finalize (void);
private:
// This does not actually refer to a Java object. Instead it is a
diff --git a/libjava/java/lang/natClass.cc b/libjava/java/lang/natClass.cc
index 3a02b46a..0e54791 100644
--- a/libjava/java/lang/natClass.cc
+++ b/libjava/java/lang/natClass.cc
@@ -1,6 +1,6 @@
// 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.
@@ -615,7 +615,7 @@ java::lang::Class::getMethods (void)
return result;
}
-inline jboolean
+jboolean
java::lang::Class::isAssignableFrom (jclass klass)
{
// Arguments may not have been initialized, given ".class" syntax.
@@ -624,7 +624,7 @@ java::lang::Class::isAssignableFrom (jclass klass)
return _Jv_IsAssignableFrom (this, klass);
}
-inline jboolean
+jboolean
java::lang::Class::isInstance (jobject obj)
{
if (__builtin_expect (! obj || isPrimitive (), false))
@@ -633,7 +633,7 @@ java::lang::Class::isInstance (jobject obj)
return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
}
-inline jboolean
+jboolean
java::lang::Class::isInterface (void)
{
return (accflags & java::lang::reflect::Modifier::INTERFACE) != 0;
@@ -1235,7 +1235,7 @@ _Jv_AppendPartialITable (jclass klass, jclass iface, void **itable,
for (jclass cl = klass; cl; cl = cl->getSuperclass())
{
meth = _Jv_GetMethodLocal (cl, iface->methods[j].name,
- iface->methods[j].signature);
+ iface->methods[j].signature);
if (meth)
break;
@@ -1409,3 +1409,19 @@ java::lang::Class::getPrivateMethod (jstring name, JArray<jclass> *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;
+}