2000-01-04 09:46:52 +01:00
|
|
|
// natConstructor.cc - Native code for Constructor class.
|
|
|
|
|
2002-08-28 01:57:17 +02:00
|
|
|
/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
|
2000-01-04 09:46:52 +01:00
|
|
|
|
|
|
|
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 ()
|
|
|
|
{
|
2000-07-28 01:57:07 +02:00
|
|
|
// Ignore all unknown flags.
|
|
|
|
return _Jv_FromReflectedConstructor (this)->accflags & Modifier::ALL_FLAGS;
|
2000-01-04 09:46:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
java::lang::reflect::Constructor::getType ()
|
|
|
|
{
|
|
|
|
_Jv_GetTypesFromSignature (_Jv_FromReflectedConstructor (this),
|
|
|
|
declaringClass,
|
|
|
|
¶meter_types,
|
|
|
|
NULL);
|
2001-03-22 07:37:16 +01:00
|
|
|
|
|
|
|
// FIXME: for now we have no way to get exception information.
|
|
|
|
exception_types =
|
|
|
|
(JArray<jclass> *) JvNewObjectArray (0, &java::lang::Class::class$, NULL);
|
2000-01-04 09:46:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
jobject
|
|
|
|
java::lang::reflect::Constructor::newInstance (jobjectArray args)
|
|
|
|
{
|
|
|
|
if (parameter_types == NULL)
|
|
|
|
getType ();
|
|
|
|
|
|
|
|
using namespace java::lang::reflect;
|
|
|
|
if (Modifier::isAbstract (declaringClass->getModifiers()))
|
exception.cc (java_eh_info): Make value type jthrowable.
* exception.cc (java_eh_info): Make value type jthrowable.
(_Jv_type_matcher): Remove now unneeded cast.
(_Jv_Throw): Make argument type jthrowable. Munge name
for SJLJ_EXCEPTIONS here ...
* gcj/cni.h: ... not here.
(JvThrow): Remove.
* gcj/javaprims.h (_Jv_Throw, _Jv_Sjlj_Throw): Update declarations.
* defineclass.cc, interpret.cc, jni.cc, posix-threads.cc,
prims.cc, resolve.cc, gnu/gcj/runtime/natFirstThread.cc,
gnu/gcj/xlib/natDrawable.cc, gnu/gcj/xlib/natFont.cc,
gnu/gcj/xlib/natWMSizeHints.cc, gnu/gcj/xlib/natWindowAttributes.cc,
gnu/gcj/xlib/natXImage.cc, java/io/natFile.cc,
java/io/natFileDescriptorEcos.cc, java/io/natFileDescriptorPosix.cc,
java/io/natFileDescriptorWin32.cc, java/io/natFileWin32.cc,
java/lang/natClass.cc, java/lang/natClassLoader.cc,
java/lang/natDouble.cc, java/lang/natObject.cc,
java/lang/natPosixProcess.cc, java/lang/natRuntime.cc,
java/lang/natString.cc, java/lang/natSystem.cc,
java/lang/natThread.cc, java/lang/reflect/natArray.cc,
java/lang/reflect/natConstructor.cc, java/lang/reflect/natField.cc,
java/lang/reflect/natMethod.cc, java/util/zip/natDeflater.cc,
java/util/zip/natInflater.cc:
Use throw, not JvThrow or _Jv_Throw.
From-SVN: r40838
2001-03-26 09:05:32 +02:00
|
|
|
throw new InstantiationException;
|
2000-01-04 09:46:52 +01:00
|
|
|
|
2002-08-28 01:57:17 +02:00
|
|
|
_Jv_InitClass (declaringClass);
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
jmethodID meth = _Jv_FromReflectedConstructor (this);
|
|
|
|
// In the constructor case the return type is the type of the
|
|
|
|
// constructor.
|
natConstructor.cc (newInstance): Use _Jv_CallAnyMethodA.
* java/lang/reflect/natConstructor.cc (newInstance): Use
_Jv_CallAnyMethodA.
* include/jvm.h: Declare _Jv_CallAnyMethodA.
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Renamed
from _Jv_CallNonvirtualMethodA. Changed interface; overloaded.
Include <jni.h>.
(COPY): Removed.
(invoke): Use _Jv_CallAnyMethodA.
(VAL): Redefined.
* java/lang/Class.h (Class): Declare JvGetFirstStaticField,
JvNumStaticFields, JvNumMethods, and JvGetFirstMethod as friend
functions.
(struct _Jv_Method): Added getNextMethod method.
(JvNumMethods): New function.
(JvGetFirstMethod): Likewise.
* gcj/field.h (JvGetFirstStaticField): New function.
(JvNumStaticFields): Likewise.
(getNextField): Renamed from getNextInstanceField.
(struct _Jv_Field): New method getClass.
* jni.cc: Wrote many new functions.
* include/jni.h (JNI_TRUE): Define.
(JNI_FALSE): Likewise.
(jobject, jclass, jstring, jarray, jthrowable, jobjectArray,
jbyteArray, jshortArray, jintArray, jlongArray, jbooleanArray,
jcharArray, jfloatArray, jdoubleArray): New typedefs.
(jfieldID, jmethodID): Likewise.
(JNI_COMMIT, JNI_ABORT): New defines.
(JNINativeMethod): New struct.
(struct JNINativeInterface): Correctly declared more entries.
(class _Jv_JNIEnv): Added `ex' member.
(JNI_VERSION_1_1): New define.
(JNI_VERSION_1_2): Likewise.
* boehm.cc (_Jv_MarkObj): Use getNextField, not
getNextInstanceField.
From-SVN: r31553
2000-01-22 00:50:31 +01:00
|
|
|
return _Jv_CallAnyMethodA (NULL, declaringClass, meth, true,
|
|
|
|
parameter_types, args);
|
2000-01-04 09:46:52 +01:00
|
|
|
}
|