aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/io/ObjectStreamClass.java27
-rw-r--r--libjava/java/io/VMObjectStreamClass.java50
-rw-r--r--libjava/java/io/natVMObjectStreamClass.cc23
-rw-r--r--libjava/java/lang/Class.h3
4 files changed, 76 insertions, 27 deletions
diff --git a/libjava/java/io/ObjectStreamClass.java b/libjava/java/io/ObjectStreamClass.java
index 5d4c102..2111635 100644
--- a/libjava/java/io/ObjectStreamClass.java
+++ b/libjava/java/io/ObjectStreamClass.java
@@ -525,7 +525,7 @@ public class ObjectStreamClass implements Serializable
}
// write class initializer method if present
- if (hasClassInitializer (cl))
+ if (VMObjectStreamClass.hasClassInitializer (cl))
{
data_out.writeUTF ("<clinit>");
data_out.writeInt (Modifier.STATIC);
@@ -613,31 +613,6 @@ public class ObjectStreamClass implements Serializable
return o;
}
-
- // Returns true if CLAZZ has a static class initializer
- // (a.k.a. <clinit>).
- private static boolean hasClassInitializer (Class clazz)
- {
- Method m = null;
-
- try
- {
- /*
- * There exists a problem here, according to the spec
- * clazz.getDeclaredMethod ("<clinit>", classArgs);
- * will always throw NoSuchMethodException, even if the static
- * intializer does exist.
- */
- Class classArgs[] = {};
- m = clazz.getDeclaredMethod ("<clinit>", classArgs);
- }
- catch (java.lang.NoSuchMethodException e)
- {
- }
-
- return m != null;
- }
-
public static final ObjectStreamField[] NO_FIELDS = {};
private static Hashtable classLookupTable = new Hashtable ();
diff --git a/libjava/java/io/VMObjectStreamClass.java b/libjava/java/io/VMObjectStreamClass.java
new file mode 100644
index 0000000..fd4023e
--- /dev/null
+++ b/libjava/java/io/VMObjectStreamClass.java
@@ -0,0 +1,50 @@
+/* VMObjectStreamClass.java -- VM helper functions for ObjectStreamClass
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.io;
+
+import java.lang.reflect.Method;
+
+final class VMObjectStreamClass
+{
+ /**
+ * Returns true if CLAZZ has a static class initializer
+ * (a.k.a. <clinit>).
+ */
+ static native boolean hasClassInitializer (Class clazz);
+}
diff --git a/libjava/java/io/natVMObjectStreamClass.cc b/libjava/java/io/natVMObjectStreamClass.cc
new file mode 100644
index 0000000..b7a056c
--- /dev/null
+++ b/libjava/java/io/natVMObjectStreamClass.cc
@@ -0,0 +1,23 @@
+// natVMObjectStreamClass.cc - Native part of VMObjectStreamClass class.
+
+/* Copyright (C) 2003 Free Software Foundation
+
+ This VMObjectStreamClass is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the ObjectInputStream "LIBGCJ_LICENSE" for
+details. */
+
+#include <gcj/cni.h>
+#include <jvm.h>
+
+#include <java/io/VMObjectStreamClass.h>
+#include <java/lang/Class.h>
+
+jboolean
+java::io::VMObjectStreamClass::hasClassInitializer (jclass klass)
+{
+ _Jv_Method *meth = _Jv_GetMethodLocal(klass, gcj::clinit_name,
+ gcj::void_signature);
+ return (meth != NULL);
+}
diff --git a/libjava/java/lang/Class.h b/libjava/java/lang/Class.h
index 5a56fd3..db05cb6 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, 2001, 2002 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
This file is part of libgcj.
@@ -364,6 +364,7 @@ private:
friend class _Jv_BytecodeVerifier;
friend class gnu::gcj::runtime::StackTrace;
+ friend class java::io::VMObjectStreamClass;
// Chain for class pool.
jclass next;