public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Android problems
@ 2017-05-18  9:31 Peter
  2017-05-18 16:57 ` Per Bothner
  2017-05-23 19:35 ` Per Bothner
  0 siblings, 2 replies; 4+ messages in thread
From: Peter @ 2017-05-18  9:31 UTC (permalink / raw)
  To: kawa

Hello ;)

I've taken a bit of a hiatus, but now I'm back to playing with Kawa and
Android. I've run into a few problems...

1) Kawa seems to be compiled against 1.8, which uses
java.lang.invoke.MethodHandle a lot, which Android does not seem to
support. Is there a simple way to compile a kawa.jar against 1.6, so I
can use it for Android?

2) In the following code, I get a kawa segfault. It seems to be related
to the anonymous inner class, if I factor that out, things work fine.

(define-simple-class test (<android.app.Activity>)
          ((onCreate (savedInstanceState :: <android.os.Bundle>)):: void
           (invoke-special <android.app.Activity> (this) 'onCreate savedInstanceState)
           (let* ((self (this)))
             (let* ((adpt (object (<android.widget.ArrayAdapter>)
                                  ((*init*)
                                   (invoke-special <android.widget.ArrayAdapter> (this) '*init* self (static-field android.R$layout 'simple_list_item_1)))
                                  ((getView (position :: int) (convert-view :: android.view.View) (parent :: android.view.ViewGroup)) :: android.view.View
                                   #!null)))
                    (lv (<android.widget.ListView> self adapter: adpt)))
               (setContentView lv)))))

> make -k
CLASSPATH=kawa.jar:/opt/android-sdk/platforms/android-14/android.jar java kawa.repl -d bin/classes -P test. --module-static-run --warn-undefined-variable --warn-unknown-member --warn-invoke-unknown-method -C foo.scm
(compiling foo.scm to test.foo)
foo.scm:6: internal error while compiling foo.scm
java.lang.NullPointerException
	at gnu.bytecode.Scope.getVariable(Scope.java:105)
	at gnu.expr.ClassExp.compileMembers(ClassExp.java:537)
	at gnu.expr.LambdaExp.compileEnd(LambdaExp.java:615)
	at gnu.expr.ClassExp.compileMembers(ClassExp.java:560)
	at gnu.expr.LambdaExp.compileEnd(LambdaExp.java:615)
	at gnu.expr.Compilation.generateBytecode(Compilation.java:2077)
	at gnu.expr.Compilation.process(Compilation.java:1943)
	at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:306)
	at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:288)
	at kawa.repl.compileFiles(repl.java:780)
	at kawa.repl.processArgs(repl.java:441)
	at kawa.repl.main(repl.java:820)
make: *** [Makefile:2: all] Error 255

Is this somehow my fault, or is this a bug in the compiler?

Thanks for any help!

Greetings, Peter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Android problems
  2017-05-18  9:31 Android problems Peter
@ 2017-05-18 16:57 ` Per Bothner
  2017-05-23 19:35 ` Per Bothner
  1 sibling, 0 replies; 4+ messages in thread
From: Per Bothner @ 2017-05-18 16:57 UTC (permalink / raw)
  To: Peter, kawa

On 05/18/2017 02:31 AM, Peter wrote:

> 1) Kawa seems to be compiled against 1.8, which uses
> java.lang.invoke.MethodHandle a lot, which Android does not seem to
> support.

Apparently Android O will support MethodHandles.

> Is there a simple way to compile a kawa.jar against 1.6, so I
> can use it for Android?

You need to build Kawa from source, using the configure flag
     --with-android=/path/to/android.jar

These instructions should help; however, they are a bit out-of-date:
     https://www.gnu.org/software/kawa/Building-for-Android.html

(Advice for updating the instructions would be very welcome.)

> 2) In the following code, I get a kawa segfault. It seems to be related
> to the anonymous inner class, if I factor that out, things work fine.
> ...
> Is this somehow my fault, or is this a bug in the compiler?

Could be both :-)

As a general rule, any segfault or NullPointerException in the compiler is a compiler bug.
(I don't count exceptions in for example user-written macro transformers - however,
the compiler should catch those and print a helpful error message.)

Sometimes a compiler bug is triggered by a bug in the application.

I was able to reproduce the NullPointerException, so I'll take a look later.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Android problems
  2017-05-18  9:31 Android problems Peter
  2017-05-18 16:57 ` Per Bothner
@ 2017-05-23 19:35 ` Per Bothner
  2017-05-24 13:28   ` Peter
  1 sibling, 1 reply; 4+ messages in thread
From: Per Bothner @ 2017-05-23 19:35 UTC (permalink / raw)
  To: Peter, kawa

I checked in a fix for the following. (Only into the master branch; I can
cherry-pick it into the kawa-2.4 branch if requested.)

I also checked in a testcase dericed from yours, but not Android-dependent.
It 'stestsuite/nesting-1.scm.

On 05/18/2017 02:31 AM, Peter wrote:
> 2) In the following code, I get a kawa segfault. It seems to be related
> to the anonymous inner class, if I factor that out, things work fine.
> 
> (define-simple-class test (<android.app.Activity>)
>            ((onCreate (savedInstanceState :: <android.os.Bundle>)):: void
>             (invoke-special <android.app.Activity> (this) 'onCreate savedInstanceState)
>             (let* ((self (this)))
>               (let* ((adpt (object (<android.widget.ArrayAdapter>)
>                                    ((*init*)
>                                     (invoke-special <android.widget.ArrayAdapter> (this) '*init* self (static-field android.R$layout 'simple_list_item_1)))
>                                    ((getView (position :: int) (convert-view :: android.view.View) (parent :: android.view.ViewGroup)) :: android.view.View
>                                     #!null)))
>                      (lv (<android.widget.ListView> self adapter: adpt)))
>                 (setContentView lv)))))
> 
>> make -k
> CLASSPATH=kawa.jar:/opt/android-sdk/platforms/android-14/android.jar java kawa.repl -d bin/classes -P test. --module-static-run --warn-undefined-variable --warn-unknown-member --warn-invoke-unknown-method -C foo.scm
> (compiling foo.scm to test.foo)
> foo.scm:6: internal error while compiling foo.scm
> java.lang.NullPointerException
> 	at gnu.bytecode.Scope.getVariable(Scope.java:105)


-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Android problems
  2017-05-23 19:35 ` Per Bothner
@ 2017-05-24 13:28   ` Peter
  0 siblings, 0 replies; 4+ messages in thread
From: Peter @ 2017-05-24 13:28 UTC (permalink / raw)
  To: Per Bothner, kawa

> I checked in a fix for the following. (Only into the master branch; I can
> cherry-pick it into the kawa-2.4 branch if requested.)
> I also checked in a testcase dericed from yours, but not Android-dependent.
> It 'stestsuite/nesting-1.scm.

Great, thank you very much for the swift fix!

Greetings, Peter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-24 13:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-18  9:31 Android problems Peter
2017-05-18 16:57 ` Per Bothner
2017-05-23 19:35 ` Per Bothner
2017-05-24 13:28   ` Peter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).