ability to inject custom properties into a JS object

Radu Cotescu radu at cotescu.com
Mon Jun 15 12:12:58 UTC 2015


I've recently started looking into replacing Rhino with Nashorn as the
JavaScript scripting engine for Apache Sling (see SLING-4801 [0]).

Once nice Rhino feature that I don't seem to be able to easily map to
something from Nashorn is the ability to provide my own object wrappers,
such that the resulting JS object contains some custom properties. I did
notice this thread [1] but I wasn't able to reach to a conclusion regarding
this feature.

Is there a way to easily implement this custom object translation layer
without having to implement a JSObject? The problem with this approach is
that Sling script developers will have to use these custom wrapper classes
(JSObjects) instead of the APIs directly available through the Bindings,
making scripts written for the Rhino implementation incompatible.


[0] - https://issues.apache.org/jira/browse/SLING-4801
[1] -

More information about the nashorn-dev mailing list