Incorrect Java methods called from CNI
Dave Menendez
dave@sycamore.us
Thu May 13 04:11:00 GMT 2004
On Wed, 2004年05月12日 at 20:20, Bryce McKinlay wrote:
> 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.
>
Interesting problem - yes, getClassification() is indeed, defined in an
interface (actual a superinterface of the actual interface implemented
by AbstractClassificationObject).
I added the following declaration to the
AbstractClassificationModel.java file:
public abstract Classification getClassification();
Cleaned everything and tried to build again, but got the following
compiler error when compiling Classification.cpp:
In file included from
./jblocks/security/classification/Classification.h:8,
from Classification.cpp:7:
./jblocks/security/classification/AbstractClassificationModel.h:30:
error: Java method 'jblocks::security::classification::Classification*
jblocks::security::classification::AbstractClassificationModel::getClassification()' has non-Java return type `jblocks::security::classification::Classification*'
Which isn't true - the line that was added to
AbstractClassificationModel.h by gcjh was the following:
virtual ::jblocks::security::classification::Classification
*getClassification () = 0;
...and there's an appropriate forward declaration for Classification in
the extern "Java" block in the correct namespace.
More information about the Java
mailing list