define-alias NOT working

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

define-alias NOT working

Alcides Flores Pineda
Hello Everybody:

I'm finally migrating to Kawa 2.0 and just found that this code:

(define-alias showMsgDlg javax.swing.JOptionPane:showMessageDialog)

(showMsgDlg #!null "Hello everybody from Kawa!")


That used to work pretty well in Kawa 1.14, is now broken..

$ java -cp kawa-2.0.1.jar kawa.repl
#|kawa:1|# (define-alias  showMsgDlg
javax.swing.JOptionPane:showMessageDialog)
java.lang.NullPointerException
     at kawa.standard.location.rewriteApply(location.java:96)
     at kawa.standard.location.rewrite(location.java:64)
     at kawa.standard.define_alias.rewriteForm(define_alias.java:86)
     at kawa.lang.Translator.apply_rewrite(Translator.java:175)
     at kawa.lang.Translator.rewrite_pair(Translator.java:353)
     at kawa.lang.Translator.rewrite_with_position(Translator.java:1355)
     at kawa.lang.Translator.rewrite(Translator.java:735)
     at kawa.lang.Translator.rewrite(Translator.java:715)
     at kawa.lang.Translator.rewriteInBody(Translator.java:668)
     at kawa.lang.Translator.rewriteBody(Translator.java:1663)
     at kawa.lang.Translator.resolveModule(Translator.java:1844)
     at gnu.kawa.lispexpr.LispLanguage.resolve(LispLanguage.java:141)
     at gnu.expr.Compilation.process(Compilation.java:1973)
     at gnu.expr.ModuleExp.evalModule1(ModuleExp.java:240)
     at gnu.expr.ModuleExp.evalModule(ModuleExp.java:214)
     at kawa.Shell.run(Shell.java:291)
     at kawa.Shell.run(Shell.java:203)
     at kawa.Shell.run(Shell.java:184)
     at kawa.repl.main(repl.java:903)

$ java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~deb7u1)
OpenJDK Server VM (build 24.75-b04, mixed mode)

I'm getting this error consistently in compile mode and from the REPL,
and with JDK8(Oracle) and JDK7(OpenJDK), hence my example project
(https://github.com/alcidesfp/swing-kawa) cannot be compiled with Kawa 2.0

Any workaround or suggestion will be highly appreciated.

Greetings.
--
Alcides Flores Pineda.

Reply | Threaded
Open this post in threaded view
|

Re: define-alias NOT working

Per Bothner


On 04/04/2015 03:46 PM, Alcides Flores Pineda wrote:

> (define-alias showMsgDlg javax.swing.JOptionPane:showMessageDialog)
>
> (showMsgDlg #!null "Hello everybody from Kawa!")
>
>
> That used to work pretty well in Kawa 1.14, is now broken..
>
> $ java -cp kawa-2.0.1.jar kawa.repl
> #|kawa:1|# (define-alias  showMsgDlg javax.swing.JOptionPane:showMessageDialog)
> java.lang.NullPointerException
>      at kawa.standard.location.rewriteApply(location.java:96)

I checked in a fix for this.

By the way: Kawa isn't able to resolve the call to showMsgDlg to a specific method,
so it ends up doing runtime reflection.  It would be nice to fix this,
but as an alternative you might consider using a macro:

(define-syntax showMsgDlg
   (syntax-rules ()
     ((_ . args)
      (javax.swing.JOptionPane:showMessageDialog . args))))
--
        --Per Bothner
[hidden email]   http://per.bothner.com/