This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Incorrect Java methods called from CNI


Dave Menendez wrote:

Can you do the same for AbstractClassificationModel? Looks like C++ and GCJ disagree on how many virtual methods there are in that class.


<>
Sorry for the delay - I ran into some system problems and was down for
awhile. Attached is the vtable for AbstractClassificationModel as well
as the original Java declarations, and generated C++ header.


Hmm, this is what we call the "miranda bug". I suspect what is happening is this:

getClassification() is defined in an interface. That interface is implemented by the abstract class, but the method is not actually defined there. gcj allocates a vtable slot in the abstract class for this method, so that it can be called correctly from code using invokevirtual on the abstract class. The class file on the other hand contains no mention of this extra method, and gcjh isn't smart enough to look for it. So, the .h file doesn't declare it and thus the C++ compilers idea of the vtable layout is wrong.

Work around: declare "abstract getClassification();" in the abstract class.

Fix: will be to make gcjh aware of gcj's "miranda methods" logic. Or, use the bc-abi (when its finished) which won't have this problem.

Regards

Bryce


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]