This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Some other oddities
Thanks for stomping the class bug; turnaround time isn't crucial, as
I've got a hack that gets around it for now. And I'm SHOCKED at the
speed Kawa's running my examples when you load it down with type
declarations. About 1.5 the speed of full, reasonably optimized
Java. Really amazing!
A few other oddities I came across in Kawa that I can't find answers
to in the docs. Could anyone shed some light onto them for me?
0. The syntax for making multidimensional arrays is lacking. To do
this in Java:
public static final int[][] b_heptomino = new int[][]
{{0, 1, 1},
{1, 1, 0},
{0, 1, 1},
{0, 0, 1}};
The best I've been able to manage is:
(b-heptomino type: <int[][]>
allocation: 'static
init-form: (make <int[][]>
(make <int[]> 0 1 1)
(make <int[]> 1 1 0)
(make <int[]> 0 1 1)
(make <int[]> 0 0 1)))
Yuck. Still, a big improvement over 1.8.
1. The documentation says that to access fields defined in Scheme in
a simple-class, you have to use (slot-ref foo 'bar), but for standard
Java classes you can use (#:.bar foo). And it appears to be the case
in my testing. :-( The question is: why is this the case? It sure
makes for an inconsistent user experience.
2. Load order for mutually-referential simple-classes seems to be
broken, or at least inconsistent in an undocumented way. I have a
class called <tutorial1> which has a method that looks like this:
(define-simple-class <tutorial1> (<sim.engine.SimState>)
((start) :: <void>
..........
(make <ca>) ....
I have another class called <ca> which has a method which like this:
(define-simple-class <ca> (<sim.engine.Steppable>)
((step (state :: <sim.engine.SimState>)) :: <void>
..........
(let ((tut :: <tutorial1> (as <tutorial1> state))) ....
As can be seen, they each refer to the other. If you load
<tutorial1> before <ca> you get a warning:
(load "tutorial1.scm")
(load "ca.scm")
tutorial1.scm:40:13: warning - unknown class: ca
... and it works fine. But if you load ca first before loading
tutorial1, kawa spits out a large Java error indicating that
tutorial1 doesn't exist yet! Specifically:
(load "ca.scm")
ca.scm:13:36: unknown class: tutorial1
java.lang.RuntimeException: no such class: tutorial1
at gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:77)
at gnu.bytecode.ClassType.addFields(ClassType.java:402)
at gnu.bytecode.ClassType.getFields(ClassType.java:306)
at gnu.bytecode.ClassType.getDeclaredField(ClassType.java:320)
........
Caused by: java.lang.ClassNotFoundException: tutorial1
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
........
What's failing, and why? Is it the tut :: <tutorial1> that requires
tutorial1 exist? or is it the case (which, btw, appears to be
NECESSARY if I want to call a function on the tutorial1 method that
doesn't exist in its superclass -- very un-scheme-like :-( )