This is the mail archive of the kawa@sources.redhat.com 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]

Boolean to boolean conversion not automatic.


I've just discovered a case of coercion not being as automatic as I
thought it was in Kawa. I'm used to automatic coercion between <boolean>
and <java.lang.Boolean>, so that if for example I have a Vector with a
Boolean in it, and then in Kawa assign that Boolean to a <boolean>, it all
works. Similarly for <java.lang.Integer> and <int>. But here's where this
breaks down:

Define a Kawa function returning a <boolean>:
  (module-name 't)

  (module-static #t)

  (define (t) <boolean>
    (make <java.lang.Boolean> #t)
  )
  ; In my original function, the Boolean came from a Java data structure,
  ; one field of which is Boolean. I've simplified when demonstrating the
  ; error.

Call it:
  public class test
  {
    public static void main( String[] argv )
    {
      kawa.standard.Scheme.registerEnvironment();

      boolean b = t.t();
      System.out.println( b );
    }
  }

And get an error:
  [d:\kb7\mm3\decompiler]java kb7.mm3.decompiler.test
  Exception in thread "main" java.lang.VerifyError: (class: kb7/mm3/decompiler/t,
  method: t signature: ()Z) Wrong return type in function
                            at kb7.mm3.decompiler.test.main(test.java:9)

Per's dump utility shows the function's signature to be correct, as I
suppose does the fact that the Java compiler accepts it. So the failure is
taking place inside the function, when it tries to coerce Boolean to
boolean. Surprising that Kawa doesn't report an error during compilation.

Jocelyn Paine
http://www.ifs.org.uk/~popx/
+44 (0)7768 534 091 




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