Re: the ScriptingMojo

From: Kartik Ohri <kartikohri13(at)gmail(dot)com>
To: Chapman Flack <chap(at)anastigmatix(dot)net>
Cc: pljava-dev(at)lists(dot)postgresql(dot)org
Subject: Re: the ScriptingMojo
Date: 2020-08-22 19:12:04
Message-ID: CAASLQ4MBWQeFLdAPNcsgcpLyekU5X=ExQUuGgE49AUFdEYJr8g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

>
> 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

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Chapman Flack 2020-08-22 19:33:13 Re: the ScriptingMojo
Previous Message Kartik Ohri 2020-08-22 10:15:01 Re: the ScriptingMojo