| 1 | // natConstructor.cc - Native code for Constructor class.
|
|---|
| 2 |
|
|---|
| 3 | /* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
|
|---|
| 4 |
|
|---|
| 5 | This file is part of libgcj.
|
|---|
| 6 |
|
|---|
| 7 | This software is copyrighted work licensed under the terms of the
|
|---|
| 8 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|---|
| 9 | details. */
|
|---|
| 10 |
|
|---|
| 11 | #include <config.h>
|
|---|
| 12 |
|
|---|
| 13 | #include <gcj/cni.h>
|
|---|
| 14 | #include <jvm.h>
|
|---|
| 15 |
|
|---|
| 16 | #include <java/lang/reflect/Constructor.h>
|
|---|
| 17 | #include <java/lang/reflect/Method.h>
|
|---|
| 18 | #include <java/lang/reflect/InvocationTargetException.h>
|
|---|
| 19 | #include <java/lang/reflect/Modifier.h>
|
|---|
| 20 | #include <java/lang/InstantiationException.h>
|
|---|
| 21 | #include <gcj/method.h>
|
|---|
| 22 |
|
|---|
| 23 | jint
|
|---|
| 24 | java::lang::reflect::Constructor::getModifiers ()
|
|---|
| 25 | {
|
|---|
| 26 | // Ignore all unknown flags.
|
|---|
| 27 | return _Jv_FromReflectedConstructor (this)->accflags & Modifier::ALL_FLAGS;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | void
|
|---|
| 31 | java::lang::reflect::Constructor::getType ()
|
|---|
| 32 | {
|
|---|
| 33 | _Jv_GetTypesFromSignature (_Jv_FromReflectedConstructor (this),
|
|---|
| 34 | declaringClass,
|
|---|
| 35 | ¶meter_types,
|
|---|
| 36 | NULL);
|
|---|
| 37 |
|
|---|
| 38 | // FIXME: for now we have no way to get exception information.
|
|---|
| 39 | exception_types =
|
|---|
| 40 | (JArray<jclass> *) JvNewObjectArray (0, &java::lang::Class::class$, NULL);
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | jobject
|
|---|
| 44 | java::lang::reflect::Constructor::newInstance (jobjectArray args)
|
|---|
| 45 | {
|
|---|
| 46 | if (parameter_types == NULL)
|
|---|
| 47 | getType ();
|
|---|
| 48 |
|
|---|
| 49 | using namespace java::lang::reflect;
|
|---|
| 50 | if (Modifier::isAbstract (declaringClass->getModifiers()))
|
|---|
| 51 | throw new InstantiationException;
|
|---|
| 52 |
|
|---|
| 53 | _Jv_InitClass (declaringClass);
|
|---|
| 54 |
|
|---|
| 55 | jmethodID meth = _Jv_FromReflectedConstructor (this);
|
|---|
| 56 | // In the constructor case the return type is the type of the
|
|---|
| 57 | // constructor.
|
|---|
| 58 | return _Jv_CallAnyMethodA (NULL, declaringClass, meth, true,
|
|---|
| 59 | parameter_types, args);
|
|---|
| 60 | }
|
|---|