diff options
Diffstat (limited to 'libjava/java/lang/reflect')
-rw-r--r-- | libjava/java/lang/reflect/Method.java | 26 | ||||
-rw-r--r-- | libjava/java/lang/reflect/natMethod.cc | 39 |
2 files changed, 15 insertions, 50 deletions
diff --git a/libjava/java/lang/reflect/Method.java b/libjava/java/lang/reflect/Method.java index edca309..e95ca0d 100644 --- a/libjava/java/lang/reflect/Method.java +++ b/libjava/java/lang/reflect/Method.java @@ -1,6 +1,6 @@ // Method.java - Represent method of class or interface. -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -68,30 +68,6 @@ public final class Method extends AccessibleObject implements Member return name.hashCode() + declaringClass.getName().hashCode(); } - // This is used to perform an actual method call via ffi. - private static final native void hack_call (RawData cif, - RawData method, - RawData ret_value, - RawData values); - - // Perform an ffi call while capturing exceptions. We have to do - // this because we can't catch Java exceptions from C++. - static final Throwable hack_trampoline (RawData cif, - RawData method, - RawData ret_value, - RawData values) - { - try - { - hack_call (cif, method, ret_value, values); - } - catch (Throwable x) - { - return x; - } - return null; - } - public native Object invoke (Object obj, Object[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException; diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc index 988fa1e..c4482ee 100644 --- a/libjava/java/lang/reflect/natMethod.cc +++ b/libjava/java/lang/reflect/natMethod.cc @@ -152,21 +152,6 @@ get_ffi_type (jclass klass) return r; } -// Actually perform an FFI call. -void -java::lang::reflect::Method::hack_call (gnu::gcj::RawData *rcif, - gnu::gcj::RawData *rmethod, - gnu::gcj::RawData *rret_value, - gnu::gcj::RawData *rvalues) -{ - ffi_cif *cif = (ffi_cif *) rcif; - void (*method) (...) = (void (*) (...)) rmethod; - void *ret_value = (void *) rret_value; - void **values = (void **) rvalues; - - ffi_call (cif, method, ret_value, values); -} - jobject java::lang::reflect::Method::invoke (jobject obj, jobjectArray args) { @@ -419,19 +404,23 @@ _Jv_CallAnyMethodA (jobject obj, // FIXME: initialize class here. - java::lang::Throwable *ex; using namespace java::lang; using namespace java::lang::reflect; - ex = Method::hack_trampoline ((gnu::gcj::RawData *) &cif, - (gnu::gcj::RawData *) meth->ncode, - (gnu::gcj::RawData *) result, - (gnu::gcj::RawData *) values); - if (ex) - // FIXME: this is wrong for JNI. But if we just return the - // exception, then the non-JNI cases won't be able to distinguish - // it from exceptions we might generate ourselves. Sigh. - ex = new InvocationTargetException (ex); + Throwable *ex = NULL; + + try + { + ffi_call (&cif, (void (*) (...)) meth->ncode, result, values); + } + catch (Throwable *ex2) + { + // FIXME: this is wrong for JNI. But if we just return the + // exception, then the non-JNI cases won't be able to + // distinguish it from exceptions we might generate ourselves. + // Sigh. + ex = new InvocationTargetException (ex2); + } if (is_constructor) result->l = obj; |