Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Well, that assumption would hold for any of the Sun/IBM derived VM's, but I can certainly see how Dalvik might be doing something different in that case.

It might be safer and simpler to add a getContext() method to com.sun.star.uno.Exception and then look that up and access it.
That has a higher chance of using the same methodID for both classes.

On 2012-03-23 14:44, Tor Lillqvist wrote:
It seems that the code assumes the field id for the "Context" field in
com.sun.star.uno.Exception is also valid for that field in
com.sun.star.uno.RuntimeException. This apparently holds for "normal"
JVMs, but not Dalvik? I am still digging into what is actually going
on, need to write some minimal test programs, but just wanted to ask
about this already now in case somebody immediately can think of
something like "yeah, I remember back in 2001 when we discussed
whether that is safe" ;)

I added some debugging output to the JNI_compound_type_info
constructor in bridges/sources/jni_uno/jni_info.cxx, where it calls
GetFieldId for the Exception and RuntimeException types to see what
the returned field ids are:

diff --git a/bridges/source/jni_uno/jni_info.cxx
b/bridges/source/jni_uno/jni_info.cxx
index a5ed28a..8e15979 100644
--- a/bridges/source/jni_uno/jni_info.cxx
+++ b/bridges/source/jni_uno/jni_info.cxx
@@ -302,2 +302,3 @@ JNI_compound_type_info::JNI_compound_type_info(
                  (jclass) jo_class.get(), "Context", "Ljava/lang/Object;" );
+            fprintf(stderr, "%s:%d %s: m_fields=[%p,%p]\n",
__FUNCTION__, __LINE__, OUStringToOString(uno_name,
RTL_TEXTENCODING_ASCII_US).getStr(), m_fields[0], m_fields[1]);
              jni.ensure_no_exception();
@@ -311,2 +312,3 @@ JNI_compound_type_info::JNI_compound_type_info(

+            fprintf(stderr, "%s:%d %s: %d fields\n", __FUNCTION__,
__LINE__, OUStringToOString(uno_name,
RTL_TEXTENCODING_ASCII_US).getStr(), (int)nMembers);
              for ( sal_Int32 nPos = 0; nPos<  nMembers; ++nPos )
@@ -337,2 +339,3 @@ JNI_compound_type_info::JNI_compound_type_info(
                  jni.ensure_no_exception();
+                fprintf(stderr, "  %s: %p\n", member_name.getStr(),
m_fields[nPos]);
                  OSL_ASSERT( 0 != m_fields[ nPos ] );

and get this output:

JNI_compound_type_info:303 com.sun.star.uno.Exception: m_fields=[0x0,0x44e29a68]
JNI_compound_type_info:303 com.sun.star.uno.RuntimeException:
m_fields=[0x0,0x44e26c68]

Then shortly after that I get a crash:

JNI WARNING: instance fieldID 0x44e29a68 not valid for class
Lcom/sun/star/uno/RuntimeException;

Note that the fieldID here is the one printed as being for the
Exception type, while the warning message says it is used for
RuntimeExcpetion.

(Yeah, despite claiming that is a "warning", Dalvik then throw its
hands up and quits:
http://androidxref.com/source/xref/dalvik/vm/CheckJni.cpp#364 )

Bells ringing, anyone?

Firstlty, I guess I need to quickly check what that debugging output
says with a "normal" JVM, whether the field ids are

--tml
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Disclaimer: http://www.peralex.com/disclaimer.html



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.