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: Android Kawa - verifier error


* teyc [2012-01-27 21:06] writes:

> (I've set aside the issue of creating classes at the moment)
>
> My next task is to figure out how to execute Lisp forms on the UI thread and
> fetch the result back to the REPL. The main idea is to use a lock, eval a
> form, store the result and the REPL thread blocks until the result is
> available.
>
> First I ran this up in Java, and confirmed it worked.
>
> ; Job.scm
> ; a job that is posted on a UI thread.
> (define-simple-class Job (java.lang.Runnable)
>     (result type: object init-value: #!null)
>     (form init-keyword: form:)
>     ((*init* (form0:: Object))
>         (set! form form0))
>     ((run) :: #!void
>         (synchronized (this)
>             (if (not (eq? #!null form))
>                 (set! result (eval form (interaction-environment))))
>             (notify))
>     ))
>
> #|
> ; Test routine
> (let ((job (Job '(* 21 2))))
>     (synchronized job
>         ((java.lang.Thread:new job):start)
>         (job:wait))
>     (display (format "Result: ~a ~%Done~%" job:result)))
> |#
>
> But when I (require "Job.scm") from my hello.scm in Dalvik, 
> I get the following error on the 'require' line itself:

The same problem occurs on a normal JVM.  The file is named "Job.scm" so
I think Kawa compiles that module to a JVM level class with name "Job"
and that will probably conflict in some way with the class that you
defined.  Incidentally, modules are also instances of Runnable.  The
problem might go away if you name the file differently, say "job.scm".

Kawa should warn earlier about the problem.

Helmut


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