source: trunk/gcc/libjava/java/io/natObjectInputStream.cc

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1// natObjectInputStream.cc - Native part of ObjectInputStream class.
2
3/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
4
5 This ObjectInputStream is part of libgcj.
6
7This software is copyrighted work licensed under the terms of the
8Libgcj License. Please consult the ObjectInputStream "LIBGCJ_LICENSE" for
9details. */
10
11#include <config.h>
12
13#include <gcj/cni.h>
14#include <jvm.h>
15
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>
22
23#ifdef DEBUG
24#include <java/lang/System.h>
25#include <java/io/PrintStream.h>
26#endif
27
28jobject
29java::io::ObjectInputStream::allocateObject (jclass klass)
30{
31 jobject obj = NULL;
32 using namespace java::lang::reflect;
33
34 try
35 {
36 JvAssert (klass && ! klass->isArray ());
37 if (klass->isInterface() || Modifier::isAbstract(klass->getModifiers()))
38 obj = NULL;
39 else
40 {
41 obj = JvAllocObject (klass);
42 }
43 }
44 catch (jthrowable t)
45 {
46 return NULL;
47 }
48
49 return obj;
50}
51
52
53void
54java::io::ObjectInputStream::callConstructor (jclass klass, jobject obj)
55{
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$,
63 NULL);
64 java::lang::reflect::Method *m = klass->getPrivateMethod (init_name,
65 arg_types);
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)
69 + m->offset);
70 _Jv_CallAnyMethodA (obj, JvPrimClass (void), meth, false, arg_types, NULL);
71}
Note: See TracBrowser for help on using the repository browser.