1 // natConstructor.cc - Native code for Constructor class.
3 /* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2006 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
15 #include <java-stack.h>
17 #include <java/lang/ArrayIndexOutOfBoundsException.h>
18 #include <java/lang/IllegalAccessException.h>
19 #include <java/lang/reflect/Constructor.h>
20 #include <java/lang/reflect/Method.h>
21 #include <java/lang/reflect/InvocationTargetException.h>
22 #include <java/lang/reflect/Modifier.h>
23 #include <java/lang/InstantiationException.h>
24 #include <gcj/method.h>
26 typedef JArray
< ::java::lang::annotation::Annotation
* > * anno_a_t
;
27 typedef JArray
< JArray
< ::java::lang::annotation::Annotation
* > *> * anno_aa_t
;
30 java::lang::reflect::Constructor::getModifiersInternal ()
32 return _Jv_FromReflectedConstructor (this)->accflags
;
36 java::lang::reflect::Constructor::getSignature()
38 return declaringClass
->getReflectionSignature (this);
42 java::lang::reflect::Constructor::getDeclaredAnnotationsInternal()
45 return (anno_a_t
) declaringClass
->getDeclaredAnnotations(this, false);
49 java::lang::reflect::Constructor::getParameterAnnotationsInternal()
52 return (anno_aa_t
) declaringClass
->getDeclaredAnnotations(this, true);
56 java::lang::reflect::Constructor::getType ()
58 _Jv_GetTypesFromSignature (_Jv_FromReflectedConstructor (this),
63 // FIXME: for now we have no way to get exception information.
65 (JArray
<jclass
> *) JvNewObjectArray (0, &java::lang::Class::class$
, NULL
);
69 java::lang::reflect::Constructor::newInstance (jobjectArray args
)
71 using namespace java::lang::reflect
;
73 if (parameter_types
== NULL
)
76 jmethodID meth
= _Jv_FromReflectedConstructor (this);
78 // Check accessibility, if required.
79 if (! (Modifier::isPublic (meth
->accflags
) || this->isAccessible()))
81 Class
*caller
= _Jv_StackTrace::GetCallingClass (&Constructor::class$
);
82 if (! _Jv_CheckAccess(caller
, declaringClass
, meth
->accflags
))
83 throw new IllegalAccessException
;
86 if (Modifier::isAbstract (declaringClass
->getModifiers()))
87 throw new InstantiationException
;
89 _Jv_InitClass (declaringClass
);
91 // In the constructor case the return type is the type of the
93 return _Jv_CallAnyMethodA (NULL
, declaringClass
, meth
, true,
94 parameter_types
, args
);