Repository navigation
Conversation
withJsGlobals(false) skips the globalThis.<module>.<function> wrappers for builtins (quickjs4j_engine included) and the exports of guest functions. Builtins stay reachable through java_invoke. The code appended after the guest library now calls the guest function through a generated table and java_invoke, so it no longer depends on those globals in either mode. Smaller fixes: - an unknown module or guest function throws IllegalArgumentException instead of NullPointerException - invoking a guest function from inside a builtin fails with a clear IllegalStateException instead of a QuickJS panic - builtins sharing a module name with invokables are no longer dropped
The guard only fired when the inner call's code was already cached, and the engine was unusable afterwards anyway. Builtins that share a module with invokables now fail fast when a name clashes with a guest function or its _set_result setter, instead of one silently replacing the other. exec and guestOutput keep the underlying exception as the cause.
The result of a guest function was never cleared between calls, so an async guest function that rejected, or returned a promise that never settled, silently returned the previous call's result (or null). Clear the result before each call and throw a GuestException when none arrives. A rejection's message and stack are written to stderr, so they show up in the exception.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #227: only the last commit (
Fail guest calls that return no result) belongs to this PR. I'll rebase once #227 is merged.The result of a guest function was never cleared between calls. When
<fn>_set_resultwasn't reached, the caller silently got the previous call's result, ornullon the first call:async f(x) { if (x < 0) throw ...; return x; }called with5and then-1, returns5the second time;The engine now clears the result before each call and throws a
GuestExceptionnaming the function when no result arrives. A rejection's message and stack are written to stderr, so they show up in the exception message. The engine stays usable afterwards.Behavior change: precompiled code that doesn't deliver a result, for example code not built with
compilePortableGuestFunction, now throws instead of returningnullor a stale value.