1999-04-07 16:42:40 +02:00
|
|
|
|
// natMethod.cc - Native code for Method 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) 1998, 1999, 2000, 2001 , 2002, 2003, 2004, 2005, 2006 Free Software Foundation
|
1999-04-07 16:42:40 +02: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>
|
|
|
|
|
|
1999-09-11 00:03:10 +02:00
|
|
|
|
#include <gcj/cni.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#include <jvm.h>
|
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
|
|
|
|
#include <jni.h>
|
2005-03-10 20:02:21 +01:00
|
|
|
|
#include <java-stack.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
|
|
#include <java/lang/reflect/Method.h>
|
2000-01-04 09:46:52 +01:00
|
|
|
|
#include <java/lang/reflect/Constructor.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#include <java/lang/reflect/InvocationTargetException.h>
|
|
|
|
|
#include <java/lang/reflect/Modifier.h>
|
|
|
|
|
|
|
|
|
|
#include <java/lang/Void.h>
|
|
|
|
|
#include <java/lang/Byte.h>
|
|
|
|
|
#include <java/lang/Boolean.h>
|
|
|
|
|
#include <java/lang/Character.h>
|
|
|
|
|
#include <java/lang/Short.h>
|
|
|
|
|
#include <java/lang/Integer.h>
|
|
|
|
|
#include <java/lang/Long.h>
|
|
|
|
|
#include <java/lang/Float.h>
|
|
|
|
|
#include <java/lang/Double.h>
|
2003-10-25 08:49:20 +02:00
|
|
|
|
#include <java/lang/IllegalAccessException.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#include <java/lang/IllegalArgumentException.h>
|
2004-12-17 16:13:44 +01:00
|
|
|
|
#include <java/lang/IncompatibleClassChangeError.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#include <java/lang/NullPointerException.h>
|
2003-07-21 03:54:06 +02:00
|
|
|
|
#include <java/lang/ArrayIndexOutOfBoundsException.h>
|
2003-08-18 16:36:07 +02:00
|
|
|
|
#include <java/lang/VirtualMachineError.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#include <java/lang/Class.h>
|
1999-09-11 00:03:10 +02:00
|
|
|
|
#include <gcj/method.h>
|
2000-01-04 09:46:52 +01:00
|
|
|
|
#include <gnu/gcj/RawData.h>
|
2005-04-06 00:26:26 +02:00
|
|
|
|
#include <java/lang/NoClassDefFoundError.h>
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2001-06-02 10:49:31 +02:00
|
|
|
|
#if USE_LIBFFI
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#include <ffi.h>
|
2001-06-02 10:49:31 +02:00
|
|
|
|
#else
|
|
|
|
|
#include <java/lang/UnsupportedOperationException.h>
|
|
|
|
|
#endif
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-07 16:42:40 +02:00
|
|
|
|
struct cpair
|
|
|
|
|
{
|
|
|
|
|
jclass prim;
|
|
|
|
|
jclass wrap;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// This is used to determine when a primitive widening conversion is
|
|
|
|
|
// allowed.
|
|
|
|
|
static cpair primitives[] =
|
|
|
|
|
{
|
2000-12-28 05:34:33 +01:00
|
|
|
|
#define BOOLEAN 0
|
natPlainDatagramSocketImpl.cc (BooleanClass): Removed.
* java/net/natPlainDatagramSocketImpl.cc (BooleanClass): Removed.
(IntegerClass): Likewise.
* java/lang/natClass.cc (CloneableClass): Removed.
(ObjectClass, ErrorClass, ClassClass, MethodClass, FieldClass,
ConstructorClass): Likewise.
* java/lang/natClassLoader.cc (CloneableClass): Removed.
(ObjectClass, ClassClass, VMClassLoaderClass, ClassLoaderClass,
SerializableClass): Likewise.
* java/lang/reflect/natMethod.cc (BooleanClass): Removed.
(VoidClass, ByteClass, ShortClass, CharacterClass, IntegerClass,
LongClass, FloatClass, DoubleClass): Likewise.
From-SVN: r54977
2002-06-25 07:29:22 +02:00
|
|
|
|
{ JvPrimClass (boolean), &java::lang::Boolean::class$ },
|
|
|
|
|
{ JvPrimClass (byte), &java::lang::Byte::class$ },
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#define SHORT 2
|
natPlainDatagramSocketImpl.cc (BooleanClass): Removed.
* java/net/natPlainDatagramSocketImpl.cc (BooleanClass): Removed.
(IntegerClass): Likewise.
* java/lang/natClass.cc (CloneableClass): Removed.
(ObjectClass, ErrorClass, ClassClass, MethodClass, FieldClass,
ConstructorClass): Likewise.
* java/lang/natClassLoader.cc (CloneableClass): Removed.
(ObjectClass, ClassClass, VMClassLoaderClass, ClassLoaderClass,
SerializableClass): Likewise.
* java/lang/reflect/natMethod.cc (BooleanClass): Removed.
(VoidClass, ByteClass, ShortClass, CharacterClass, IntegerClass,
LongClass, FloatClass, DoubleClass): Likewise.
From-SVN: r54977
2002-06-25 07:29:22 +02:00
|
|
|
|
{ JvPrimClass (short), &java::lang::Short::class$ },
|
1999-04-07 16:42:40 +02:00
|
|
|
|
#define CHAR 3
|
natPlainDatagramSocketImpl.cc (BooleanClass): Removed.
* java/net/natPlainDatagramSocketImpl.cc (BooleanClass): Removed.
(IntegerClass): Likewise.
* java/lang/natClass.cc (CloneableClass): Removed.
(ObjectClass, ErrorClass, ClassClass, MethodClass, FieldClass,
ConstructorClass): Likewise.
* java/lang/natClassLoader.cc (CloneableClass): Removed.
(ObjectClass, ClassClass, VMClassLoaderClass, ClassLoaderClass,
SerializableClass): Likewise.
* java/lang/reflect/natMethod.cc (BooleanClass): Removed.
(VoidClass, ByteClass, ShortClass, CharacterClass, IntegerClass,
LongClass, FloatClass, DoubleClass): Likewise.
From-SVN: r54977
2002-06-25 07:29:22 +02:00
|
|
|
|
{ JvPrimClass (char), &java::lang::Character::class$ },
|
|
|
|
|
{ JvPrimClass (int), &java::lang::Integer::class$ },
|
|
|
|
|
{ JvPrimClass (long), &java::lang::Long::class$ },
|
|
|
|
|
{ JvPrimClass (float), &java::lang::Float::class$ },
|
|
|
|
|
{ JvPrimClass (double), &java::lang::Double::class$ },
|
1999-04-07 16:42:40 +02:00
|
|
|
|
{ NULL, NULL }
|
|
|
|
|
};
|
|
|
|
|
|
2000-12-28 05:34:33 +01:00
|
|
|
|
static inline jboolean
|
1999-04-07 16:42:40 +02:00
|
|
|
|
can_widen (jclass from, jclass to)
|
|
|
|
|
{
|
|
|
|
|
int fromx = -1, tox = -1;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; primitives[i].prim; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (primitives[i].wrap == from)
|
|
|
|
|
fromx = i;
|
|
|
|
|
if (primitives[i].prim == to)
|
|
|
|
|
tox = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Can't handle a miss.
|
|
|
|
|
if (fromx == -1 || tox == -1)
|
|
|
|
|
return false;
|
2000-12-28 05:34:33 +01:00
|
|
|
|
// Boolean arguments may not be widened.
|
|
|
|
|
if (fromx == BOOLEAN && tox != BOOLEAN)
|
1999-04-07 16:42:40 +02:00
|
|
|
|
return false;
|
2001-10-02 15:44:32 +02:00
|
|
|
|
// Nothing promotes to char.
|
|
|
|
|
if (tox == CHAR && fromx != CHAR)
|
1999-04-07 16:42:40 +02:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return fromx <= tox;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-02 10:49:31 +02:00
|
|
|
|
#ifdef USE_LIBFFI
|
2000-12-28 05:34:33 +01:00
|
|
|
|
static inline ffi_type *
|
1999-04-07 16:42:40 +02:00
|
|
|
|
get_ffi_type (jclass klass)
|
|
|
|
|
{
|
|
|
|
|
// A special case.
|
|
|
|
|
if (klass == NULL)
|
|
|
|
|
return &ffi_type_pointer;
|
|
|
|
|
|
|
|
|
|
ffi_type *r;
|
|
|
|
|
if (klass == JvPrimClass (byte))
|
|
|
|
|
r = &ffi_type_sint8;
|
|
|
|
|
else if (klass == JvPrimClass (short))
|
|
|
|
|
r = &ffi_type_sint16;
|
|
|
|
|
else if (klass == JvPrimClass (int))
|
|
|
|
|
r = &ffi_type_sint32;
|
|
|
|
|
else if (klass == JvPrimClass (long))
|
|
|
|
|
r = &ffi_type_sint64;
|
|
|
|
|
else if (klass == JvPrimClass (float))
|
|
|
|
|
r = &ffi_type_float;
|
|
|
|
|
else if (klass == JvPrimClass (double))
|
|
|
|
|
r = &ffi_type_double;
|
|
|
|
|
else if (klass == JvPrimClass (boolean))
|
|
|
|
|
{
|
2000-01-05 18:23:34 +01:00
|
|
|
|
// On some platforms a bool is a byte, on others an int.
|
|
|
|
|
if (sizeof (jboolean) == sizeof (jbyte))
|
|
|
|
|
r = &ffi_type_sint8;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
JvAssert (sizeof (jboolean) == sizeof (jint));
|
|
|
|
|
r = &ffi_type_sint32;
|
|
|
|
|
}
|
1999-04-07 16:42:40 +02:00
|
|
|
|
}
|
|
|
|
|
else if (klass == JvPrimClass (char))
|
|
|
|
|
r = &ffi_type_uint16;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
JvAssert (! klass->isPrimitive());
|
|
|
|
|
r = &ffi_type_pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
2001-06-02 10:49:31 +02:00
|
|
|
|
#endif // USE_LIBFFI
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
|
|
jobject
|
2000-01-04 09:46:52 +01:00
|
|
|
|
java::lang::reflect::Method::invoke (jobject obj, jobjectArray args)
|
1999-04-07 16:42:40 +02:00
|
|
|
|
{
|
2003-10-25 08:49:20 +02:00
|
|
|
|
using namespace java::lang::reflect;
|
2004-04-14 19:45:20 +02:00
|
|
|
|
jclass iface = NULL;
|
2003-10-25 08:49:20 +02:00
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
|
if (parameter_types == NULL)
|
|
|
|
|
getType ();
|
2003-10-25 08:49:20 +02:00
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
|
jmethodID meth = _Jv_FromReflectedMethod (this);
|
2004-04-14 19:45:20 +02:00
|
|
|
|
|
2003-10-26 03:25:42 +01:00
|
|
|
|
if (Modifier::isStatic(meth->accflags))
|
2002-08-28 01:57:17 +02:00
|
|
|
|
{
|
|
|
|
|
// We have to initialize a static class. It is safe to do this
|
|
|
|
|
// here and not in _Jv_CallAnyMethodA because JNI initializes a
|
|
|
|
|
// class whenever a method lookup is done.
|
|
|
|
|
_Jv_InitClass (declaringClass);
|
2003-10-26 03:25:42 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-11-25 04:47:08 +01:00
|
|
|
|
jclass objClass = JV_CLASS (obj);
|
2005-09-06 18:01:31 +02:00
|
|
|
|
if (! _Jv_IsAssignableFrom (objClass, declaringClass))
|
2003-10-26 03:25:42 +01:00
|
|
|
|
throw new java::lang::IllegalArgumentException;
|
2002-08-28 01:57:17 +02:00
|
|
|
|
}
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
2003-10-25 08:49:20 +02:00
|
|
|
|
// Check accessibility, if required.
|
2007-04-16 15:44:59 +02:00
|
|
|
|
if (! this->isAccessible())
|
2003-10-25 08:49:20 +02:00
|
|
|
|
{
|
2007-04-16 15:44:59 +02:00
|
|
|
|
if (! (Modifier::isPublic (meth->accflags)))
|
|
|
|
|
{
|
|
|
|
|
Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$);
|
|
|
|
|
if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags))
|
|
|
|
|
throw new IllegalAccessException;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// Method is public, check to see if class is accessible.
|
|
|
|
|
{
|
|
|
|
|
jint flags = (declaringClass->accflags
|
|
|
|
|
& (Modifier::PUBLIC
|
|
|
|
|
| Modifier::PROTECTED
|
|
|
|
|
| Modifier::PRIVATE));
|
|
|
|
|
if (flags == 0) // i.e. class is package private
|
|
|
|
|
{
|
|
|
|
|
Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$);
|
|
|
|
|
if (! _Jv_ClassNameSamePackage (caller->name,
|
|
|
|
|
declaringClass->name))
|
|
|
|
|
throw new IllegalAccessException;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-25 08:49:20 +02:00
|
|
|
|
}
|
2003-07-21 03:54:06 +02:00
|
|
|
|
|
2004-04-14 19:45:20 +02:00
|
|
|
|
if (declaringClass->isInterface())
|
|
|
|
|
iface = declaringClass;
|
2007-04-16 15:44:59 +02:00
|
|
|
|
|
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 (obj, return_type, meth, false,
|
2004-04-14 19:45:20 +02:00
|
|
|
|
parameter_types, args, iface);
|
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::Method::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_FromReflectedMethod (this)->accflags;
|
2000-01-04 09:46:52 +01:00
|
|
|
|
}
|
|
|
|
|
|
2007-01-09 20:58:05 +01:00
|
|
|
|
jstring
|
|
|
|
|
java::lang::reflect::Method::getSignature()
|
|
|
|
|
{
|
|
|
|
|
return declaringClass->getReflectionSignature (this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jobject
|
|
|
|
|
java::lang::reflect::Method::getDefaultValue()
|
|
|
|
|
{
|
|
|
|
|
return declaringClass->getMethodDefaultValue(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
anno_a_t
|
|
|
|
|
java::lang::reflect::Method::getDeclaredAnnotationsInternal()
|
|
|
|
|
{
|
|
|
|
|
return (anno_a_t) declaringClass->getDeclaredAnnotations(this, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
anno_aa_t
|
|
|
|
|
java::lang::reflect::Method::getParameterAnnotationsInternal()
|
|
|
|
|
{
|
|
|
|
|
return (anno_aa_t) declaringClass->getDeclaredAnnotations(this, true);
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
|
jstring
|
|
|
|
|
java::lang::reflect::Method::getName ()
|
|
|
|
|
{
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
name = _Jv_NewStringUtf8Const (_Jv_FromReflectedMethod (this)->name);
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Internal method to set return_type and parameter_types fields. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
java::lang::reflect::Method::getType ()
|
|
|
|
|
{
|
2001-08-24 19:24:44 +02:00
|
|
|
|
_Jv_Method *method = _Jv_FromReflectedMethod (this);
|
|
|
|
|
_Jv_GetTypesFromSignature (method,
|
2000-01-04 09:46:52 +01:00
|
|
|
|
declaringClass,
|
|
|
|
|
¶meter_types,
|
|
|
|
|
&return_type);
|
2000-08-08 05:34:51 +02:00
|
|
|
|
|
2001-08-24 19:24:44 +02:00
|
|
|
|
int count = 0;
|
|
|
|
|
if (method->throws != NULL)
|
|
|
|
|
{
|
|
|
|
|
while (method->throws[count] != NULL)
|
|
|
|
|
++count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exception_types
|
2002-11-02 22:33:30 +01:00
|
|
|
|
= (JArray<jclass> *) JvNewObjectArray (count, &java::lang::Class::class$,
|
2001-08-24 19:24:44 +02:00
|
|
|
|
NULL);
|
|
|
|
|
jclass *elts = elements (exception_types);
|
|
|
|
|
for (int i = 0; i < count; ++i)
|
2002-11-02 22:33:30 +01:00
|
|
|
|
elts[i] = _Jv_FindClass (method->throws[i],
|
2003-07-21 03:54:06 +02:00
|
|
|
|
declaringClass->getClassLoaderInternal ());
|
2000-01-04 09:46:52 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_Jv_GetTypesFromSignature (jmethodID method,
|
|
|
|
|
jclass declaringClass,
|
|
|
|
|
JArray<jclass> **arg_types_out,
|
|
|
|
|
jclass *return_type_out)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
_Jv_Utf8Const* sig = method->signature;
|
2003-07-21 03:54:06 +02:00
|
|
|
|
java::lang::ClassLoader *loader = declaringClass->getClassLoaderInternal();
|
2004-08-12 08:53:42 +02:00
|
|
|
|
char *ptr = sig->chars();
|
2000-01-04 09:46:52 +01:00
|
|
|
|
int numArgs = 0;
|
|
|
|
|
/* First just count the number of parameters. */
|
2005-04-06 00:26:26 +02:00
|
|
|
|
// FIXME: should do some validation here, e.g., that there is only
|
|
|
|
|
// one return type.
|
2000-01-04 09:46:52 +01:00
|
|
|
|
for (; ; ptr++)
|
|
|
|
|
{
|
|
|
|
|
switch (*ptr)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
case ')':
|
|
|
|
|
case 'V':
|
|
|
|
|
break;
|
|
|
|
|
case '[':
|
|
|
|
|
case '(':
|
|
|
|
|
continue;
|
|
|
|
|
case 'B':
|
|
|
|
|
case 'C':
|
|
|
|
|
case 'D':
|
|
|
|
|
case 'F':
|
|
|
|
|
case 'S':
|
|
|
|
|
case 'I':
|
|
|
|
|
case 'J':
|
|
|
|
|
case 'Z':
|
|
|
|
|
numArgs++;
|
|
|
|
|
continue;
|
|
|
|
|
case 'L':
|
|
|
|
|
numArgs++;
|
|
|
|
|
do
|
|
|
|
|
ptr++;
|
|
|
|
|
while (*ptr != ';' && ptr[1] != '\0');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JArray<jclass> *args = (JArray<jclass> *)
|
2001-08-24 19:24:44 +02:00
|
|
|
|
JvNewObjectArray (numArgs, &java::lang::Class::class$, NULL);
|
2000-01-04 09:46:52 +01:00
|
|
|
|
jclass* argPtr = elements (args);
|
2004-08-12 08:53:42 +02:00
|
|
|
|
for (ptr = sig->chars(); *ptr != '\0'; ptr++)
|
2000-01-04 09:46:52 +01:00
|
|
|
|
{
|
2005-04-06 00:26:26 +02:00
|
|
|
|
if (*ptr == '(')
|
|
|
|
|
continue;
|
|
|
|
|
if (*ptr == ')')
|
2000-01-04 09:46:52 +01:00
|
|
|
|
{
|
|
|
|
|
argPtr = return_type_out;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-06 00:26:26 +02:00
|
|
|
|
char *end_ptr;
|
|
|
|
|
jclass type = _Jv_FindClassFromSignature (ptr, loader, &end_ptr);
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
// FIXME: This isn't ideal.
|
|
|
|
|
throw new java::lang::NoClassDefFoundError (sig->toString());
|
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
|
// ARGPTR can be NULL if we are processing the return value of a
|
|
|
|
|
// call from Constructor.
|
|
|
|
|
if (argPtr)
|
|
|
|
|
*argPtr++ = type;
|
2005-04-06 00:26:26 +02:00
|
|
|
|
|
|
|
|
|
ptr = end_ptr;
|
2000-01-04 09:46:52 +01:00
|
|
|
|
}
|
|
|
|
|
*arg_types_out = args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is a very rough analog of the JNI CallNonvirtual<type>MethodA
|
|
|
|
|
// functions. It handles both Methods and Constructors, and it can
|
|
|
|
|
// handle any return type. In the Constructor case, the `obj'
|
|
|
|
|
// argument is unused and should be NULL; also, the `return_type' is
|
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
|
|
|
|
// the class that the constructor will construct. RESULT is a pointer
|
|
|
|
|
// to a `jvalue' (see jni.h); for a void method this should be NULL.
|
|
|
|
|
// This function returns an exception (if one was thrown), or NULL if
|
|
|
|
|
// the call went ok.
|
2003-08-18 16:36:07 +02:00
|
|
|
|
void
|
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
|
|
|
|
_Jv_CallAnyMethodA (jobject obj,
|
|
|
|
|
jclass return_type,
|
|
|
|
|
jmethodID meth,
|
|
|
|
|
jboolean is_constructor,
|
2003-10-26 03:25:42 +01:00
|
|
|
|
jboolean is_virtual_call,
|
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
|
|
|
|
JArray<jclass> *parameter_types,
|
Import GNU Classpath (libgcj-import-20070727).
libjava/
2007-08-04 Matthias Klose <doko@ubuntu.com>
Import GNU Classpath (libgcj-import-20070727).
* Regenerate class and header files.
* Regenerate auto* files.
* include/jvm.h:
* jni-libjvm.cc (Jv_JNI_InvokeFunctions): Rename type.
* jni.cc (_Jv_JNIFunctions, _Jv_JNI_InvokeFunctions): Likewise.
* jni.cc (_Jv_JNI_CallAnyMethodA, _Jv_JNI_CallAnyVoidMethodA,
_Jv_JNI_CallMethodA, _Jv_JNI_CallVoidMethodA,
_Jv_JNI_CallStaticMethodA, _Jv_JNI_CallStaticVoidMethodA,
_Jv_JNI_NewObjectA, _Jv_JNI_SetPrimitiveArrayRegion): Constify
jvalue parameter.
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Likewise.
* java/lang/VMFloat.java (toString, parseFloat): New.
* gnu/awt/xlib/XToolkit.java (setAlwaysOnTop, isModalityTypeSupported,
isModalExclusionTypeSupported): New (stub only).
* gnu/awt/xlib/XCanvasPeer.java (requestFocus): Likewise.
* gnu/awt/xlib/XFramePeer.java (updateMinimumSize, updateIconImages,
updateFocusableWindowState, setModalBlocked, getBoundsPrivate,
setAlwaysOnTop): Likewise.
* gnu/awt/xlib/XFontPeer.java (canDisplay): Update signature.
* scripts/makemake.tcl: Ignore gnu/javax/sound/sampled/gstreamer,
ignore javax.sound.sampled.spi.MixerProvider, ignore .in files.
* HACKING: Mention --enable-gstreamer-peer, removal of generated files.
libjava/classpath/
2007-08-04 Matthias Klose <doko@ubuntu.com>
* java/util/EnumMap.java (clone): Add cast.
From-SVN: r127204
2007-08-04 12:53:49 +02:00
|
|
|
|
const jvalue *args,
|
2003-08-18 16:36:07 +02:00
|
|
|
|
jvalue *result,
|
2004-04-14 19:45:20 +02:00
|
|
|
|
jboolean is_jni_call,
|
|
|
|
|
jclass iface)
|
2000-01-04 09:46:52 +01:00
|
|
|
|
{
|
2003-10-30 22:09:45 +01:00
|
|
|
|
using namespace java::lang::reflect;
|
|
|
|
|
|
2001-06-02 10:49:31 +02:00
|
|
|
|
#ifdef USE_LIBFFI
|
2000-01-04 09:46:52 +01:00
|
|
|
|
JvAssert (! is_constructor || ! obj);
|
2000-11-16 22:34:48 +01:00
|
|
|
|
JvAssert (! is_constructor || return_type);
|
2000-01-04 09:46:52 +01:00
|
|
|
|
|
|
|
|
|
// See whether call needs an object as the first argument. A
|
|
|
|
|
// constructor does need a `this' argument, but it is one we create.
|
|
|
|
|
jboolean needs_this = false;
|
|
|
|
|
if (is_constructor
|
2003-10-30 22:09:45 +01:00
|
|
|
|
|| ! Modifier::isStatic(meth->accflags))
|
2000-01-04 09:46:52 +01:00
|
|
|
|
needs_this = true;
|
|
|
|
|
|
|
|
|
|
int param_count = parameter_types->length;
|
|
|
|
|
if (needs_this)
|
|
|
|
|
++param_count;
|
|
|
|
|
|
2000-01-05 18:23:34 +01:00
|
|
|
|
ffi_type *rtype;
|
|
|
|
|
// A constructor itself always returns void.
|
|
|
|
|
if (is_constructor || return_type == JvPrimClass (void))
|
|
|
|
|
rtype = &ffi_type_void;
|
|
|
|
|
else
|
|
|
|
|
rtype = get_ffi_type (return_type);
|
2002-01-08 21:00:50 +01:00
|
|
|
|
ffi_type **argtypes = (ffi_type **) __builtin_alloca (param_count
|
|
|
|
|
* sizeof (ffi_type *));
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
|
jclass *paramelts = elements (parameter_types);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
|
// Special case for the `this' argument of a constructor. Note that
|
|
|
|
|
// the JDK 1.2 docs specify that the new object must be allocated
|
|
|
|
|
// before argument conversions are done.
|
|
|
|
|
if (is_constructor)
|
2004-04-20 03:38:46 +02:00
|
|
|
|
obj = _Jv_AllocObject (return_type);
|
2000-01-04 09:46:52 +01:00
|
|
|
|
|
2003-02-28 18:26:29 +01:00
|
|
|
|
const int size_per_arg = sizeof(jvalue);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
ffi_cif cif;
|
|
|
|
|
|
2003-02-28 18:26:29 +01:00
|
|
|
|
char *p = (char *) __builtin_alloca (param_count * size_per_arg);
|
|
|
|
|
// Overallocate to get correct alignment.
|
|
|
|
|
void **values = (void **)
|
|
|
|
|
__builtin_alloca (param_count * sizeof (void *));
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
2003-02-28 18:26:29 +01:00
|
|
|
|
int i = 0;
|
2000-01-04 09:46:52 +01:00
|
|
|
|
if (needs_this)
|
|
|
|
|
{
|
2003-02-28 18:26:29 +01:00
|
|
|
|
// The `NULL' type is `Object'.
|
|
|
|
|
argtypes[i] = get_ffi_type (NULL);
|
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
|
|
|
|
values[i] = p;
|
|
|
|
|
memcpy (p, &obj, sizeof (jobject));
|
2003-02-28 18:26:29 +01:00
|
|
|
|
p += size_per_arg;
|
2000-01-04 09:46:52 +01:00
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-06 01:56:21 +01:00
|
|
|
|
for (int arg = 0; i < param_count; ++i, ++arg)
|
1999-04-07 16:42:40 +02:00
|
|
|
|
{
|
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
|
|
|
|
int tsize;
|
2003-02-28 18:26:29 +01:00
|
|
|
|
|
|
|
|
|
argtypes[i] = get_ffi_type (paramelts[arg]);
|
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
|
|
|
|
if (paramelts[arg]->isPrimitive())
|
|
|
|
|
tsize = paramelts[arg]->size();
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else
|
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
|
|
|
|
tsize = sizeof (jobject);
|
|
|
|
|
|
|
|
|
|
// Copy appropriate bits from the jvalue into the ffi array.
|
|
|
|
|
// FIXME: we could do this copying all in one loop, above, by
|
|
|
|
|
// over-allocating a bit.
|
2003-02-28 18:26:29 +01:00
|
|
|
|
// How do we do this without breaking big-endian platforms?
|
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
|
|
|
|
values[i] = p;
|
|
|
|
|
memcpy (p, &args[arg], tsize);
|
2003-02-28 18:26:29 +01:00
|
|
|
|
p += size_per_arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, param_count,
|
|
|
|
|
rtype, argtypes) != FFI_OK)
|
2003-08-18 16:36:07 +02:00
|
|
|
|
throw new java::lang::VirtualMachineError(JvNewStringLatin1("internal error: ffi_prep_cif failed"));
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
2000-01-04 09:46:52 +01:00
|
|
|
|
using namespace java::lang;
|
|
|
|
|
using namespace java::lang::reflect;
|
2000-03-02 21:25:20 +01:00
|
|
|
|
|
2002-02-24 18:55:44 +01:00
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
ffi_arg i;
|
2002-03-01 06:36:31 +01:00
|
|
|
|
jobject o;
|
2002-02-24 18:55:44 +01:00
|
|
|
|
jlong l;
|
|
|
|
|
jfloat f;
|
|
|
|
|
jdouble d;
|
|
|
|
|
} ffi_result;
|
|
|
|
|
|
2003-08-18 16:36:07 +02:00
|
|
|
|
switch (rtype->type)
|
|
|
|
|
{
|
|
|
|
|
case FFI_TYPE_VOID:
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT8:
|
|
|
|
|
result->b = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT16:
|
|
|
|
|
result->s = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_UINT16:
|
|
|
|
|
result->c = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT32:
|
|
|
|
|
result->i = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT64:
|
|
|
|
|
result->j = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_FLOAT:
|
|
|
|
|
result->f = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_DOUBLE:
|
|
|
|
|
result->d = 0;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_POINTER:
|
|
|
|
|
result->l = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
JvFail ("Unknown ffi_call return type");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-26 03:25:42 +01:00
|
|
|
|
void *ncode;
|
|
|
|
|
|
2004-02-26 16:22:20 +01:00
|
|
|
|
// FIXME: If a vtable index is -1 at this point it is invalid, so we
|
|
|
|
|
// have to use the ncode.
|
|
|
|
|
//
|
|
|
|
|
// This can happen because methods in final classes don't have
|
|
|
|
|
// vtable entries, but _Jv_isVirtualMethod() doesn't know that. We
|
|
|
|
|
// could solve this problem by allocating a vtable index for methods
|
|
|
|
|
// in final classes.
|
|
|
|
|
if (is_virtual_call
|
|
|
|
|
&& ! Modifier::isFinal (meth->accflags)
|
|
|
|
|
&& (_Jv_ushort)-1 != meth->index)
|
2003-10-26 03:25:42 +01:00
|
|
|
|
{
|
|
|
|
|
_Jv_VTable *vtable = *(_Jv_VTable **) obj;
|
2004-04-14 19:45:20 +02:00
|
|
|
|
if (iface == NULL)
|
2004-12-17 16:13:44 +01:00
|
|
|
|
{
|
|
|
|
|
if (is_jni_call && Modifier::isAbstract (meth->accflags))
|
|
|
|
|
{
|
|
|
|
|
// With JNI we don't know if this is an interface call
|
|
|
|
|
// or a call to an abstract method. Look up the method
|
|
|
|
|
// by name, the slow way.
|
|
|
|
|
_Jv_Method *concrete_meth
|
|
|
|
|
= _Jv_LookupDeclaredMethod (vtable->clas,
|
|
|
|
|
meth->name,
|
|
|
|
|
meth->signature,
|
|
|
|
|
NULL);
|
|
|
|
|
if (concrete_meth == NULL
|
|
|
|
|
|| concrete_meth->ncode == NULL
|
|
|
|
|
|| Modifier::isAbstract(concrete_meth->accflags))
|
|
|
|
|
throw new java::lang::IncompatibleClassChangeError
|
2005-02-17 20:17:08 +01:00
|
|
|
|
(_Jv_GetMethodString (vtable->clas, meth));
|
2004-12-17 16:13:44 +01:00
|
|
|
|
ncode = concrete_meth->ncode;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ncode = vtable->get_method (meth->index);
|
|
|
|
|
}
|
2004-04-14 19:45:20 +02:00
|
|
|
|
else
|
2004-09-22 00:23:46 +02:00
|
|
|
|
ncode = _Jv_LookupInterfaceMethodIdx (vtable->clas, iface,
|
|
|
|
|
meth->index);
|
2003-10-26 03:25:42 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ncode = meth->ncode;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-02 21:25:20 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
2003-10-26 03:25:42 +01:00
|
|
|
|
ffi_call (&cif, (void (*)()) ncode, &ffi_result, values);
|
2000-03-02 21:25:20 +01:00
|
|
|
|
}
|
2003-08-18 16:36:07 +02:00
|
|
|
|
catch (Throwable *ex)
|
2000-03-02 21:25:20 +01:00
|
|
|
|
{
|
2003-08-18 16:36:07 +02:00
|
|
|
|
// For JNI we just throw the real error. For reflection, we
|
|
|
|
|
// wrap the underlying method's exception in an
|
|
|
|
|
// InvocationTargetException.
|
|
|
|
|
if (! is_jni_call)
|
|
|
|
|
ex = new InvocationTargetException (ex);
|
|
|
|
|
throw ex;
|
2000-03-02 21:25:20 +01:00
|
|
|
|
}
|
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
|
|
|
|
|
2002-02-24 18:55:44 +01:00
|
|
|
|
// Since ffi_call returns integer values promoted to a word, use
|
|
|
|
|
// a narrowing conversion for jbyte, jchar, etc. results.
|
|
|
|
|
// Note that boolean is handled either by the FFI_TYPE_SINT8 or
|
|
|
|
|
// FFI_TYPE_SINT32 case.
|
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
|
|
|
|
if (is_constructor)
|
|
|
|
|
result->l = obj;
|
2002-03-01 06:36:31 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (rtype->type)
|
|
|
|
|
{
|
|
|
|
|
case FFI_TYPE_VOID:
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT8:
|
|
|
|
|
result->b = (jbyte)ffi_result.i;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT16:
|
|
|
|
|
result->s = (jshort)ffi_result.i;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_UINT16:
|
|
|
|
|
result->c = (jchar)ffi_result.i;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT32:
|
|
|
|
|
result->i = (jint)ffi_result.i;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_SINT64:
|
|
|
|
|
result->j = (jlong)ffi_result.l;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_FLOAT:
|
|
|
|
|
result->f = (jfloat)ffi_result.f;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_DOUBLE:
|
|
|
|
|
result->d = (jdouble)ffi_result.d;
|
|
|
|
|
break;
|
|
|
|
|
case FFI_TYPE_POINTER:
|
|
|
|
|
result->l = (jobject)ffi_result.o;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
JvFail ("Unknown ffi_call return type");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-06-02 10:49:31 +02:00
|
|
|
|
#else
|
2003-08-18 16:36:07 +02:00
|
|
|
|
throw new java::lang::UnsupportedOperationException(JvNewStringLatin1("reflection not available in this build"));
|
2001-06-02 10:49:31 +02:00
|
|
|
|
#endif // USE_LIBFFI
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This is another version of _Jv_CallAnyMethodA, but this one does
|
|
|
|
|
// more checking and is used by the reflection (and not JNI) code.
|
|
|
|
|
jobject
|
|
|
|
|
_Jv_CallAnyMethodA (jobject obj,
|
|
|
|
|
jclass return_type,
|
|
|
|
|
jmethodID meth,
|
|
|
|
|
jboolean is_constructor,
|
|
|
|
|
JArray<jclass> *parameter_types,
|
2004-04-14 19:45:20 +02:00
|
|
|
|
jobjectArray args,
|
|
|
|
|
jclass iface)
|
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
|
|
|
|
{
|
2000-09-06 23:20:45 +02:00
|
|
|
|
if (parameter_types->length == 0 && args == NULL)
|
|
|
|
|
{
|
|
|
|
|
// The JDK accepts this, so we do too.
|
|
|
|
|
}
|
|
|
|
|
else if (parameter_types->length != args->length)
|
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 java::lang::IllegalArgumentException;
|
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
|
|
|
|
|
|
|
|
|
int param_count = parameter_types->length;
|
|
|
|
|
|
|
|
|
|
jclass *paramelts = elements (parameter_types);
|
2000-09-06 23:20:45 +02:00
|
|
|
|
jobject *argelts = args == NULL ? NULL : elements (args);
|
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
|
|
|
|
jvalue argvals[param_count];
|
|
|
|
|
|
|
|
|
|
#define COPY(Where, What, Type) \
|
|
|
|
|
do { \
|
|
|
|
|
Type val = (What); \
|
|
|
|
|
memcpy ((Where), &val, sizeof (Type)); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < param_count; ++i)
|
|
|
|
|
{
|
|
|
|
|
jclass k = argelts[i] ? argelts[i]->getClass() : NULL;
|
|
|
|
|
if (paramelts[i]->isPrimitive())
|
|
|
|
|
{
|
|
|
|
|
if (! argelts[i]
|
|
|
|
|
|| ! k
|
|
|
|
|
|| ! can_widen (k, paramelts[i]))
|
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 java::lang::IllegalArgumentException;
|
2000-12-28 05:34:33 +01:00
|
|
|
|
|
|
|
|
|
if (paramelts[i] == JvPrimClass (boolean))
|
|
|
|
|
COPY (&argvals[i],
|
|
|
|
|
((java::lang::Boolean *) argelts[i])->booleanValue(),
|
|
|
|
|
jboolean);
|
|
|
|
|
else if (paramelts[i] == JvPrimClass (char))
|
|
|
|
|
COPY (&argvals[i],
|
|
|
|
|
((java::lang::Character *) argelts[i])->charValue(),
|
|
|
|
|
jchar);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
java::lang::Number *num = (java::lang::Number *) argelts[i];
|
|
|
|
|
if (paramelts[i] == JvPrimClass (byte))
|
|
|
|
|
COPY (&argvals[i], num->byteValue(), jbyte);
|
|
|
|
|
else if (paramelts[i] == JvPrimClass (short))
|
|
|
|
|
COPY (&argvals[i], num->shortValue(), jshort);
|
|
|
|
|
else if (paramelts[i] == JvPrimClass (int))
|
|
|
|
|
COPY (&argvals[i], num->intValue(), jint);
|
|
|
|
|
else if (paramelts[i] == JvPrimClass (long))
|
|
|
|
|
COPY (&argvals[i], num->longValue(), jlong);
|
|
|
|
|
else if (paramelts[i] == JvPrimClass (float))
|
|
|
|
|
COPY (&argvals[i], num->floatValue(), jfloat);
|
|
|
|
|
else if (paramelts[i] == JvPrimClass (double))
|
|
|
|
|
COPY (&argvals[i], num->doubleValue(), jdouble);
|
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (argelts[i] && ! paramelts[i]->isAssignableFrom (k))
|
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 java::lang::IllegalArgumentException;
|
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
|
|
|
|
COPY (&argvals[i], argelts[i], jobject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jvalue ret_value;
|
2003-08-18 16:36:07 +02:00
|
|
|
|
_Jv_CallAnyMethodA (obj, return_type, meth, is_constructor,
|
2003-10-26 03:25:42 +01:00
|
|
|
|
_Jv_isVirtualMethod (meth),
|
2003-08-18 16:36:07 +02:00
|
|
|
|
parameter_types, argvals, &ret_value,
|
2004-04-14 19:45:20 +02:00
|
|
|
|
false, iface);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
|
|
|
|
|
jobject r;
|
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
|
|
|
|
#define VAL(Wrapper, Field) (new Wrapper (ret_value.Field))
|
2000-01-05 18:23:34 +01:00
|
|
|
|
if (is_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
|
|
|
|
r = ret_value.l;
|
|
|
|
|
else if (return_type == JvPrimClass (byte))
|
|
|
|
|
r = VAL (java::lang::Byte, b);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (short))
|
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
|
|
|
|
r = VAL (java::lang::Short, s);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (int))
|
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
|
|
|
|
r = VAL (java::lang::Integer, i);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (long))
|
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
|
|
|
|
r = VAL (java::lang::Long, j);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (float))
|
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
|
|
|
|
r = VAL (java::lang::Float, f);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (double))
|
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
|
|
|
|
r = VAL (java::lang::Double, d);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (boolean))
|
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
|
|
|
|
r = VAL (java::lang::Boolean, z);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (char))
|
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
|
|
|
|
r = VAL (java::lang::Character, c);
|
1999-04-07 16:42:40 +02:00
|
|
|
|
else if (return_type == JvPrimClass (void))
|
|
|
|
|
r = NULL;
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-01-04 09:46:52 +01:00
|
|
|
|
JvAssert (return_type == NULL || ! return_type->isPrimitive());
|
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
|
|
|
|
r = ret_value.l;
|
1999-04-07 16:42:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|