This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: GCJ and C++ (calling Java from C++)
On Monday 05 December 2005 03:39, Andrew Haley wrote:
> Lothar Werzinger writes:
> >From what I learned reading about CNI calling methods on interfaces
> >requires a special dispatch table called otable.
>
> I don't think so. As far as I'm aware the otable is only ever
> involved when a file has been compiled with -findirect dispatch. CNI
> doesn't use indirect dispatch. Without indirect dispatch, we'd expect
> the otable to be null.
The jar and the Java file are compiled with -findirect-dispatch, so I think
having a null otable is bad. You should be able to see that in the build.xml
in the project I sent you last time.
> Which line? Does the failure occur in the call to get_name?
As said in previous postings it fails either in
JvInitClass(LibraryTestClass);
or in
String * p_name = p_library->getName();
if I comment out the JvInitClass. If I do comment it out I get the following
console ouput from some println's I do in the code:
[exec] LibraryTest::class$.getName() = test.LibraryTest
[exec] p_libraryTest->getClass()->getName() = test.LibraryTest
[exec] Library::class$.getName() =
org.eclipse.emf.examples.extlibrary.Library
[exec] p_library->getClass()->getName() =
org.eclipse.emf.examples.extlibrary.impl.LibraryImpl
The LibraryImpl is the class that implements the Library interface.
> What is the faulting instruction?
>
> The problem here is that we only have tiny snippets of information to
> go on.
As for the faulting instruction, what ezactly do you want me to do to find
that? Send you the asm again? GDB output - if you tell me which commands to
execute in gdb I would be happy to do that. Please tell me exactly how I can
help you finding the problem. I can also send you the full tar again if you
want to try to reproduce it by yourself.
Again here's the exception if it fails in JvInitClass:
[exec] Unhandled Java exception:
[exec] java.lang.LinkageError: unexpected exception during linking:
org.eclipse.emf.examples.extlibrary.Library
[exec] at java.lang.VMClassLoader.transformException(java.lang.Class,
java.lang.Throwable)
(/opt2/linux/ix86/lib/gcc/x86_64-pc-linux-gnu/4.0.2/32/libgcj.so.6.0.0)
[exec] at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/opt2/linux/ix86/lib/gcc/x86_64-pc-linux-gnu/4.0.2/32/libgcj.so.6.0.0)
[exec] at java.lang.Class.initializeClass()
(/opt2/linux/ix86/lib/gcc/x86_64-pc-linux-gnu/4.0.2/32/libgcj.so.6.0.0)
[exec] at .JvInitClass(java.lang.Class)
(/opt2/linux/ix86/lib/gcc/x86_64-pc-linux-gnu/4.0.2/include/c++/gcj/cni.h:31)
[exec] at .main
(/home/lothar/workspace/org.eclipse.emf.examples.library.edit/cpp/librarytest/main.cpp:136)
[exec] at .__libc_start_main (/lib/tls/libc-2.3.5.so)
[exec] Caused by: java.lang.NullPointerException
[exec] at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/opt2/linux/ix86/lib/gcc/x86_64-pc-linux-gnu/4.0.2/32/libgcj.so.6.0.0)
[exec] ...4 more
here's the gdb output for that:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1450252512 (LWP 16169)]
0x55bb2402 in _Jv_Linker::verify_class (klass=0x804d6e0) at link.cc:1573
1573 klass->engine->verify(klass);
(gdb) p *klass
$1 = {<> = {<No data fields>}, static class$ = {<> = {<No data fields>},
static class$ = <same as static member of an already seen type>,
next_or_version = 0x5626ff40, name = 0x56045276, accflags = 17,
superclass = 0x562f1de0, constants = {size = 8, tags = 0x562e8728 "",
data = 0x562f5480}, methods = 0x562f2080, method_count = 53,
vtable_method_count = 41, fields = 0x0, size_in_bytes = 140,
field_count = 0, static_field_count = 0, vtable = 0x562f24c8,
otable = 0x0, otable_syms = 0x0, atable = 0x0, atable_syms = 0x0,
itable = 0x0, itable_syms = 0x0, catch_classes = 0x562e8710,
interfaces = 0x562f206c, loader = 0x0, interface_count = 1,
state = 14 '\016', thread = 0x1, depth = 1, ancestors = 0x804f0e0,
idt = 0x804f0f0, arrayclass = 0x454c0, protectionDomain = 0x0,
assertion_table = 0x0, hack_signers = 0x0, chain = 0x562efc40,
aux_info = 0x0, engine = 0x5647006c}, next_or_version = 0x80061a80,
name = 0x555c70fa, accflags = 1537, superclass = 0x0, constants = {size = 3,
tags = 0x555d48a4 "", data = 0x555d649c}, methods = 0x555d63c0,
method_count = 11, vtable_method_count = -1, fields = 0x0,
size_in_bytes = 4, field_count = 0, static_field_count = 0, vtable = 0x0,
otable = 0x0, otable_syms = 0x0, atable = 0x0, atable_syms = 0x0,
itable = 0x0, itable_syms = 0x0, catch_classes = 0x555d48a8,
interfaces = 0x555d48a0, loader = 0x0, interface_count = 1, state = 7 '\a',
thread = 0x1e7e88, depth = 0, ancestors = 0x0, idt = 0x0, arrayclass = 0x0,
protectionDomain = 0x0, assertion_table = 0x0, hack_signers = 0x0,
chain = 0x0, aux_info = 0x0, engine = 0x0}
(gdb) disassemble
Dump of assembler code for function
_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE:
0x55bb23f0 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+0>: push
%ebp
0x55bb23f1 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+1>: mov
%esp,%ebp
0x55bb23f3 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+3>: sub
$0x8,%esp
0x55bb23f6 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+6>: mov
0x8(%ebp),%eax
0x55bb23f9 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+9>: mov
0x88(%eax),%edx
0x55bb23ff <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+15>: mov
%eax,(%esp)
0x55bb2402 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+18>: call
*0x8(%edx)
0x55bb2405 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+21>: leave
0x55bb2406 <_ZN10_Jv_Linker12verify_classEPN4java4lang5ClassE+22>: ret
End of assembler dump.
and here if it fails in getName()
[exec] Unhandled Java exception:
[exec] java.lang.NullPointerException
[exec] at .main
(/home/lothar/workspace/org.eclipse.emf.examples.library.edit/cpp/librarytest/main.cpp:136)
[exec] at .__libc_start_main (/lib/tls/libc-2.3.5.so)
here's the gdb output for that:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1450252512 (LWP 16839)]
0x55bd9d42 in _Jv_LookupInterfaceMethodIdx (klass=0x0, iface=0x0,
method_idx=1)
at natClass.cc:995
995 _Jv_IDispatchTable *cldt = klass->idt;
(gdb) p klass
$1 = 0x0
> Andrew.
Please tell me detailed what I can do to assist you in finding the problem. If
you want, I can also send you the full tar again so that you can reproduce it
by yourself.
Thanks in advance!
Lothar
--
Lothar Werzinger Dipl.-Ing. Univ.
framework & platform architect
Tradescape Inc.
111 West St. John Street, Suite 200
San Jose, Ca 95113
email: lothar@tradescape.biz