GCJ and C++ (calling Java from C++)

Andrew Haley aph@redhat.com
Mon Dec 5 11:39:00 GMT 2005


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.

 > 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);

Which line?  Does the failure occur in the call to get_name?  What is
the faulting instruction?

The problem here is that we only have tiny snippets of information to
go on.

Andrew.



More information about the Java mailing list