From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from MTA-07-4.privateemail.com (mta-07-4.privateemail.com [68.65.122.27]) by sourceware.org (Postfix) with ESMTPS id 4D7D93858D34 for ; Mon, 30 Aug 2021 23:10:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4D7D93858D34 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eatonphil.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eatonphil.com Received: from mta-07.privateemail.com (localhost [127.0.0.1]) by mta-07.privateemail.com (Postfix) with ESMTP id 2AF5F180022E for ; Mon, 30 Aug 2021 19:10:01 -0400 (EDT) Received: from mail-ua1-f48.google.com (unknown [10.20.151.217]) by mta-07.privateemail.com (Postfix) with ESMTPA id 10F2C1800227 for ; Mon, 30 Aug 2021 19:10:01 -0400 (EDT) Received: by mail-ua1-f48.google.com with SMTP id t26so8697468uao.12 for ; Mon, 30 Aug 2021 16:10:00 -0700 (PDT) X-Gm-Message-State: AOAM532eosmBNWyWDdMaLXiciMwF9gJBCoeJp0nEWdKC/bktlBcP2u9c l/DqsX8p1eMDzZd4mYUnBKZrnGMXIksbu4MKUaY= X-Google-Smtp-Source: ABdhPJxIP5nhzLA5YiA/48RbV8ganKK8qtCQf9Xq+dDzMh7jDv9qpt/bmYN8PRBVoryzaK3TOr4Uw1KNMFqHvCmf95g= X-Received: by 2002:ab0:1444:: with SMTP id c4mr16757634uae.58.1630365000074; Mon, 30 Aug 2021 16:10:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Phil Eaton Date: Mon, 30 Aug 2021 19:09:49 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Receiver class does not define or inherit an implementation of the resolved method To: Per Bothner Cc: kawa mailing list X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, HTML_MESSAGE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 23:10:13 -0000 Aha! It gave my second apply method a different suffix. By reordering these two methods the whole thing somehow works. $ javap main\$0.class Compiled from "main.scm" public class main$0 implements io.jooby.Route$Handler { main$frame this$0; public java.lang.CharSequence apply(io.jooby.Context); public java.lang.Object apply$1(io.jooby.Context); public main$0(main$frame); } It's weird but I'll take it. On Mon, Aug 30, 2021 at 12:40 PM Per Bothner wrote: > On 8/29/21 12:03 PM, Phil Eaton wrote:> Still new to Kawa. I'm trying to > implement an interface ( > > io.jooby.Route$Handler > > < > https://github.com/jooby-project/jooby/blob/2.x/jooby/src/main/java/io/jooby/Route.java#L247 > >). > > It only has a single non-default method, apply. > > > > Here's what I've got > > > > (define (route app method path handler) > > (let ((handler (object (io.jooby.Route$Handler) > > #| This method exists just to stop Jooby from > > trying to introspect Java code that doesn't exist because this isn't > > written in Java. |# > > ((apply (ctx ::io.jooby.Context)) ::string > > #!null) > > ((apply (ctx ::io.jooby.Context)) > > ::java.lang.Object > > (handler ctx))))) > > (app:route method path handler))) > > > > > > But when this gets exercised, I get: > > > > [worker-1-3] ERROR io.jooby.Jooby - GET /hello-world 500 Server Error > > java.lang.AbstractMethodError: Receiver class main$0 does not define or > > inherit an implementation of the resolved method 'abstract > java.lang.Object > > apply(io.jooby.Context)' of interface io.jooby.Route$Handler. > > I don't see anything obviously wrong. One thing to try is instead of an > anonymous class (with object) use a named class (with define-simple-class). > The anonymous class is more convenient of course there is some extra > "magic" > (such as invisible fields) that might complicate things. > > > Also on a tangent, I was excited about the lambda shorthand for single > > method objects. Like I said this interface only has a single non-default > > method: apply. But I tried just calling `(app:route method handler)` > > without wrapping it in the io.jooby.Route$Handler object but it still > > failed. I guess it couldn't figure out this one method. > > Kawa has to be able to figure out at compile time that a specific > class/interface > is required before it can convert the lambda to an object. (As far as I > can > remember, doing this conversion at run-time isn't implemented, and would be > fairly complicated.) So you may need to add some more type-specifiers. > > I suggest using javap to look at the generated classes, to see what is > going on. > -- > --Per Bothner > per@bothner.com http://per.bothner.com/ >