From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82525 invoked by alias); 18 Sep 2017 13:59:07 -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 81788 invoked by uid 89); 18 Sep 2017 13:59:06 -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= 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 13:59:04 +0000 Received: from [10.9.9.210] (helo=mailfront10.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dtwZh-000751-C6; Mon, 18 Sep 2017 15:59:01 +0200 Received: from 70-36-239-144.dsl.dynamic.fusionbroadband.com ([70.36.239.144] helo=localhost.localdomain) by mailfront10.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1dtwZ1-0001rc-MH; Mon, 18 Sep 2017 15:58:19 +0200 Subject: Re: using lambda to implement one method interface To: Sonny To Cc: Kawa mailing list References: <5319927a-872b-bf10-59a5-10b25b24343b@bothner.com> <12b97567-db76-4d6b-97a8-9da8a002883b@bothner.com> From: Per Bothner Message-ID: Date: Mon, 18 Sep 2017 13:59: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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00067.txt.bz2 On 09/18/2017 01:16 AM, Sonny To wrote: > It seems implementing single method interface using lambda only works > with methods and not in constructors? > > for example, this fails > > #|kawa:137|# (java.lang.Thread (lambda () > (+ 1 1))) > #|.....138|# /dev/stdin:137:1: warning - no possibly applicable method > '/valueOf' in java.lang.Thread > gnu.mapping.WrongArguments Yes and no. Method selection uses different code than the code that checks for type compatibility. It's mostly the same tests, but the former doesn't handle lambda-to-interface conversion. It would be non-trivial to change that. However, this works: (java.lang.Thread (->java.lang.Runnable (lambda () (newline)))) -- --Per Bothner per@bothner.com http://per.bothner.com/