From b971a1d46024bc94ee4ce40624ee30e905849527 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 17 Jan 2005 20:57:04 +0000 Subject: [PATCH] [multiple changes] 2005-01-17 Andrew Haley * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): In the case of virtual dispatch, if we have no method index, and no code pointer, look a method up by name. 2005-01-17 Tom Tromey * testsuite/libjava.jni/iface.c: New file. * testsuite/libjava.jni/iface.out: New file. * testsuite/libjava.jni/iface.java: New file. From-SVN: r93776 --- libjava/ChangeLog | 12 ++++++++++ libjava/java/lang/reflect/natMethod.cc | 31 +++++++++++++++++--------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 2068e78c2970..c6137a8dae14 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,15 @@ +2005-01-17 Andrew Haley + + * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): In the case + of virtual dispatch, if we have no method index, and no code + pointer, look a method up by name. + +2005-01-17 Tom Tromey + + * testsuite/libjava.jni/iface.c: New file. + * testsuite/libjava.jni/iface.out: New file. + * testsuite/libjava.jni/iface.java: New file. + 2004-12-06 Tom Tromey For PR java/14853: diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc index 736103b63dd5..4ff2c9596ae8 100644 --- a/libjava/java/lang/reflect/natMethod.cc +++ b/libjava/java/lang/reflect/natMethod.cc @@ -1,6 +1,6 @@ // natMethod.cc - Native code for Method class. -/* Copyright (C) 1998, 1999, 2000, 2001 , 2002, 2003 Free Software Foundation +/* Copyright (C) 1998, 1999, 2000, 2001 , 2002, 2003, 2005 Free Software Foundation This file is part of libgcj. @@ -464,7 +464,7 @@ _Jv_CallAnyMethodA (jobject obj, break; } - void *ncode; + void *ncode = meth->ncode; // FIXME: If a vtable index is -1 at this point it is invalid, so we // have to use the ncode. @@ -473,16 +473,25 @@ _Jv_CallAnyMethodA (jobject obj, // 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) - { + if (is_virtual_call) + { _Jv_VTable *vtable = *(_Jv_VTable **) obj; - ncode = vtable->get_method (meth->index); - } - else - { - ncode = meth->ncode; + if ((_Jv_ushort)-1 == meth->index) + { + if (ncode == NULL) + // We have no vtable index, and we have no code pointer. + // Look method up by name. + ncode = _Jv_LookupInterfaceMethod (vtable->clas, + meth->name, + meth->signature); + } + else + { + // We have an index. If METH is not final, use virtual + // dispatch. + if (! Modifier::isFinal (meth->accflags)) + ncode = vtable->get_method (meth->index); + } } try -- 2.47.2