From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33708 invoked by alias); 1 Apr 2017 19:44:59 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 33696 invoked by uid 89); 1 Apr 2017 19:44:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=590 X-HELO: mail-ua0-f171.google.com Received: from mail-ua0-f171.google.com (HELO mail-ua0-f171.google.com) (209.85.217.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 01 Apr 2017 19:44:57 +0000 Received: by mail-ua0-f171.google.com with SMTP id 9so10899680uau.1 for ; Sat, 01 Apr 2017 12:44:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0NNF0XJgJAbbIxBaRemJEn5w0DQyahiFodiy7jtq5JQ=; b=LzUkt5KeyDaAPmxLFgmRxrmpjqJjQd0sxG0ULdRTqCOJYTCpgN1LJU9eN9aaqWK0gJ C1CYd9c+/CZpwY7EUESqpBZ/9kC8Cex1O6Ds8uCV5s9lQ1m/Smrm3wvML2J09l21qxM1 PFBkzQC26A8T9K33dKA6vQOKlngOB3kcpxN980S15t79nEYy7c8opaKB0oohEEhUYWVE 8+TdHH6J2qFHpfCokHKRKJhZx8/z6u+iHVnNJNMZKdQqIJ5FIpPNla3yVLXlmlTZIBtE GRxf+NNSPOJqTe6ovGKvVNuLg1RDkrsJ6llADYUSZTo9zFniSZXa/0hm4/7b2u/6y0TE jZaw== X-Gm-Message-State: AFeK/H1mM+MLSnPIyjnNMEGS/N08rxnPHordNSpe0vhJ6mwngQhsAA+eCsMnBQ7vLPbesPB0SxMOUqGnfJu0pw== X-Received: by 10.159.38.48 with SMTP id 45mr2084339uag.52.1491075896980; Sat, 01 Apr 2017 12:44:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.81.136 with HTTP; Sat, 1 Apr 2017 12:44:56 -0700 (PDT) In-Reply-To: <58919df1-afe7-ae3b-0fdc-bb428c8ba3ed@bothner.com> References: <58919df1-afe7-ae3b-0fdc-bb428c8ba3ed@bothner.com> From: Vasantha Ganesh Date: Sat, 01 Apr 2017 19:44:00 -0000 Message-ID: Subject: Re: Help, writing kawa equivalent of java program To: Per Bothner Cc: kawa@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2017-q2/txt/msg00008.txt.bz2 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.