public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Vasantha Ganesh <vasanthaganesh.k@gmail.com>
To: Per Bothner <per@bothner.com>
Cc: kawa@sourceware.org
Subject: Re: Help, writing kawa equivalent of java program
Date: Sat, 01 Apr 2017 19:44:00 -0000	[thread overview]
Message-ID: <CAL0TjKqKnn_VprxeXVN1vU67bJ3BoHYkUyxSc852VnGiX_+Opw@mail.gmail.com> (raw)
In-Reply-To: <58919df1-afe7-ae3b-0fdc-bb428c8ba3ed@bothner.com>

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.

  reply	other threads:[~2017-04-01 19:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01 15:54 Vasantha Ganesh
2017-04-01 16:28 ` Per Bothner
2017-04-01 19:44   ` Vasantha Ganesh [this message]
2017-04-01 19:52     ` Per Bothner
2017-04-01 19:59       ` Vasantha Ganesh
2017-04-01 20:00         ` Vasantha Ganesh
2017-04-01 20:20           ` Sudarshan S Chawathe
2017-04-01 20:25             ` Per Bothner
2017-04-01 20:51               ` Vasantha Ganesh
2017-04-02  5:39   ` Per Bothner

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=CAL0TjKqKnn_VprxeXVN1vU67bJ3BoHYkUyxSc852VnGiX_+Opw@mail.gmail.com \
    --to=vasanthaganesh.k@gmail.com \
    --cc=kawa@sourceware.org \
    --cc=per@bothner.com \
    /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).