[jsword-devel] [JIRA] Created: (JS-212) Android 4 incompatibility in CallContext (fixed applied locally)

Martin Denham (JIRA) jira at crosswire.org
Wed Mar 7 13:06:58 MST 2012


Android 4 incompatibility in CallContext (fixed applied locally)
----------------------------------------------------------------

                 Key: JS-212
                 URL: http://www.crosswire.org/bugs/browse/JS-212
             Project: JSword
          Issue Type: Bug
          Components: o.c.common.util
            Reporter: Martin Denham
            Assignee: DM Smith
         Attachments: CallContext.java

I had to amend my version of CallContext before a recent And Bible release because of an incompatibility with the latest version of Android (4.0/ICS) that prevented And Bible from starting up.

Android 4.0 does not return anything from getClassContext() so using the default JSword code causes Exception on start up.  For now I commented out the call and replaced it with a reference to Thread.getStackTrace().  I did this about a month ago and some of the detail now escapes me but the changes I stopped CallContext extending SecurityManager and replaced getCallingClass with the following.

    public static Class<?> getCallingClass(int i) {
    	try {
	// Android 4.0 does not return anything from getClassContext() so using the default JSword code causes Exception in Initializer resulting from an NPE
	        return Class.forName(Thread.currentThread().getStackTrace()[CALL_CONTEXT_OFFSET + i].getClassName());
	//        return instance().getClassContext()[CALL_CONTEXT_OFFSET + i];

It is a bit messy but I thought it best to include the live version.  I have also attached the actual class I now use.  There may be an inefficiency in the above so it may be that we need to differentiate between Android and other environments if JSword is updated.

The above problem was a bit of a surprise because it works fine in all versions of Android until 4.0

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jsword-devel mailing list