RFR: 8353487: JShell LocalExecutionControl should allow decorating the execution task
Archie Cobbs
acobbs at openjdk.org
Fri Apr 4 16:55:11 UTC 2025
On Fri, 4 Apr 2025 15:53:50 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> I wonder how generic are the snippets used - for some types of snippets, it might be possible to put some code around the original snippet directly in the snippet. That would alleviate the need to add a new API. But presumably it would only work for some types of snippets.
Yes, sort of - it's already possible to modify the snippet bytecode itself of course because the `ExecutionProvider` is who loads it. That works for things like imposing time limits, etc., but it doesn't work so well for "wrapping" the execution because (a) you have to know what the secret method is that is going to be invoked (not hard - it's called `do_it()`, but kludgey), and (b) you would have to insert an INVOKESTATIC that calls into your `ExecutionProvider`, which means your `ExecutionProvider` must be available via the class loader that the snippet uses, and this is not guaranteed.
> For the API itself - just an idea, would having a method `doInvoke` along these lines work:
>
> ```
> public Object doInvoke(Method m) throws Exception {
> return doitMethod.invoke(null, new Object[0]);
> }
> ```
Yes that would work just as well. A third option would be to define a pair like `executionStart()` and `executionFinish()`.
I think your idea of a `doInvoke()` is actually a bit simpler/better, so I've updated that in 8c472446e66 and also updated the CSR.
Thanks for taking a look.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24398#issuecomment-2779283959
More information about the kulla-dev
mailing list