From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56115 invoked by alias); 18 Sep 2017 14:24:37 -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 55071 invoked by uid 89); 18 Sep 2017 14:24:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1398, HContent-Transfer-Encoding:8bit X-HELO: aibo.runbox.com Received: from dns3.teletopia.net (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Sep 2017 14:24:30 +0000 Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dtwyD-0001Nk-Mn; Mon, 18 Sep 2017 16:24:21 +0200 Received: from 70-36-239-144.dsl.dynamic.fusionbroadband.com ([70.36.239.144] helo=localhost.localdomain) by mailfront12.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1dtwww-0000LQ-BG; Mon, 18 Sep 2017 16:23:02 +0200 Subject: Re: using lambda to implement one method interface To: Sudarshan S Chawathe , Sonny To Cc: Kawa mailing list References: <22802.1505733729@vereq.eip10.org> From: Per Bothner Message-ID: Date: Mon, 18 Sep 2017 14:24:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <22802.1505733729@vereq.eip10.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00068.txt.bz2 On 09/18/2017 04:22 AM, Sudarshan S Chawathe wrote: >> how would I implement an interface with multiple methods? > > I have found that simply defining the methods required by an interface > (with the proper names and type signatures) works, in the sense that the > resulting objects can be used anywhere that requires objects > implementing the interface. Not sure I understand what you mean by that. The problem is defining an instance of an interface: (1) with multiple methods; (2) on-the-fly, in a REPL; (3) on Android, which doesn't (didn't?) have ClassLoader.defineClass. It should be possible to generalize gnu.kawa.reflect.ProceduralProxy to handle multiple methods and corresponding implementing procedures. The tricky is specifying which method is implemented by which procedure. Perhaps problem (3) above is no longer a problem, at least on Android 8. https://developer.android.com/reference/java/lang/ClassLoader.html says that the byte array to defineClass "should have the format of a valid class file as defined by The Java™ Virtual Machine Specification." So maybe we need to update the compilerAvailable test in ModuleExp.java. If we now can generate classes on-the-fly then that removes a major limitation of Kawa on Android. (At least on newer Android versions.) -- --Per Bothner per@bothner.com http://per.bothner.com/