2000-01-04 09:46:52 +01:00
|
|
|
// natConstructor.cc - Native code for Constructor class.
|
|
|
|
|
re PR libgcj/27729 (Field, Method and Constructor need isSynthetic() implemetation)
gcc/java:
PR libgcj/27729:
* jcf.h (ACC_INVISIBLE): Changed value.
libjava:
PR libgcj/27729:
* java/lang/reflect/natField.cc (getAddr): Added parens.
* java/lang/reflect/natConstructor.cc (getModifiersInternal):
Renamed. Don't mask flags.
* java/lang/reflect/Constructor.java (CONSTRUCTOR_MODIFIERS): New
constant.
(getModifiersInternal): Renamed.
(getModifiers): Rewrote.
(isSynthetic, isVarArgs): New methods.
(hashCode): Rewrote.
(addTypeParameters, toGenericString): New methods.
(getTypeParameters): Rewrote.
(getSignature): New method.
(getGenericParameterTypes, getGenericExceptionTypes): Likewise.
* java/lang/reflect/natMethod.cc (getModifiersInternal):
Renamed. Don't mask flags.
* java/lang/reflect/natField.cc (getModifiersInternal): Renamed.
Don't mask flags.
* java/lang/reflect/Modifier.java (BRIDGE, VARARGS, SYNTHETIC,
ENUM): New constants.
(INVISIBLE): Changed value.
* java/lang/reflect/Method.java: Mostly merged with Classpath.
(getModifiersInternal): Renamed.
(getModifiers): Rewrote.
(isBridge, isSynthetic, isVarArgs): New methods.
(toGenericString): Likewise.
(getTypeParameters): Likewise.
(getSignature): Likewise.
(getGenericExceptionTypes, getGenericParameterTypes,
getGenericReturnType): Likewise.
(METHOD_MODIFIERS): New constant.
* java/lang/reflect/Field.java: Mostly merged with Classpath.
Added javadoc everywhere.
(getModifiersInternal): Renamed.
(getModifiers, isSynthetic, isEnumConstant): Rewrote.
(toGenericString): New method.
(getGenericType, getSignature): Likewise.
(FIELD_MODIFIERS): New constant.
From-SVN: r114046
2006-05-24 19:21:52 +02:00
|
|
|
/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2006 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>
|
2005-03-10 20:02:21 +01:00
|
|
|
#include <java-stack.h>
|
2000-01-04 09:46:52 +01:00
|
|
|
|
2003-07-21 03:54:06 +02:00
|
|
|
#include <java/lang/ArrayIndexOutOfBoundsException.h>
|
|
|
|
#include <java/lang/IllegalAccessException.h>
|
2000-01-04 09:46:52 +01:00
|
|
|
#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>
|
|
|
|
|
2007-01-09 20:58:05 +01:00
|
|
|
typedef JArray< ::java::lang::annotation::Annotation * > * anno_a_t;
|
|
|
|
typedef JArray< JArray< ::java::lang::annotation::Annotation * > *> * anno_aa_t;
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
jint
|
re PR libgcj/27729 (Field, Method and Constructor need isSynthetic() implemetation)
gcc/java:
PR libgcj/27729:
* jcf.h (ACC_INVISIBLE): Changed value.
libjava:
PR libgcj/27729:
* java/lang/reflect/natField.cc (getAddr): Added parens.
* java/lang/reflect/natConstructor.cc (getModifiersInternal):
Renamed. Don't mask flags.
* java/lang/reflect/Constructor.java (CONSTRUCTOR_MODIFIERS): New
constant.
(getModifiersInternal): Renamed.
(getModifiers): Rewrote.
(isSynthetic, isVarArgs): New methods.
(hashCode): Rewrote.
(addTypeParameters, toGenericString): New methods.
(getTypeParameters): Rewrote.
(getSignature): New method.
(getGenericParameterTypes, getGenericExceptionTypes): Likewise.
* java/lang/reflect/natMethod.cc (getModifiersInternal):
Renamed. Don't mask flags.
* java/lang/reflect/natField.cc (getModifiersInternal): Renamed.
Don't mask flags.
* java/lang/reflect/Modifier.java (BRIDGE, VARARGS, SYNTHETIC,
ENUM): New constants.
(INVISIBLE): Changed value.
* java/lang/reflect/Method.java: Mostly merged with Classpath.
(getModifiersInternal): Renamed.
(getModifiers): Rewrote.
(isBridge, isSynthetic, isVarArgs): New methods.
(toGenericString): Likewise.
(getTypeParameters): Likewise.
(getSignature): Likewise.
(getGenericExceptionTypes, getGenericParameterTypes,
getGenericReturnType): Likewise.
(METHOD_MODIFIERS): New constant.
* java/lang/reflect/Field.java: Mostly merged with Classpath.
Added javadoc everywhere.
(getModifiersInternal): Renamed.
(getModifiers, isSynthetic, isEnumConstant): Rewrote.
(toGenericString): New method.
(getGenericType, getSignature): Likewise.
(FIELD_MODIFIERS): New constant.
From-SVN: r114046
2006-05-24 19:21:52 +02:00
|
|
|
java::lang::reflect::Constructor::getModifiersInternal ()
|
2000-01-04 09:46:52 +01:00
|
|
|
{
|
re PR libgcj/27729 (Field, Method and Constructor need isSynthetic() implemetation)
gcc/java:
PR libgcj/27729:
* jcf.h (ACC_INVISIBLE): Changed value.
libjava:
PR libgcj/27729:
* java/lang/reflect/natField.cc (getAddr): Added parens.
* java/lang/reflect/natConstructor.cc (getModifiersInternal):
Renamed. Don't mask flags.
* java/lang/reflect/Constructor.java (CONSTRUCTOR_MODIFIERS): New
constant.
(getModifiersInternal): Renamed.
(getModifiers): Rewrote.
(isSynthetic, isVarArgs): New methods.
(hashCode): Rewrote.
(addTypeParameters, toGenericString): New methods.
(getTypeParameters): Rewrote.
(getSignature): New method.
(getGenericParameterTypes, getGenericExceptionTypes): Likewise.
* java/lang/reflect/natMethod.cc (getModifiersInternal):
Renamed. Don't mask flags.
* java/lang/reflect/natField.cc (getModifiersInternal): Renamed.
Don't mask flags.
* java/lang/reflect/Modifier.java (BRIDGE, VARARGS, SYNTHETIC,
ENUM): New constants.
(INVISIBLE): Changed value.
* java/lang/reflect/Method.java: Mostly merged with Classpath.
(getModifiersInternal): Renamed.
(getModifiers): Rewrote.
(isBridge, isSynthetic, isVarArgs): New methods.
(toGenericString): Likewise.
(getTypeParameters): Likewise.
(getSignature): Likewise.
(getGenericExceptionTypes, getGenericParameterTypes,
getGenericReturnType): Likewise.
(METHOD_MODIFIERS): New constant.
* java/lang/reflect/Field.java: Mostly merged with Classpath.
Added javadoc everywhere.
(getModifiersInternal): Renamed.
(getModifiers, isSynthetic, isEnumConstant): Rewrote.
(toGenericString): New method.
(getGenericType, getSignature): Likewise.
(FIELD_MODIFIERS): New constant.
From-SVN: r114046
2006-05-24 19:21:52 +02:00
|
|
|
return _Jv_FromReflectedConstructor (this)->accflags;
|
2000-01-04 09:46:52 +01:00
|
|
|
}
|
|
|
|
|
2007-01-09 20:58:05 +01:00
|
|
|
jstring
|
|
|
|
java::lang::reflect::Constructor::getSignature()
|
|
|
|
{
|
|
|
|
return declaringClass->getReflectionSignature (this);
|
|
|
|
}
|
|
|
|
|
|
|
|
anno_a_t
|
|
|
|
java::lang::reflect::Constructor::getDeclaredAnnotationsInternal()
|
|
|
|
{
|
|
|
|
return (anno_a_t) declaringClass->getDeclaredAnnotations(this, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
anno_aa_t
|
|
|
|
java::lang::reflect::Constructor::getParameterAnnotationsInternal()
|
|
|
|
{
|
|
|
|
return (anno_aa_t) declaringClass->getDeclaredAnnotations(this, true);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2003-10-26 03:25:42 +01:00
|
|
|
using namespace java::lang::reflect;
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
if (parameter_types == NULL)
|
|
|
|
getType ();
|
|
|
|
|
2003-10-26 03:25:42 +01:00
|
|
|
jmethodID meth = _Jv_FromReflectedConstructor (this);
|
|
|
|
|
|
|
|
// Check accessibility, if required.
|
|
|
|
if (! (Modifier::isPublic (meth->accflags) || this->isAccessible()))
|
2003-07-21 03:54:06 +02:00
|
|
|
{
|
2005-03-10 20:02:21 +01:00
|
|
|
Class *caller = _Jv_StackTrace::GetCallingClass (&Constructor::class$);
|
2003-10-26 03:25:42 +01:00
|
|
|
if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags))
|
|
|
|
throw new IllegalAccessException;
|
|
|
|
}
|
2003-07-21 03:54:06 +02:00
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
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
|
|
|
// 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
|
|
|
}
|