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 1k9Ywk-0002yg-3g for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 19:12:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k9YwC-0001nN-43 for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 19:12:24 +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 1k9YwB-0001nF-Qi for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 19:12:23 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k9Yw6-0003sp-HR for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 19:12:22 +0000 Received: by mail-ed1-x52a.google.com with SMTP id ba10so4566969edb.3 for ; Sat, 22 Aug 2020 12:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=inIS25SWwQw7aeMNMwnwen+2BU7WF7+4650R815ugGs=; b=mAnvi1Lt50TP/ZhrXXaHdQ0UU2N8cMAEgQhpYMl85ZI4A8bNKYGtDxe32I01Oej2ol SFZa7LvynrnDIqZOT8MFzeaz/6fjGAx92ztFn/St0H6YEtsUBN48Sl/UMbUNvd1EwG00 XcyYvwfKsu6F4n19wjuvjKsMSHNRws5NS9yQgQeyrgM2Ytd+n3jPTcraVnEvnZ25A/nh Ida8fBNam/Eciro+LcayxIFw0ZxaTu47WUHRJDaw0iyfDR3cSmNnDnwmkpsHKRqcDeLn ihk5LWNRlDu69cODrulphLr9Lr0uy/PvAZDVGVtfiNRPBbczwFWR6wB8pJMVo1GJLG08 fhcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=inIS25SWwQw7aeMNMwnwen+2BU7WF7+4650R815ugGs=; b=CieBq8+G1JFEl48zaov1QCxOG5o9JmQQ2XUcEOBXAP8ywCMEUYqIsPn5iPv9lbeUgN Qb2pZ1ebvjyRA9h5ihHB+5Aq3a/OLiG6LdonAwERlR2PrWbJlBsBx6XzqSV88rK80XFr 9GpgMVDYe7+FKM3ct3rgNg7G34Z8VLK54ZQ25RcUf0Z6AWqAyMeZStjhZlZvdT+Wh5UO fG6kXbvYuTLaZ2NmSy/jJ1dirVVRKoqz8OF/350H/hFLovCez6gjQ8uZIaUlUUCSiFlh IFW09HFKqhSxez660LUKIXx3hZa2NshN4aLbG6gfr7xPgsMxIZAC2Dn+wuqHlh5ZomkL +AhA== X-Gm-Message-State: AOAM532TNhy2ADliL5MP43i4zleuYM4MTl/zoXOxzgrFNEh2Qosk9eu/ cwm51nozW2FV+uOY/PcoWaOOwY7oBt3/j34uSpT1kwhuTQmVnQ== X-Google-Smtp-Source: ABdhPJy+x0I32Q4aDGFRdVqv4UDG5kWPkRtF909qK7GJ/2MTRYVUExNZmZ/yzSvCHIu58mq92OgbDYktw+7ozb/geyo= X-Received: by 2002:aa7:d5d0:: with SMTP id d16mr8094097eds.212.1598123536728; Sat, 22 Aug 2020 12:12:16 -0700 (PDT) MIME-Version: 1.0 References: <5F2EB313.8090706@anastigmatix.net> <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> In-Reply-To: <5F3DA48D.7090408@anastigmatix.net> From: Kartik Ohri Date: Sun, 23 Aug 2020 00:42:04 +0530 Message-ID: Subject: Re: the ScriptingMojo To: Chapman Flack Cc: pljava-dev@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000b6c6a905ad7c2108" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000b6c6a905ad7c2108 Content-Type: text/plain; charset="UTF-8" > > It might be worthwhile to define an abstract class in Java that has > the necessary methods; it could also supply some other useful methods > or default implementations. I think the javascript could then do something > like: > > var platforms = { > 'Linux': { compile: function(...) { ... }, link: function... }, > 'Windows' : { ... }, > ... > } > > var impl = new AbstractPGXS(platforms['Linux']); > > which would enforce that the needed methods were all present, and the > ones supplied in Java would be naturally available too. I have not > tried this out to make sure it does what I expect in both nashorn > and graal. > Hi! 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. So, it will require implementation based handling depending on the Script Engine. That would probably require having both Nashorn and Graal present as dependencies or dynamically instantiating implementations which could get messy (or we could enforce using graal always, but I don't know if that's a good idea). But I might be missing something or another easy way here. Also, we could add a javascript function to examine the object runtime and throw an error with a detailed message if something is incorrect. Regards, Kartik --000000000000b6c6a905ad7c2108 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It might be worthwhile to define an abstract class in Ja= va that has
the necessary methods; it could also supply some other useful methods
or default implementations. I think the javascript could then do something<= br> like:

var platforms =3D {
=C2=A0 'Linux': { compile: function(...) { ... }, link: function...= },
=C2=A0 'Windows' : { ... },
=C2=A0 ...
}

var impl =3D new AbstractPGXS(platforms['Linux']);

which would enforce that the needed methods were all present, and the
ones supplied in Java would be naturally available too. I have not
tried this out to make sure it does what I expect in both nashorn
and graal.

Hi!
I really like = this idea. But I am not sure how to work this out. The main point of conten= tion is the class type of platforms["Linux"]. I tested with Nasho= rn and Graal and printed the class of the object in the constructor. For na= shorn, it is jdk.nashorn.api.scripting.ScriptObjectMirror and for graal it = is com.oracle.truffle.polyglot.PolyglotMap. So, it will require implementat= ion based handling depending on the Script Engine. That would probably requ= ire having both Nashorn and Graal present as dependencies or dynamically=C2= =A0instantiating implementations which could get messy (or we could enforce= using graal always, but I don't know if that's a good idea).=C2=A0=

But I might be missing something or another easy = way here. Also, we could add a javascript function to examine the object ru= ntime and throw an error with a detailed message if something is incorrect.=

Regards,
Kartik

--000000000000b6c6a905ad7c2108--