Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add nullable JS API parameter support #1756

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

drubanovich-soti
Copy link
Contributor

This change allows to define JS APIs which receive nullable primitive type parameters. E.g. before the change it was not possible to pass null to JS function with string parameter, instead the function received a string "null".

As standard Java doesn't have nullable types, this feature currently can only be used if the files are written in Kotlin. Kotlin metadata library is used to detect nullable parameter types.

@drubanovich-soti
Copy link
Contributor Author

drubanovich-soti commented Dec 13, 2024

I would like to run this idea with you before I fix the module (it doesn't export Kotlin dependencies, so the clients will need to explicitly add those) and add unit tests.
Thanks!

This change allows to define JS APIs which receive nullable primitive
type parameters. E.g. before the change it was not possible to pass
null to JS function with string parameter, instead the function
received a string "null".

As standard Java doesn't have nullable types, this feature currently
can only be used if the files are written in Kotlin. Kotlin metadata
library is used to detect nullable parameter types.
@gbrail
Copy link
Collaborator

gbrail commented Dec 14, 2024

Thanks for working on this! This is an interesting idea, and it'd be great to have Rhino work better with Kotlin.

However, right now Rhino has no dependencies, and I think it's important that we keep it that way. This PR makes Rhino depend on a Kotlin package. I don't know how intrusive that is (like how many nested dependencies it brings in) but I'm still very reluctant to make a core library like this something that Rhino requires.

Is there another way to do this, like making the dependency optional and searching for it via reflection, or adding a "rhino-kotlin" module that's loaded via ServiceLoader, or incorporating the part of the Kotlin library that Rhino needs in to the project directly?

@drubanovich-soti
Copy link
Contributor Author

Sure Greg, if you like the idea, I will work on a proper implementation.
I'll try your ServiceLoader suggestion with Kotlin-specific implementation in a new "rhino-kotlin" module.

@gbrail
Copy link
Collaborator

gbrail commented Dec 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants