Index: include/Makefile.am =================================================================== RCS file: /cvsroot/classpath/classpath/include/Makefile.am,v retrieving revision 1.41 diff -u -r1.41 Makefile.am --- include/Makefile.am 16 Apr 2005 09:19:54 -0000 1.41 +++ include/Makefile.am 16 Apr 2005 11:04:40 -0000 @@ -72,8 +72,8 @@ $(top_srcdir)/include/gnu_java_nio_VMPipe.h \ $(top_srcdir)/include/gnu_java_nio_VMSelector.h \ $(top_srcdir)/include/gnu_java_nio_channels_FileChannelImpl.h \ -$(top_srcdir)/include/java_io_ObjectInputStream.h \ $(top_srcdir)/include/java_io_VMFile.h \ +$(top_srcdir)/include/java_io_VMObjectInputStream.h \ $(top_srcdir)/include/java_io_VMObjectStreamClass.h \ $(top_srcdir)/include/java_lang_Math.h \ $(top_srcdir)/include/java_lang_VMDouble.h \ @@ -111,10 +111,10 @@ $(JAVAH) -o $@ gnu.java.nio.VMPipe $(top_srcdir)/include/gnu_java_nio_VMSelector.h: $(top_srcdir)/vm/reference/gnu/java/nio/VMSelector.java $(JAVAH) -o $@ gnu.java.nio.VMSelector -$(top_srcdir)/include/java_io_ObjectInputStream.h: $(top_srcdir)/java/io/ObjectInputStream.java - $(JAVAH) -o $@ java.io.ObjectInputStream $(top_srcdir)/include/java_io_VMFile.h: $(top_srcdir)/vm/reference/java/io/VMFile.java $(JAVAH) -o $@ java.io.VMFile +$(top_srcdir)/include/java_io_VMObjectInputStream.h: $(top_srcdir)/vm/reference/java/io/VMObjectInputStream.java + $(JAVAH) -o $@ java.io.VMObjectInputStream $(top_srcdir)/include/java_io_VMObjectStreamClass.h: $(top_srcdir)/vm/reference/java/io/VMObjectStreamClass.java $(JAVAH) -o $@ java.io.VMObjectStreamClass $(top_srcdir)/include/java_lang_Math.h: $(top_srcdir)/java/lang/Math.java Index: include/java_io_ObjectInputStream.h =================================================================== RCS file: include/java_io_ObjectInputStream.h diff -N include/java_io_ObjectInputStream.h --- include/java_io_ObjectInputStream.h 6 Dec 2004 17:11:45 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,22 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ - -#ifndef __java_io_ObjectInputStream__ -#define __java_io_ObjectInputStream__ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -JNIEXPORT jobject JNICALL Java_java_io_ObjectInputStream_currentClassLoader (JNIEnv *env, jclass, jobject); -JNIEXPORT jobject JNICALL Java_java_io_ObjectInputStream_allocateObject (JNIEnv *env, jobject, jclass, jclass, jobject); -#undef java_io_ObjectInputStream_BUFFER_SIZE -#define java_io_ObjectInputStream_BUFFER_SIZE 1024L - -#ifdef __cplusplus -} -#endif - -#endif /* __java_io_ObjectInputStream__ */ Index: include/java_io_VMObjectInputStream.h =================================================================== RCS file: include/java_io_VMObjectInputStream.h diff -N include/java_io_VMObjectInputStream.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/java_io_VMObjectInputStream.h 16 Apr 2005 11:04:40 -0000 @@ -0,0 +1,20 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ + +#ifndef __java_io_VMObjectInputStream__ +#define __java_io_VMObjectInputStream__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +JNIEXPORT jobject JNICALL Java_java_io_VMObjectInputStream_currentClassLoader (JNIEnv *env, jclass, jobject); +JNIEXPORT jobject JNICALL Java_java_io_VMObjectInputStream_allocateObject (JNIEnv *env, jclass, jclass, jclass, jobject); + +#ifdef __cplusplus +} +#endif + +#endif /* __java_io_VMObjectInputStream__ */ Index: java/io/ObjectInputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v retrieving revision 1.54 diff -u -r1.54 ObjectInputStream.java --- java/io/ObjectInputStream.java 22 Feb 2005 03:39:43 -0000 1.54 +++ java/io/ObjectInputStream.java 16 Apr 2005 11:04:41 -0000 @@ -796,7 +796,7 @@ if (sm == null) sm = new SecurityManager () {}; - return currentClassLoader(sm); + return VMObjectInputStream.currentClassLoader(sm); } /** @@ -888,7 +888,7 @@ if (sm == null) sm = new SecurityManager() {}; - ClassLoader cl = currentClassLoader(sm); + ClassLoader cl = VMObjectInputStream.currentClassLoader(sm); Class[] clss = new Class[intfs.length]; if(cl == null) @@ -1838,7 +1838,7 @@ throw new InvalidClassException("Missing accessible no-arg base class constructor for " + real_class.getName()); try { - return allocateObject(real_class, constructor.getDeclaringClass(), constructor); + return VMObjectInputStream.allocateObject(real_class, constructor.getDeclaringClass(), constructor); } catch (InstantiationException e) { @@ -1866,15 +1866,6 @@ } } - /** - * This native method is used to get access to the protected method - * of the same name in SecurityManger. - * - * @param sm SecurityManager instance which should be called. - * @return The current class loader in the calling stack. - */ - private static native ClassLoader currentClassLoader (SecurityManager sm); - private void callReadMethod (Method readObject, Class klass, Object obj) throws ClassNotFoundException, IOException { @@ -1906,9 +1897,6 @@ prereadFields = null; } - private native Object allocateObject(Class clazz, Class constr_clazz, Constructor constructor) - throws InstantiationException; - private static final int BUFFER_SIZE = 1024; private DataInputStream realInputStream; Index: native/jni/java-io/Makefile.am =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/java-io/Makefile.am,v retrieving revision 1.18 diff -u -r1.18 Makefile.am --- native/jni/java-io/Makefile.am 26 Oct 2004 20:26:03 -0000 1.18 +++ native/jni/java-io/Makefile.am 16 Apr 2005 11:04:41 -0000 @@ -2,8 +2,8 @@ libjavaio_la_SOURCES = javaio.h \ javaio.c \ - java_io_ObjectInputStream.c \ java_io_VMFile.c \ + java_io_VMObjectInputStream.c \ java_io_VMObjectStreamClass.c libjavaio_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo Index: native/jni/java-io/java_io_ObjectInputStream.c =================================================================== RCS file: native/jni/java-io/java_io_ObjectInputStream.c diff -N native/jni/java-io/java_io_ObjectInputStream.c --- native/jni/java-io/java_io_ObjectInputStream.c 8 Apr 2005 13:01:42 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,91 +0,0 @@ -/* java_io_ObjectInputStream.c -- Native methods for ObjectInputStream class - Copyright (C) 1998, 2004 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. */ - - -/* TODO: check exceptions */ -/* comments */ - -/* do not move; needed here because of some macro definitions */ -#include - -#include -#include - -#include "java_io_ObjectInputStream.h" - -/* - * Class: java_io_ObjectInputStream - * Method: currentClassLoader - * Signature: (Ljava/lang/SecurityManager;)Ljava/lang/ClassLoader; - */ -JNIEXPORT jobject JNICALL -Java_java_io_ObjectInputStream_currentClassLoader (JNIEnv * env, - jclass clazz, - jobject loader) -{ - jmethodID id = (*env)->GetMethodID (env, - (*env)->GetObjectClass (env, loader), - "currentClassLoader", - "()Ljava/lang/ClassLoader;"); - - if (id == NULL) - return NULL; - - return (*env)->CallObjectMethod (env, loader, id, clazz); -} - - -/* - * Class: java_io_ObjectInputStream - * Method: allocateObject - * Signature: (Ljava/lang/Class;)Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL -Java_java_io_ObjectInputStream_allocateObject (JNIEnv * env, - jobject self - __attribute__ ((__unused__)), - jclass clazz, - jclass constr_clazz, - jobject constructor) -{ - jobject obj = (*env)->AllocObject (env, clazz); - jmethodID id = (*env)->FromReflectedMethod (env, constructor); - - (*env)->CallNonvirtualVoidMethod (env, obj, constr_clazz, id); - - return obj; -} Index: native/jni/java-io/java_io_VMObjectInputStream.c =================================================================== RCS file: native/jni/java-io/java_io_VMObjectInputStream.c diff -N native/jni/java-io/java_io_VMObjectInputStream.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ native/jni/java-io/java_io_VMObjectInputStream.c 16 Apr 2005 11:04:41 -0000 @@ -0,0 +1,91 @@ +/* java_io_VMObjectInputStream.c -- Native methods for ObjectInputStream class + Copyright (C) 1998, 2004, 2005 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. */ + + +/* TODO: check exceptions */ +/* comments */ + +/* do not move; needed here because of some macro definitions */ +#include + +#include +#include + +#include "java_io_VMObjectInputStream.h" + +/* + * Class: java_io_VMObjectInputStream + * Method: currentClassLoader + * Signature: (Ljava/lang/SecurityManager;)Ljava/lang/ClassLoader; + */ +JNIEXPORT jobject JNICALL +Java_java_io_VMObjectInputStream_currentClassLoader (JNIEnv * env, + jclass clazz, + jobject loader) +{ + jmethodID id = (*env)->GetMethodID (env, + (*env)->GetObjectClass (env, loader), + "currentClassLoader", + "()Ljava/lang/ClassLoader;"); + + if (id == NULL) + return NULL; + + return (*env)->CallObjectMethod (env, loader, id, clazz); +} + + +/* + * Class: java_io_VMObjectInputStream + * Method: allocateObject + * Signature: (Ljava/lang/Class;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL +Java_java_io_VMObjectInputStream_allocateObject (JNIEnv * env, + jclass clazz + __attribute__((__unused__)), + jclass target_clazz, + jclass constr_clazz, + jobject constructor) +{ + jobject obj = (*env)->AllocObject (env, target_clazz); + jmethodID id = (*env)->FromReflectedMethod (env, constructor); + + (*env)->CallNonvirtualVoidMethod (env, obj, constr_clazz, id); + + return obj; +} Index: vm/reference/java/io/VMObjectInputStream.java =================================================================== RCS file: vm/reference/java/io/VMObjectInputStream.java diff -N vm/reference/java/io/VMObjectInputStream.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ vm/reference/java/io/VMObjectInputStream.java 16 Apr 2005 11:04:41 -0000 @@ -0,0 +1,65 @@ +/* ObjectInputStream.java -- Class used to read serialized objects + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 + 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 gnu.classpath.Configuration; +import gnu.java.io.ObjectIdentityWrapper; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Proxy; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Arrays; +import java.util.Hashtable; +import java.util.Vector; + +final class VMObjectInputStream +{ + static native ClassLoader currentClassLoader(SecurityManager sm); + + static native Object allocateObject(Class clazz, Class constr_clazz, Constructor constructor) + throws InstantiationException; +} +