This is the mail archive of the kawa@sourceware.org mailing list for the Kawa 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: More loading on Android strangeness




On 11/20/2014 03:13 AM, Ben Simon wrote:
On Wed, Nov 19, 2014 at 2:26 PM, Jamison Hope <jrh@theptrgroup.com> wrote:
I agree.  Any ideas why these errors are being printed out in the log
vs. being thrown as an exception?  In an ideal world, I'd like to
catch the exception in the code that calls (load ...) and display it
to the user.

If it's a "massive stack trace" it could a stack overflow.


((current-activity):setContentView
    (android.widget.TextView (current-activity)
      text: "Hello World"))

(logi "Ending")
; ---------------------------

I get the error in the logs below. I've fiddled around with using (as
android.app.Activity (current-activity)) to help indicate what type
the activity is, but that hasn't worked yet.


on-create.scm(14167): Starting
t/sdcard/AppDoh/on-create.scm:8:2: warning - no known slot
'setContentView' in java.lang.Object
t/sdcard/AppDoh/on-create.scm:9:2: caught exception in inliner for
#<procedure make> - java.lang.NullPointerException
  gnu.expr.ReferenceExp.<init>(ReferenceExp.java:76)
  gnu.kawa.android.ViewBuilder.useBuilder(ViewBuilder.scm:17)
  gnu.kawa.reflect.CompileInvoke.validateNamedInvoke(CompileInvoke.java:249)
  gnu.kawa.reflect.CompileInvoke.validateApplyInvoke(CompileInvoke.java:151)

This looks like a bug/limitation in the useBuilder meyjpd in ViewBuilder.scm.

First note that the loaded code is "compiled" - though only to an Expression tree,
not all the way to bytecode.

CompileInvoke.validateNamedInvoke is (at compile time) called to process the
  (android.widget.TextView ...)
expression.  It looks for a definition of current-activity in the (lexical) scope.
That becomes the value of activity-decl, which is then passed to the
(gnu.expr.ReferenceExp activity-decl).
It looks like activity-decl is null.

I'm guessing that is because the (require 'android-defs) is not in the same
"module" as the  (android.widget.TextView ...).

A possible work-around is to wrap the entire body in a begin:

(begin
  (require 'android-defs)

  (define (logi . messages)
  (android.util.Log:i "on-create.scm" (apply string-append messages)))

  (logi "Starting")

  ((current-activity):setContentView
   (android.widget.TextView (current-activity)
     text: "Hello World"))

  (logi "Ending")
)

This forces the whole things to be a single "module", which there will
hopefully be a visible declaration for current-activity.

It that works, we can consider replacing the (gnu.expr.ReferenceExp activity-decl)
with something that expands to
  (gnu.kawa.android.utils:current-activity)
That shouldn't be too difficult.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


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