Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for lambda-based native functions #865

Merged
merged 3 commits into from
Apr 16, 2021
Merged

Conversation

gbrail
Copy link
Collaborator

@gbrail gbrail commented Apr 15, 2021

This introduces LambdaFunction and LambdaConstructor, which can be used
to represent Java lambda functions as native JavaScript functions,
and also can be used to construct an entire class out of lambdas.

This pattern is a more direct representation of the JavaScript object
model to Java than the existing reflection mechanism, and it is usable
with far less code than the IdScriptableObject class. It also outperforms
both in microbenchmarks.

This just adds the new classes -- I'm hoping to use them to get Promises working very soon. The test in this PR, and the benchmark, show how the new classes might be used to implement new native classes. This all seems easier to me than what we have today -- PTAL and let me know if you agree.

This introduces LambdaFunction and LambdaConstructor, which can be used
to represent Java lambda functions as native JavaScript functions,
and also can be used to construct an entire class out of lambdas.

This pattern is a more direct representation of the JavaScript object
model to Java than the existing reflection mechanism, and it is usable
with far less code than the IdScriptableObject class. It also outperforms
both in microbenchmarks.
@gbrail gbrail merged commit 68fed7b into master Apr 16, 2021
@p-bakker p-bakker added enhancement Java Interop Issues related to the interaction between Java and JavaScript labels Oct 13, 2021
@p-bakker p-bakker added this to the Release 1.7.14 milestone Oct 13, 2021
@p-bakker p-bakker added Performance Issues related to the performance of the Rhino engine embedding Rhino Issues related to enbedding Rhino and removed Java Interop Issues related to the interaction between Java and JavaScript labels Oct 13, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
embedding Rhino Issues related to enbedding Rhino enhancement Performance Issues related to the performance of the Rhino engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants