summaryrefslogtreecommitdiff
path: root/libjava/java/lang/reflect/natConstructor.cc
blob: 1197e68c90a110edc1a04bdd7ac3eb651e757755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// natConstructor.cc - Native code for Constructor class.

/* Copyright (C) 1999, 2000  Cygnus Solutions

   This file is part of libgcj.

This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */

#include <config.h>

#include <gcj/cni.h>
#include <jvm.h>

#include <java/lang/reflect/Constructor.h>
#include <java/lang/reflect/Method.h>
#include <java/lang/reflect/InvocationTargetException.h>
#include <java/lang/reflect/Modifier.h>
#include <java/lang/InstantiationException.h>
#include <gcj/method.h>

jint
java::lang::reflect::Constructor::getModifiers ()
{
  return _Jv_FromReflectedConstructor (this)->accflags;
}

void
java::lang::reflect::Constructor::getType ()
{
  _Jv_GetTypesFromSignature (_Jv_FromReflectedConstructor (this),
			     declaringClass,
			     &parameter_types,
			     NULL);
}

jobject
java::lang::reflect::Constructor::newInstance (jobjectArray args)
{
  if (parameter_types == NULL)
    getType ();

  using namespace java::lang::reflect;
  if (Modifier::isAbstract (declaringClass->getModifiers()))
    JvThrow (new InstantiationException);

  jmethodID meth = _Jv_FromReflectedConstructor (this);
  // In the constructor case the return type is the type of the
  // constructor.
  return _Jv_CallNonvirtualMethodA (NULL, declaringClass, meth, true,
				    parameter_types, args);
}