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 1k9QYQ-0004nN-Gm for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 10:15:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k9QYP-00022T-Fk for pljava-dev@arkaria.postgresql.org; Sat, 22 Aug 2020 10:15:17 +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 1k9QYP-00022M-An for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 10:15:17 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k9QYM-0006aA-Ji for pljava-dev@lists.postgresql.org; Sat, 22 Aug 2020 10:15:16 +0000 Received: by mail-ed1-x530.google.com with SMTP id di22so3617189edb.12 for ; Sat, 22 Aug 2020 03:15:14 -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=jn5x0jbkxTPHWAyEJs30nIjc6stbgwKxasDo8z5GaiQ=; b=I6YRiLZqSt5RUzAsEn1CMUtcwoV1kOqsyyq0KolBC+NJ2vqXWmADg7ye9F49uDaibY wmnBziQcVQyjSNN7STUhNzLeOcqH8DU68S2fPkM4UXumLKDkSMvo12YJtm07yZUuzqTL XmkAzj0oM5SdUd5ZAqjaSyiV/cDv+upRNWdic0AENDGxoGo2R7aBaMNJIIJC4IPUUONm 4VQtdOtH2X12Nl5cdxowo3k95JVJd9duotK2HyX2spu70I6olBIwIK2qqTUqISsr+qqQ cLazdzSn+J5SyqLY6/cg1aFnHy9yaJYjklupdMSl04MMraZh2sJEmHFgIftraeTiuOP8 NHxg== 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=jn5x0jbkxTPHWAyEJs30nIjc6stbgwKxasDo8z5GaiQ=; b=RKgeaJXDwuwpci9lMNBbXHdK8QSHeUF5LUGuCq9nbJjl4EYHaNkA9THMLn9mj1JfcC 5CjE3oxhSYiTMM8Wz2ep3ZHQaueBtn0qcLKSqneMHr9NBXa07sZHaUD3Fw9v/n7FlBUF UoxctCn2YqMYmasLgW6DPWGKs3CQGPKw2rcpB5Y4uuLHn1jMVtBEzUsu8nPBEXUhx34w p9JMJyv3nqDAWl1U39DZyZIBZ5yJ9ax6KblHDxGT9s3CCoX9KAC9zZVOsp8usUhgdghJ miPZbmu6/in24YHOkPHjS7meGeFMywUS50QYGBOHUsVCRe2wNG5IFSJO7i0cEsEBl6Co lbQQ== X-Gm-Message-State: AOAM530kEeitm8KWuVJVkhAaRQTU1H/ocxzTMnHcIBGLV11LdvapAQwR q5gmBl5fVpp5jFuZ+UAzWWLnA1C/ow3eGbdASFj4bah+pcGC0w== X-Google-Smtp-Source: ABdhPJwF8SDWh+KCRJB/gMuOzM7YFkR6jlMsvJwXzFJLXwlinGXMMcCJJx1ASVoOWMyTScPDekFstP7Kw1cidXhBwAk= X-Received: by 2002:aa7:d983:: with SMTP id u3mr6910926eds.366.1598091313008; Sat, 22 Aug 2020 03:15:13 -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: Sat, 22 Aug 2020 15:45:01 +0530 Message-ID: Subject: Re: the ScriptingMojo To: Chapman Flack Cc: pljava-dev@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000007d65905ad74a163" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000007d65905ad74a163 Content-Type: text/plain; charset="UTF-8" > > - I was thinking of simplifying the parameters to processBuilder, to not > need the caller to separately pass the command string and a list of the > rest of the arguments. An idea that just hit me was why not just > processBuilder(Consumer>)? A script could use it like: > > var pb = processBuilder(function(l) { > l.add(command); > l.addAll(stuff); > l.add(thing); > ... > }); > > so the script would avoid the messiness of allocating its own ArrayList > and so on. On the Java side that's just > > pb = new ProcessBuilder(); > callback.accept(pb.command()); > ... > return pb; > Hi! I am working adding these changes but I am particularly stuck at this one. It seems that Nashorn and Graal do not support SAM inside SAM or I am doing this the wrong way. Please see https://www.ideone.com/cQVGuB and https://www.ideone.com/1x7Ah7. The former one fails at runtime but the latter completes execution. (Here I have done a Consumer whereas Function will be required for our use case, but both fail at runtime anyways). This is the commit ( https://github.com/amCap1712/pljava/commit/136a8e879951432ec47faeb74e2a86e848481e67) with changes that fails. I have been able to work around the issue using the approach here https://github.com/amCap1712/pljava/commit/d5977c5cf386758fb2d9e56524b05f9549cefe31 . Regards, Kartik --00000000000007d65905ad74a163 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
- I was thinking of simplifying the parameters to proces= sBuilder, to not
=C2=A0 need the caller to separately pass the command string and a list of = the
=C2=A0 rest of the arguments. An idea that just hit me was why not just
=C2=A0 processBuilder(Consumer<List<String>>)? A script could u= se it like:

=C2=A0 var pb =3D processBuilder(function(l) {
=C2=A0 =C2=A0 l.add(command);
=C2=A0 =C2=A0 l.addAll(stuff);
=C2=A0 =C2=A0 l.add(thing);
=C2=A0 =C2=A0 ...
=C2=A0 });

=C2=A0 so the script would avoid the messiness of allocating its own ArrayL= ist
=C2=A0 and so on. On the Java side that's just

=C2=A0 pb =3D new ProcessBuilder();
=C2=A0 callback.accept(pb.command());
=C2=A0 ...
=C2=A0 return pb;

Hi!
I am wo= rking adding these changes but I am particularly stuck at this one. It seem= s that Nashorn and Graal do not support SAM inside SAM or I am doing this t= he wrong way. Please see=C2=A0htt= ps://www.ideone.com/cQVGuB=C2=A0and=C2=A0https://www.ideone.com/1x7Ah7. The former one fails at runt= ime but the latter completes execution. (Here I have done a Consumer<Fun= ction, ?>=C2=A0 whereas Function<Consumer, ?> will be required for= our use case, but both fail at runtime anyways). This is the commit (https://github.com/amCap1712/pljava/commit/136a8e879951432e= c47faeb74e2a86e848481e67) with changes that fails. I have been able to = work around the issue using the approach here=C2=A0htt= ps://github.com/amCap1712/pljava/commit/d5977c5cf386758fb2d9e56524b05f9549c= efe31.

Regards,
Kartik
--00000000000007d65905ad74a163--