Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9ZtW-0005U0-Hu for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 20:13:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k9ZtT-0005MX-IH for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 20:13:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9ZtS-0005MG-QL for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 20:13:38 +0000 Received: from anastigmatix.net ([68.171.219.55]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9ZtL-0004M6-IC for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 20:13:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:Cc:References:To:Subject:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5Cy9eAIyd6bBMfgwvLjTA9lSNqx4/SDakxvH8V08rvA=; b=JbHfeCJdOQh749Ye7CG6plAwo VE9X5TIK6WAGIHRXuA3K9bb8fcdlfqVPAHhcm6zH1Cu8edpgkRGb259S5NgXFTEDxKUflzjt7xDTC waFtDjcIddpD1DO6ET9N/dX0GFzZm2jM4TPFgpK/WNigFJzI2oahvrFRN8B44epKSpOZYkf7fTMXn dhGKfKxcs+8cb2NRAJSbrX/piMH8IACOHZpd9PC4pEYckmr9V+Qq2zu1uu9ECh2XIthSddBWX2c5g Hsk/Hy920QNj3qYkRwwL8rTBP/M4NIlPadjIZLw0yFLcItl+D7cJl8WgDlJGgHoqVtcmrgcIMLcu1 XfqWdCw3w==; Received: from [184.19.31.139] (port=45286) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k9ZtJ-00C1VH-AT; Sat, 22 Aug 2020 16:13:29 -0400 Subject: Re: the ScriptingMojo To: Kartik Ohri References: <5F2EC4F4.3080608@anastigmatix.net> <5F31EFEC.1080609@anastigmatix.net> <5F368380.9070203@anastigmatix.net> <5F368A99.6070709@anastigmatix.net> <5F36965C.60707@anastigmatix.net> <5F3A7DC6.8090905@anastigmatix.net> <5F3D32E9.80504@anastigmatix.net> <5F3D36BE.70703@anastigmatix.net> <5F3D38F8.7050907@anastigmatix.net> <5F3D3A75.5010304@anastigmatix.net> <5F3D3D2E.4070109@anastigmatix.net> <5F3D43BD.4020900@anastigmatix.net> <5F3DA48D.7090408@anastigmatix.net> <5F4172F9.4060608@anastigmatix.net> Cc: pljava-dev@lists.postgresql.org From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5F417C68.50702@anastigmatix.net> Date: Sat, 22 Aug 2020 16:13:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <5F4172F9.4060608@anastigmatix.net> Content-Type: multipart/mixed; boundary="------------040100090505060803040802" X-OutGoing-Spam-Status: No, score=-95.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------040100090505060803040802 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 08/22/20 15:33, Chapman Flack wrote: > Ok, I removed the parallel() and now graal also complains about the SAM > cast. This puzzles me because I thought both engines were intended to > support that, so I'll keep playing with it a bit. If I make the attached changes, both nashorn and graal seem to be happy. It appears that, when invoking a method /of a Java object/, they recognize when its parameter type is a SAM interface, and do the magic to present a JavaScript function as an implementation of that. We might just be asking for too many layers of magic when we start by binding a Java lambda into the script engine (which probably wraps one layer of magic over it to make it look like a JS function), and then try to pass a JS function as a parameter needing its own magic wrapping to appear as a Java SAM interface, and the engine may not see through the first layer of magic to realize it needs to add the second. "Thing" as a class name is just proof-of-concept of course. :) I had been wondering earlier if it might be useful to make PGXSUtils instantiable and bind an instance of it into the script; its constructor could take the MavenProject and Log and those wouldn't have to be passed around as much. It would still be possible to bind selected methods of it directly with names of their own for convenience, but other methods could just be accessible as utils.method() and I think that would solve this casting issue. Regards, -Chap --------------040100090505060803040802 Content-Type: image/x-coreldrawpattern; name="thing.pat" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="thing.pat" LS0tIGEvcGxqYXZhLXBneHMvc3JjL21haW4vamF2YS9vcmcvcG9zdGdyZXNxbC9wbGphdmEv cGd4cy9QR1hTVXRpbHMuamF2YQorKysgYi9wbGphdmEtcGd4cy9zcmMvbWFpbi9qYXZhL29y Zy9wb3N0Z3Jlc3FsL3BsamF2YS9wZ3hzL1BHWFNVdGlscy5qYXZhCkBAIC0xNDUsMTAgKzE0 NSw3IEBAIHB1YmxpYyBmaW5hbCBjbGFzcyBQR1hTVXRpbHMKIAkJCShGdW5jdGlvbjxMaXN0 PFN0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