OpenOffice and gcj at runtime
Andrew Haley
aph@redhat.com
Fri Dec 10 13:35:00 GMT 2004
Bryce McKinlay writes:
> Andrew Haley wrote:
>
> > > On Tue, 2004年12月07日 at 09:35 -0700, Tom Tromey wrote:
> >
> > > > Some versions of gcj did have a bug when calling an interface method
> > > > via JNI. Is that what you're running into? Do you get a
> > > > NullPointerException or something?
> >
> >This is also broken with CVS HEAD.
> >
> >I suggest this patch. The idea is pretty simple: if we have no method
> >index, and no code pointer, look the method up by name.
> >
> >
> In what cases do we not have a method index? In general the index for an
> interface method should not be -1. see:
> _Jv_Linker::layout_interface_methods(). It sounds like a bug if you are
> seeing -1 values at runtime.
This is 3.4.3, which didn't do that.
> Presumably, the bug being seen here is gcc.gnu.org/PR15001 ? This is a
> serious regression that must be fixed for 4.0, even if the fix results
> in a (temporary) performance regression, eg: disabling fast interface
> dispatch for reflection. We'll have to come up with something better for
> 4.1, though.
It can be done by looking up the method by name -- the performance
regression is that abstract methods result in a run-time lookup. It
might be worth caching _Jv_LookupDeclaredMethod to speed up this path.
Andrew.
2004年12月10日 Andrew Haley <aph@redhat.com>
PR java/15001
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Look up
abstract methods by name.
Index: java/lang/reflect/natMethod.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/reflect/natMethod.cc,v
retrieving revision 1.42
diff -p -2 -c -r1.42 natMethod.cc
*** java/lang/reflect/natMethod.cc 25 Nov 2004 03:47:05 -0000 1.42
--- java/lang/reflect/natMethod.cc 10 Dec 2004 13:32:55 -0000
*************** details. */
*** 31,34 ****
--- 31,35 ----
#include <java/lang/IllegalAccessException.h>
#include <java/lang/IllegalArgumentException.h>
+ #include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/NullPointerException.h>
#include <java/lang/ArrayIndexOutOfBoundsException.h>
*************** _Jv_CallAnyMethodA (jobject obj,
*** 481,485 ****
_Jv_VTable *vtable = *(_Jv_VTable **) obj;
if (iface == NULL)
! ncode = vtable->get_method (meth->index);
else
ncode = _Jv_LookupInterfaceMethodIdx (vtable->clas, iface,
--- 482,506 ----
_Jv_VTable *vtable = *(_Jv_VTable **) obj;
if (iface == NULL)
! {
! 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
! (_Jv_GetMethodString (vtable->clas, meth->name));
! ncode = concrete_meth->ncode;
! }
! else
! ncode = vtable->get_method (meth->index);
! }
else
ncode = _Jv_LookupInterfaceMethodIdx (vtable->clas, iface,
More information about the Java
mailing list