OpenOffice and gcj at runtime
Andrew Haley
aph@redhat.com
Thu Dec 9 16:31:00 GMT 2004
Caolan McNamara writes:
> On Tue, 2004年12月07日 at 09:35 -0700, Tom Tromey wrote:
> > >>>>> "Caolan" == Caolan McNamara <caolanm@redhat.com> writes:
> >
> > Caolan> with (FC3) gcj/g++ 3.4.2 this example fails
> > Caolan> with (rawhide) gcj/g++ 3.4.3 this example fails
> > Caolan> with gcj/g++ from head (20041126) this example passes.
> >
> > With the FC2 gcj, this does something at least:
> >
> > opsy. type gcj
> > gcj is /usr/bin/gcj
> > opsy. rpm -q gcc-java
> > gcc-java-3.3.3-7
> > opsy. sh runme.gcj.sh
> > registerInterfaceA is 959e668
> > registerInterfaceB is 95b47e0
> > A: registerInterface
> > A: registerInterface
>
> > 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?
> >
>
> That's what I want all right, and forcing the example to link directly
> against libgcj.so.4 gives me the same results as you had, so libgcj.so.5
> and .6 are the culprits, while libgcj.so.4 is behaving itself.
>
> > We can fix this on some branch or another, especially since it seemed
> > to work in 3.3 (regressions get special dispensation, usually).
> > This example doesn't work in the BEA JDK :-)
>
> Excellent that its a regression :-)
>
> > Caolan> Mixing gcj from head and g++ 3.4.2 and the example fails, which is
> > Caolan> more-or-less what I was doing with OOo (started with 3.4.2 and moved to
> > Caolan> the head gcj because of the URL snafu) :-) I deserved that I guess, can
> > Caolan> hardly complain about doing something odd like that.
> >
> > Were there changes to libgcc? If not, I would actually expect this to
> > work ok. It seems to me that you wouldn't hit C++ ABI problems as the
> > JNI stuff is all inlined...
> >
> > What goes wrong?
> >
> > It would be nice to get this approach working, because most of the
> > other java stuff we're looking at (for, say, FC4) will most likely be
> > compiled with gcj4.
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.
Andrew.
2004年12月09日 Andrew Haley <aph@redhat.com>
* 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.
Index: natMethod.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/reflect/natMethod.cc,v
retrieving revision 1.36.6.1
diff -p -4 -c -r1.36.6.1 natMethod.cc
*** natMethod.cc 26 Feb 2004 15:21:11 -0000 1.36.6.1
--- natMethod.cc 9 Dec 2004 16:26:57 -0000
*************** _Jv_CallAnyMethodA (jobject obj,
*** 463,489 ****
JvFail ("Unknown ffi_call return type");
break;
}
! void *ncode;
// 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)
! {
_Jv_VTable *vtable = *(_Jv_VTable **) obj;
! ncode = vtable->get_method (meth->index);
! }
! else
! {
! ncode = meth->ncode;
}
try
{
--- 463,498 ----
JvFail ("Unknown ffi_call return type");
break;
}
! void *ncode = meth->ncode;
// 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)
! {
_Jv_VTable *vtable = *(_Jv_VTable **) obj;
! 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
{
More information about the Java
mailing list