Any JNI/UNO bridge experts around? Some assumptions about field ids are apparently not valid for Dalvik
Tor Lillqvist
tml at iki.fi
Fri Mar 23 08:59:09 PDT 2012
After some lengthy experimentation with test programs (which is
something I love to do, honestly) (even if the slow iteration cycle on
Android is a bit irrtating), the root cause to my problem seems pretty
obvious. The concept of field ID in "normal" JVMs and in Android's
Dalvik appears to be quite different.
In normal JVMs, a field id is a small integer, in no way unique. If
two classes both have a field with a certain name and no other
fields, the id of that field is the same for both classes. The field
id of Context in com.sun.star.uno.Exception and in
com.sun.star.uno.RuntimeException are the same.
In Dalvik, field ids are basically pointers to some internal
structure. And they indeed seem to be unique for each field in each
class.
So it is quite obvious that what the code apparently tries to do doesn't work.
In the IDL and C++, css::uno::Exception has a Context field.
css::uno::RuntimeException is a subclass of css::uno::Exception with
no fields of its own, it inherits Exception's Context field.
But the corresponding Java UNO types, in ridl.jar, have a different
relationship.
com.sun.star.uno.RuntimeException extends java.lang.RuntimeException
and has a Context field, and com.sun.star.uno.Exception extends
java.lang.Exception and has its own Context field.
Hmm. OK, I think I get it, Java's RuntimeException (and the subclasses
of that) has significantly different semantics than that of its
Exception (and subclasses), unchecked vs. checked. The intent is that
the UNO exceptions be similarly divided when viewed on the Java side.
Presumably that can not be changed.
--tml
More information about the LibreOffice
mailing list