From aa6f3d48d59f98f3a238d10ed7247c3ba4cd2f99 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 17 Jan 2003 16:45:28 +0000 Subject: * NEWS: Describe java.io.(VM)ObjectStreamClass. * configure.in (AC_OUTPUT): Add vm/reference/java/io/Makefile. * include/java_io_VMObjectOutputStream.h: New pregenerated header file. * java/io/ObjectStreamClass.java (getClassUID): Call VMObjectStreamClass.hasClassInitializer(). (hasClassInitializer): Removed. * native/jni/java-io/Makefile.am (libjavaio_la_SOURCES): Add java_io_ObjectStreamClass.c * native/jni/java-io/java_io_ObjectStreamClass.c: New file. * vm/reference/java/Makefile.am (SUBDIRS): Add io. * vm/reference/java/io/.cvsignore: New file. * vm/reference/java/io/Makefile.am: New file. * vm/reference/java/io/VMObjectStreamClass.java: New class. --- NEWS | 6 +++ configure.in | 1 + java/io/ObjectStreamClass.java | 27 +----------- native/jni/java-io/Makefile.am | 1 + native/jni/java-io/java_io_ObjectStreamClass.c | 61 ++++++++++++++++++++++++++ vm/reference/java/Makefile.am | 2 +- vm/reference/java/io/.cvsignore | 2 + vm/reference/java/io/Makefile.am | 4 ++ vm/reference/java/io/VMObjectStreamClass.java | 50 +++++++++++++++++++++ 9 files changed, 127 insertions(+), 27 deletions(-) create mode 100644 native/jni/java-io/java_io_ObjectStreamClass.c create mode 100644 vm/reference/java/io/.cvsignore create mode 100644 vm/reference/java/io/Makefile.am create mode 100644 vm/reference/java/io/VMObjectStreamClass.java diff --git a/NEWS b/NEWS index 6013b621d..12bcb972d 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,10 @@ New in release 0.05 [ no date yet ] +* New VM helper class java.io.VMObjectStreamClass which should provide + the hasClassInitializer() method. Previously ObjectStreamClass used + Class.getDeclaredMethod("") but according to the spec this + should always throw NoSuchMethodException for class initialization methods. + A JNI reference implementation is provided as + vm/reference/java-io/java_io_VMObjectStreamClass.c * There have been numerous infrastructure improvements * Configure option --enable-gjdoc to generate javadoc-like output * Gjdoc output is included with distribution, see doc/api/html/ diff --git a/configure.in b/configure.in index bb6a0e425..21a8b5f2b 100644 --- a/configure.in +++ b/configure.in @@ -389,6 +389,7 @@ vm/reference/Makefile vm/reference/java/Makefile vm/reference/java/lang/Makefile vm/reference/java/lang/reflect/Makefile +vm/reference/java/io/Makefile lib/Makefile lib/gen-classlist.sh lib/gen_nio.sh, diff --git a/java/io/ObjectStreamClass.java b/java/io/ObjectStreamClass.java index 5d4c102f2..211163552 100644 --- a/java/io/ObjectStreamClass.java +++ b/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 (""); 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. ). - private static boolean hasClassInitializer (Class clazz) - { - Method m = null; - - try - { - /* - * There exists a problem here, according to the spec - * clazz.getDeclaredMethod ("", classArgs); - * will always throw NoSuchMethodException, even if the static - * intializer does exist. - */ - Class classArgs[] = {}; - m = clazz.getDeclaredMethod ("", classArgs); - } - catch (java.lang.NoSuchMethodException e) - { - } - - return m != null; - } - public static final ObjectStreamField[] NO_FIELDS = {}; private static Hashtable classLookupTable = new Hashtable (); diff --git a/native/jni/java-io/Makefile.am b/native/jni/java-io/Makefile.am index 8f282d0f0..c56a2e553 100644 --- a/native/jni/java-io/Makefile.am +++ b/native/jni/java-io/Makefile.am @@ -9,6 +9,7 @@ libjavaio_la_SOURCES = javaio.h \ java_io_RandomAccessFile.c \ java_io_ObjectOutputStream.c \ java_io_ObjectInputStream.c \ + java_io_ObjectStreamClass.c \ java_nio.c diff --git a/native/jni/java-io/java_io_ObjectStreamClass.c b/native/jni/java-io/java_io_ObjectStreamClass.c new file mode 100644 index 000000000..6fe7b66c9 --- /dev/null +++ b/native/jni/java-io/java_io_ObjectStreamClass.c @@ -0,0 +1,61 @@ +/* java_io_VMObjectStreamClass.c -- Native methods for VMObjectStreamClass.java + 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. */ + + +#include +#include + +#include "java_io_VMObjectOutputStream.h" + +/* + * Class: java_io_VMObjectOutputStream + * Method: hasClassInitializer + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL +Java_java_io_VMObjectStreamClass_hasClassInitializer( JNIEnv * env, + jclass vmosklass, + jclass klass ) +{ + jmethodID mid = (*env)->GetStaticMethodID(env, klass, "", "()V"); + if (mid == NULL) + { + (*env)->ExceptionClear(env); + return JNI_FALSE; + } + return JNI_TRUE; +} diff --git a/vm/reference/java/Makefile.am b/vm/reference/java/Makefile.am index 479bbbe06..8c16975d6 100644 --- a/vm/reference/java/Makefile.am +++ b/vm/reference/java/Makefile.am @@ -1,3 +1,3 @@ # used by automake to generate Makefile.in -SUBDIRS = lang +SUBDIRS = lang io diff --git a/vm/reference/java/io/.cvsignore b/vm/reference/java/io/.cvsignore new file mode 100644 index 000000000..282522db0 --- /dev/null +++ b/vm/reference/java/io/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/vm/reference/java/io/Makefile.am b/vm/reference/java/io/Makefile.am new file mode 100644 index 000000000..4d060aaf2 --- /dev/null +++ b/vm/reference/java/io/Makefile.am @@ -0,0 +1,4 @@ +# used by automake to generate Makefile.in + +EXTRA_DIST = \ +VMObjectStreamClass.java diff --git a/vm/reference/java/io/VMObjectStreamClass.java b/vm/reference/java/io/VMObjectStreamClass.java new file mode 100644 index 000000000..fd4023e40 --- /dev/null +++ b/vm/reference/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. ). + */ + static native boolean hasClassInitializer (Class clazz); +} -- cgit v1.2.1