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 1k9bTr-0001Jc-BP for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 21:55:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k9bTo-0004C9-Na for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 21:55:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9bTo-0004C2-IO for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 21:55:16 +0000 Received: from anastigmatix.net ([68.171.219.55]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9bTl-0007cN-Eu for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 21:55:16 +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=DPpEWfrYWNbWN5XSwmlvYRbY/HYxieMlpCKHhWf62ss=; b=QpNDBvBV8qotlofsShKh3rC5B jRfmyc23gM5Oqgot+EL+39VdBbSB+1bfm8K3tQIktz22yiIBcie0LPph+8HEDD+S12nt4lGm6VjQs mLd8/+ibWFxtw6PuSSC+typcPOcencvR28NLwQ+aDkzZoiDgWOXuQc2wltQLl15rF+Gy7xK3HcYWL K9FIHbUHDqHE0c0F0ACEVMocsM2M+mf84oDppkfr8/yVWq2Uv6sQYeysuMho/ZslOUtc/oirrZgcJ 1k/OTtPWSxMheg5/iDL2c6GsoHhc4cBSNX/HDfWC2cTL9npg4ATl8/1DnHOjw3Gf//N8qTXTzVrPx K2oRTpxZg==; Received: from [184.19.31.139] (port=45355) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k9bTi-00DBYt-WF; Sat, 22 Aug 2020 17:55:11 -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> Cc: pljava-dev@lists.postgresql.org From: Chapman Flack X-Enigmail-Draft-Status: N1110 Message-ID: <5F41943D.9080707@anastigmatix.net> Date: Sat, 22 Aug 2020 17:55:09 -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: Content-Type: multipart/mixed; boundary="------------070509090807050104040202" 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. --------------070509090807050104040202 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 08/22/20 15:12, Kartik Ohri wrote: > I really like this idea. But I am not sure how to work this out. The main > point of contention is the class type of platforms["Linux"]. I tested with > Nashorn and Graal and printed the class of the object in the constructor. > For nashorn, it is jdk.nashorn.api.scripting.ScriptObjectMirror and for > graal it is com.oracle.truffle.polyglot.PolyglotMap. If I do the attached, it does what I was hoping for. The constructor prints PGXS impl class is jdk.nashorn.javaadapters.org_postgresql_pljava_pgxs_PGXSUtils$PGXS in nashorn, or PGXS impl class is org.postgresql.pljava.pgxs.PGXSUtils$PGXS$$JSJavaAdapter in graal. (Wow, pretty sneaky, Graal fakes up a class that is even in the superclass's package! I bet it's using MethodHandles.Lookup.defineClass, which appeared in Java 9 so Nashorn probably doesn't.) The new Foo(jsobject) syntax only has magic if Foo is an interface or an abstract class. If Foo is an instantiable class, that will be parsed as simply calling a one-argument constructor to instantiate it, and passing the jsobject as the argument. Maybe that is what you were seeing? You sort of have to believe with this stuff; ask too many questions and you drive the magic away. Regards, -Chap --------------070509090807050104040202 Content-Type: image/x-coreldrawpattern; name="pgxs.pat" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pgxs.pat" LS0tIGEvcGxqYXZhLXBneHMvc3JjL21haW4vamF2YS9vcmcvcG9zdGdyZXNxbC9wbGphdmEv cGd4cy9QR1hTVXRpbHMuamF2YQorKysgYi9wbGphdmEtcGd4cy9zcmMvbWFpbi9qYXZhL29y Zy9wb3N0Z3Jlc3FsL3BsamF2YS9wZ3hzL1BHWFNVdGlscy5qYXZhCkBAIC0xOTAsNiArMTkw LDE4IEBAIHB1YmxpYyBmaW5hbCBjbGFzcyBQR1hTVXRpbHMKIAkJfQogCX0KIAorCXB1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