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++)
- From: Lothar Werzinger <lothar at tradescape dot biz>
- To: java at gcc dot gnu dot org
- Date: Fri, 2 Dec 2005 17:19:49 -0800
- Subject: Re: GCJ and C++ (calling Java from C++)
- References: <200511281612.37450.lothar@tradescape.biz> <200511290933.40573.lothar@tradescape.biz> <200512011539.07910.lothar@tradescape.biz>
>From what I learned reading about CNI calling methods on interfaces requires a
special dispatch table called otable. I checked the Library and the
LibraryTest class variables in the debugger and found that the Library class
has otable = 0x0 which seems to be the culprit of the
java.lang.NullPointerException when calling a method.
Has anybody a clue why the otable for that class is NULL?
Here's a snippet of code that executes without problems:
jclass LibraryTestClass = &LibraryTest::class$;
JvInitClass(LibraryTestClass);
System::out->print(JvNewStringUTF("LibraryTest::class$.getName() =
"));
System::out->println(LibraryTestClass->getName());
System::out->print(JvNewStringUTF("p_libraryTest->getClass()->getName() =
"));
System::out->println(p_libraryTest->getClass()->getName());
Library * p_library = p_libraryTest->getlibrary();
cout << "p_library=" << hex << p_library << endl;
jclass LibraryClass = &Library::class$;
JvInitClass(LibraryClass);
System::out->print(JvNewStringUTF("Library::class$.getName() =
"));
System::out->println(LibraryClass->getName());
System::out->print(JvNewStringUTF("p_library->getClass()->getName() =
"));
System::out->println(p_library->getClass()->getName());
the failure occurs here:
String * p_name = p_library->getName();
System::out->println(p_name);
Here's the gdb output:
(gdb) p *LibraryClass
$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) p *LibraryTestClass
$2 = {<> = {<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 = 0x555e04e0, name = 0x804bf56, accflags = 33, superclass =
0x562f1de0, constants = {size = 43, tags = 0x804d360 "", data = 0x804d2a0},
methods = 0x804d200, method_count = 7, vtable_method_count = 8, fields =
0x804d1c0, size_in_bytes = 20, field_count = 4, static_field_count = 0,
vtable = 0x1e4d98, otable = 0x804d960, otable_syms = 0x804d38c, atable =
0x804d9a0, atable_syms = 0x804d434, itable = 0x804da00, itable_syms =
0x804d500,
catch_classes = 0x804d5c0, interfaces = 0x0, loader = 0x0, interface_count =
0, state = 14 '\016', thread = 0x1e7e89, depth = 1, ancestors = 0x8067fb8,
idt = 0x56224880, arrayclass = 0x0, protectionDomain = 0x0, assertion_table
= 0x804d5e0, hack_signers = 0x0, chain = 0x56335660, aux_info = 0x0,
engine = 0x5647006c}
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