natVMProxy.cc (run_proxy): Use _Jv_LookupProxyMethod to find the Method.
2007-04-02 Andrew Haley <aph@redhat.com> * java/lang/reflect/natVMProxy.cc (run_proxy): Use _Jv_LookupProxyMethod to find the Method. If parameter_types->length == 0, pass a null paramameter list, not a zero-length parameter list. * java/lang/natClass.cc (_Jv_LookupProxyMethod): New function. * java/lang/Class.h (_Jv_LookupProxyMethod): Declare. From-SVN: r123431
This commit is contained in:
parent
e6c45b1e34
commit
a0036853d2
@ -1,3 +1,12 @@
|
|||||||
|
2007-04-02 Andrew Haley <aph@redhat.com>
|
||||||
|
|
||||||
|
* java/lang/reflect/natVMProxy.cc (run_proxy): Use
|
||||||
|
_Jv_LookupProxyMethod to find the Method.
|
||||||
|
If parameter_types->length == 0, pass a null paramameter list,
|
||||||
|
not a zero-length parameter list.
|
||||||
|
* java/lang/natClass.cc (_Jv_LookupProxyMethod): New function.
|
||||||
|
* java/lang/Class.h (_Jv_LookupProxyMethod): Declare.
|
||||||
|
|
||||||
2007-04-02 Kyle Galloway <kgallowa@redhat.com>
|
2007-04-02 Kyle Galloway <kgallowa@redhat.com>
|
||||||
|
|
||||||
* interpret-run.cc: Add code to properly set up variable slots
|
* interpret-run.cc: Add code to properly set up variable slots
|
||||||
|
@ -57,11 +57,13 @@ class java/lang/reflect/Method
|
|||||||
prepend jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
|
prepend jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
|
||||||
prepend jobject _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID, jboolean);
|
prepend jobject _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID, jboolean);
|
||||||
prepend ::java::lang::reflect::Method *_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
prepend ::java::lang::reflect::Method *_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
||||||
|
prepend ::java::lang::reflect::Method *_Jv_LookupProxyMethod (jclass, _Jv_Utf8Const *, _Jv_Utf8Const *);
|
||||||
friend jmethodID (::_Jv_FromReflectedMethod) (java::lang::reflect::Method *);
|
friend jmethodID (::_Jv_FromReflectedMethod) (java::lang::reflect::Method *);
|
||||||
friend jobject (::_Jv_JNI_ToReflectedMethod) (_Jv_JNIEnv *, jclass, jmethodID, jboolean);
|
friend jobject (::_Jv_JNI_ToReflectedMethod) (_Jv_JNIEnv *, jclass, jmethodID, jboolean);
|
||||||
friend class java::lang::Class;
|
friend class java::lang::Class;
|
||||||
friend class java::io::ObjectInputStream;
|
friend class java::io::ObjectInputStream;
|
||||||
friend java::lang::reflect::Method* ::_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
friend java::lang::reflect::Method* ::_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
||||||
|
friend java::lang::reflect::Method* ::_Jv_LookupProxyMethod (jclass, _Jv_Utf8Const *, _Jv_Utf8Const *);
|
||||||
|
|
||||||
class gnu/gcj/runtime/ExtensionClassLoader
|
class gnu/gcj/runtime/ExtensionClassLoader
|
||||||
friend class ::java::lang::ClassLoader;
|
friend class ::java::lang::ClassLoader;
|
||||||
|
@ -237,6 +237,8 @@ _Jv_Method* _Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
|
|||||||
java::lang::reflect::Method *_Jv_GetReflectedMethod (jclass klass,
|
java::lang::reflect::Method *_Jv_GetReflectedMethod (jclass klass,
|
||||||
_Jv_Utf8Const *name,
|
_Jv_Utf8Const *name,
|
||||||
_Jv_Utf8Const *signature);
|
_Jv_Utf8Const *signature);
|
||||||
|
java::lang::reflect::Method *_Jv_LookupProxyMethod (jclass, _Jv_Utf8Const *,
|
||||||
|
_Jv_Utf8Const *);
|
||||||
jfieldID JvGetFirstInstanceField (jclass);
|
jfieldID JvGetFirstInstanceField (jclass);
|
||||||
jint JvNumInstanceFields (jclass);
|
jint JvNumInstanceFields (jclass);
|
||||||
jfieldID JvGetFirstStaticField (jclass);
|
jfieldID JvGetFirstStaticField (jclass);
|
||||||
@ -545,6 +547,9 @@ private:
|
|||||||
friend java::lang::reflect::Method* ::_Jv_GetReflectedMethod (jclass klass,
|
friend java::lang::reflect::Method* ::_Jv_GetReflectedMethod (jclass klass,
|
||||||
_Jv_Utf8Const *name,
|
_Jv_Utf8Const *name,
|
||||||
_Jv_Utf8Const *signature);
|
_Jv_Utf8Const *signature);
|
||||||
|
friend java::lang::reflect::Method *::_Jv_LookupProxyMethod (jclass, _Jv_Utf8Const *,
|
||||||
|
_Jv_Utf8Const *);
|
||||||
|
|
||||||
friend jfieldID (::JvGetFirstInstanceField) (jclass);
|
friend jfieldID (::JvGetFirstInstanceField) (jclass);
|
||||||
friend jint (::JvNumInstanceFields) (jclass);
|
friend jint (::JvNumInstanceFields) (jclass);
|
||||||
friend jfieldID (::JvGetFirstStaticField) (jclass);
|
friend jfieldID (::JvGetFirstStaticField) (jclass);
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
VMCompiler();
|
VMCompiler();
|
||||||
static ::java::lang::Class * loadSharedLibrary(::java::lang::ClassLoader *, ::java::lang::String *, ::java::security::ProtectionDomain *, ::java::lang::String *);
|
static ::java::lang::Class * loadSharedLibrary(::java::lang::ClassLoader *, ::java::lang::String *, ::java::security::ProtectionDomain *, ::java::lang::String *);
|
||||||
|
static ::java::lang::String * bytesToString(JArray< jbyte > *);
|
||||||
public:
|
public:
|
||||||
static ::java::lang::Class * compileClass(::java::lang::ClassLoader *, ::java::lang::String *, JArray< jbyte > *, jint, jint, ::java::security::ProtectionDomain *);
|
static ::java::lang::Class * compileClass(::java::lang::ClassLoader *, ::java::lang::String *, JArray< jbyte > *, jint, jint, ::java::security::ProtectionDomain *);
|
||||||
static jboolean compileClass(::java::lang::Class *);
|
static jboolean compileClass(::java::lang::Class *);
|
||||||
|
@ -29,6 +29,7 @@ details. */
|
|||||||
#include <java/lang/reflect/Member.h>
|
#include <java/lang/reflect/Member.h>
|
||||||
#include <java/lang/reflect/Method.h>
|
#include <java/lang/reflect/Method.h>
|
||||||
#include <java/lang/reflect/Field.h>
|
#include <java/lang/reflect/Field.h>
|
||||||
|
#include <java/lang/reflect/Proxy.h>
|
||||||
#include <java/lang/reflect/Constructor.h>
|
#include <java/lang/reflect/Constructor.h>
|
||||||
#include <java/lang/AbstractMethodError.h>
|
#include <java/lang/AbstractMethodError.h>
|
||||||
#include <java/lang/ArrayStoreException.h>
|
#include <java/lang/ArrayStoreException.h>
|
||||||
@ -1652,6 +1653,39 @@ _Jv_LookupDeclaredMethod (jclass klass, _Jv_Utf8Const *name,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The rules for finding proxy methods are different: first we search
|
||||||
|
// the interfaces implemented by a proxy, then the methods declared in
|
||||||
|
// class Proxy.
|
||||||
|
|
||||||
|
java::lang::reflect::Method *
|
||||||
|
_Jv_LookupProxyMethod (jclass proxyClass, _Jv_Utf8Const *name,
|
||||||
|
_Jv_Utf8Const *signature)
|
||||||
|
{
|
||||||
|
using namespace java::lang::reflect;
|
||||||
|
jclass declaringClass;
|
||||||
|
_Jv_Method * m;
|
||||||
|
|
||||||
|
for (int i = 0; i < proxyClass->interface_count; i++)
|
||||||
|
{
|
||||||
|
declaringClass = proxyClass->interfaces[i];
|
||||||
|
m = _Jv_GetMethodLocal (declaringClass, name, signature);
|
||||||
|
if (m)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!m)
|
||||||
|
m = _Jv_LookupDeclaredMethod (&Proxy::class$,
|
||||||
|
name,
|
||||||
|
signature,
|
||||||
|
&declaringClass);
|
||||||
|
|
||||||
|
Method *rmethod = new Method ();
|
||||||
|
rmethod->offset = (char*) m - (char*) declaringClass->methods;
|
||||||
|
rmethod->declaringClass = declaringClass;
|
||||||
|
return rmethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
java::lang::reflect::Method *
|
java::lang::reflect::Method *
|
||||||
_Jv_GetReflectedMethod (jclass klass, _Jv_Utf8Const *name,
|
_Jv_GetReflectedMethod (jclass klass, _Jv_Utf8Const *name,
|
||||||
_Jv_Utf8Const *signature)
|
_Jv_Utf8Const *signature)
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
|
jmethodID _Jv_FromReflectedMethod (java::lang::reflect::Method *);
|
||||||
jobject _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID, jboolean);
|
jobject _Jv_JNI_ToReflectedMethod (_Jv_JNIEnv *, jclass, jmethodID, jboolean);
|
||||||
::java::lang::reflect::Method *_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
::java::lang::reflect::Method *_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
||||||
|
::java::lang::reflect::Method *_Jv_LookupProxyMethod (jclass, _Jv_Utf8Const *, _Jv_Utf8Const *);
|
||||||
|
|
||||||
class java::lang::reflect::Method : public ::java::lang::reflect::AccessibleObject
|
class java::lang::reflect::Method : public ::java::lang::reflect::AccessibleObject
|
||||||
{
|
{
|
||||||
@ -79,6 +80,7 @@ public:
|
|||||||
friend class java::lang::Class;
|
friend class java::lang::Class;
|
||||||
friend class java::io::ObjectInputStream;
|
friend class java::io::ObjectInputStream;
|
||||||
friend java::lang::reflect::Method* ::_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
friend java::lang::reflect::Method* ::_Jv_GetReflectedMethod (jclass, _Jv_Utf8Const*, _Jv_Utf8Const*);
|
||||||
|
friend java::lang::reflect::Method* ::_Jv_LookupProxyMethod (jclass, _Jv_Utf8Const *, _Jv_Utf8Const *);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __java_lang_reflect_Method__
|
#endif // __java_lang_reflect_Method__
|
||||||
|
@ -301,6 +301,8 @@ run_proxy (ffi_cif *cif,
|
|||||||
void **args,
|
void **args,
|
||||||
void*user_data)
|
void*user_data)
|
||||||
{
|
{
|
||||||
|
using namespace java::lang::reflect;
|
||||||
|
|
||||||
Proxy *proxy = *(Proxy**)args[0];
|
Proxy *proxy = *(Proxy**)args[0];
|
||||||
ncode_closure *self = (ncode_closure *) user_data;
|
ncode_closure *self = (ncode_closure *) user_data;
|
||||||
|
|
||||||
@ -312,17 +314,22 @@ run_proxy (ffi_cif *cif,
|
|||||||
Thread *thread = Thread::currentThread();
|
Thread *thread = Thread::currentThread();
|
||||||
_Jv_InterpFrame frame_desc (self->self, thread, proxy->getClass());
|
_Jv_InterpFrame frame_desc (self->self, thread, proxy->getClass());
|
||||||
|
|
||||||
Method *meth = _Jv_GetReflectedMethod (proxy->getClass(),
|
Method *meth = _Jv_LookupProxyMethod (proxy->getClass(),
|
||||||
self->self->name,
|
self->self->name,
|
||||||
self->self->signature);
|
self->self->signature);
|
||||||
JArray<jclass> *parameter_types = meth->internalGetParameterTypes ();
|
JArray<jclass> *parameter_types = meth->internalGetParameterTypes ();
|
||||||
JArray<jclass> *exception_types = meth->internalGetExceptionTypes ();
|
JArray<jclass> *exception_types = meth->internalGetExceptionTypes ();
|
||||||
|
|
||||||
InvocationHandler *handler = proxy->h;
|
InvocationHandler *handler = proxy->h;
|
||||||
void *poo
|
JArray<jobject> *argsArray = NULL;
|
||||||
= _Jv_NewObjectArray (parameter_types->length, &Object::class$, NULL);
|
jobject *jargs = NULL;
|
||||||
JArray<jobject> *argsArray = (JArray<jobject> *) poo;
|
if (parameter_types->length)
|
||||||
jobject *jargs = elements(argsArray);
|
{
|
||||||
|
void *poo
|
||||||
|
= _Jv_NewObjectArray (parameter_types->length, &Object::class$, NULL);
|
||||||
|
argsArray = (JArray<jobject> *) poo;
|
||||||
|
jargs = elements(argsArray);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: It must be possible to use fast interface dispatch here,
|
// FIXME: It must be possible to use fast interface dispatch here,
|
||||||
// but I've not quite figured out how to do it.
|
// but I've not quite figured out how to do it.
|
||||||
|
Loading…
Reference in New Issue
Block a user