OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [java/] [lang/] [reflect/] [natConstructor.cc] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
// natConstructor.cc - Native code for Constructor class.
2
 
3
/* Copyright (C) 1999, 2000, 2001, 2002, 2003  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
#include <java-stack.h>
16
 
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>
25
 
26
jint
27
java::lang::reflect::Constructor::getModifiers ()
28
{
29
  // Ignore all unknown flags.
30
  return _Jv_FromReflectedConstructor (this)->accflags & Modifier::ALL_FLAGS;
31
}
32
 
33
void
34
java::lang::reflect::Constructor::getType ()
35
{
36
  _Jv_GetTypesFromSignature (_Jv_FromReflectedConstructor (this),
37
                             declaringClass,
38
                             &parameter_types,
39
                             NULL);
40
 
41
  // FIXME: for now we have no way to get exception information.
42
  exception_types =
43
    (JArray<jclass> *) JvNewObjectArray (0, &java::lang::Class::class$, NULL);
44
}
45
 
46
jobject
47
java::lang::reflect::Constructor::newInstance (jobjectArray args)
48
{
49
  using namespace java::lang::reflect;
50
 
51
  if (parameter_types == NULL)
52
    getType ();
53
 
54
  jmethodID meth = _Jv_FromReflectedConstructor (this);
55
 
56
  // Check accessibility, if required.
57
  if (! (Modifier::isPublic (meth->accflags) || this->isAccessible()))
58
    {
59
      Class *caller = _Jv_StackTrace::GetCallingClass (&Constructor::class$);
60
      if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags))
61
        throw new IllegalAccessException;
62
    }
63
 
64
  if (Modifier::isAbstract (declaringClass->getModifiers()))
65
    throw new InstantiationException;
66
 
67
  _Jv_InitClass (declaringClass);
68
 
69
  // In the constructor case the return type is the type of the
70
  // constructor.
71
  return _Jv_CallAnyMethodA (NULL, declaringClass, meth, true,
72
                             parameter_types, args);
73
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.