1 // natObjectInputStream.cc - Native part of ObjectInputStream class.
3 /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
5 This ObjectInputStream is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the ObjectInputStream "LIBGCJ_LICENSE" for
16 #include <java/io/ObjectInputStream$GetField.h>
17 #include <java/io/ObjectInputStream.h>
18 #include <java/io/IOException.h>
19 #include <java/lang/Class.h>
20 #include <java/lang/reflect/Modifier.h>
21 #include <java/lang/reflect/Method.h>
24 #include <java/lang/System.h>
25 #include <java/io/PrintStream.h>
29 java::io::ObjectInputStream::allocateObject (jclass klass)
32 using namespace java::lang::reflect;
36 JvAssert (klass && ! klass->isArray ());
37 if (klass->isInterface() || Modifier::isAbstract(klass->getModifiers()))
41 obj = _Jv_AllocObject (klass);
54 java::io::ObjectInputStream::callConstructor (jclass klass, jobject obj)
56 jstring init_name = JvNewStringLatin1 ("<init>");
57 // This is a bit inefficient, and a bit of a hack, since we don't
58 // actually use the Method and since what is returned isn't
59 // technically a Method. We can't use Method.invoke as it looks up
60 // the declared method.
61 JArray<jclass> *arg_types
62 = (JArray<jclass> *) JvNewObjectArray (0, &java::lang::Class::class$,
64 java::lang::reflect::Method *m = klass->getPrivateMethod (init_name,
66 // We lie about this being a constructor. If we put `true' here
67 // then _Jv_CallAnyMethodA would try to allocate the object for us.
68 jmethodID meth = (jmethodID) ((char *) (klass->methods)
70 _Jv_CallAnyMethodA (obj, JvPrimClass (void), meth, false, arg_types, NULL);