From: Sonny To <son.c.to@gmail.com>
To: Kawa mailing list <kawa@sourceware.org>
Subject: using lambda to implement one method interface
Date: Sun, 17 Sep 2017 15:32:00 -0000 [thread overview]
Message-ID: <CAJxjsJvHAbQWoV+Y5Lu+JJ=C-g=zYUvAXmHAAzKx_=19SG944g@mail.gmail.com> (raw)
follwing docs at https://www.gnu.org/software/kawa/Anonymous-classes.html
(let ((handler (android.os.Handler (android.os.Looper:getMainLooper)))
(runnable (lambda ()
(android.util.Log:i "scm" "run me"))))
(handler:post runnable)
)
that doesn't seem to work. Do I need to give type hints to be able to do this?
I'm getting this error:
#|.....44|# #|.....45|# #|.....46|# #|.....47|# /dev/stdin:46:17:
warning - type function is incompatible with required type
java.lang.Runnable
java.lang.ClassCastException: don't know how to coerce
gnu.expr.LambdaExp$Closure to java.lang.Runnable
at gnu.bytecode.ObjectType.coerceFromObject(ObjectType.java:180)
at gnu.kawa.functions.Convert.apply2(Convert.java:38)
at gnu.mapping.Procedure2.applyToObject(Procedure2.java:62)
at java.lang.reflect.Method.invoke(Native Method)
at gnu.mapping.CallContext$ReflectMethodHandle.invokeExact(CallContext.java:726)
at gnu.mapping.Procedure.applyToConsumerDefault(Procedure.java:75)
at java.lang.reflect.Method.invoke(Native Method)
at gnu.mapping.CallContext$ReflectMethodHandle.invokeExact(CallContext.java:726)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
at gnu.mapping.CallContext.getFromContext(CallContext.java:616)
at gnu.expr.Expression.eval(Expression.java:52)
at gnu.expr.ApplyExp.apply(ApplyExp.java:161)
at gnu.expr.LetExp.apply(LetExp.java:72)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:281)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:211)
at kawa.Shell.run(Shell.java:283)
at kawa.Shell.run(Shell.java:196)
at kawa.Shell.run(Shell.java:183)
at kawa.TelnetRepl.apply0(TelnetRepl.java:25)
at gnu.mapping.RunnableClosure.run(RunnableClosure.java:75)
at java.lang.Thread.run(Thread.java:764)
next reply other threads:[~2017-09-17 15:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 15:32 Sonny To [this message]
2017-09-17 15:38 ` Sonny To
2017-09-17 15:59 ` Per Bothner
2017-09-17 16:04 ` Sonny To
2017-09-17 16:50 ` Per Bothner
2017-09-17 18:54 ` Sonny To
2017-09-17 20:02 ` Per Bothner
2017-09-18 6:35 ` Sonny To
2017-09-18 8:17 ` Sonny To
2017-09-18 13:59 ` Per Bothner
2017-09-18 11:22 ` Sudarshan S Chawathe
2017-09-18 14:24 ` Per Bothner
2017-09-18 14:31 ` Sudarshan S Chawathe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJxjsJvHAbQWoV+Y5Lu+JJ=C-g=zYUvAXmHAAzKx_=19SG944g@mail.gmail.com' \
--to=son.c.to@gmail.com \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).