This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Help, writing kawa equivalent of java program
Hello Mr. Bothner,
Thank you, that did work. Kawa complains that the interface that I
created in kawa is not an interface. Could you please help with
debugging in convert the following java code to equivalent scheme
code?
Java code:
import com.sun.jna.Library;
import com.sun.jna.Native;
public class jnaGetpid {
public interface libc extends Library{
public long getpid();
}
public static void main(String[] args) {
libc ntv = (libc) Native.loadLibrary("c", libc.class);
System.out.println(ntv.getpid());
}
}
Kawa equivalent:
(define-alias library com.sun.jna.Library)
(define-alias native com.sun.jna.Native)
(define-simple-class libc (library)
(make-interface #t)
(getpid::long))
(define inst::libc (native:loadLibrary "c" libc:class))
(display (inst:getpid))
While running this code I get the following error (Its complaing that
the scheme interface is not an interface):
[homonculus@alchemist kawa-scheme]$ kawa -J-cp
-J/usr/share/java/jna.jar:.:/usr/share/java/kawa-2.0.jar -f
jnagetpid.scm
java.lang.IllegalArgumentException: libc is not an interface
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:590)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
at java.lang.reflect.WeakCache.get(WeakCache.java:127)
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
at com.sun.jna.Native.loadLibrary(Native.java:506)
at com.sun.jna.Native.loadLibrary(Native.java:481)
at atInteractiveLevel$4.run(jnagetpid.scm:8)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:317)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219)
at kawa.Shell.run(Shell.java:291)
at kawa.Shell.runFile(Shell.java:524)
at kawa.Shell.runFileOrClass(Shell.java:447)
at kawa.repl.processArgs(repl.java:260)
at kawa.repl.main(repl.java:871)
java.lang.NullPointerException
at atInteractiveLevel$5.run(jnagetpid.scm:9)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:317)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219)
at kawa.Shell.run(Shell.java:291)
at kawa.Shell.runFile(Shell.java:524)
at kawa.Shell.runFileOrClass(Shell.java:447)
at kawa.repl.processArgs(repl.java:260)
at kawa.repl.main(repl.java:871)
Thank you,
Vasantha Ganesh K.