Any way to support expando props on Java objects?

Sundararajan Athijegannathan sundararajan.athijegannathan at oracle.com
Mon Mar 19 14:52:44 UTC 2018


Hi,

Haven't gone through the referred code. Do you want to add more 
properties to a Java object apart from "bean properties" inferred?

If so, you can write your own dynalink linker with jdk9.

See also:

API doc:

https://docs.oracle.com/javase/9/docs/api/jdk.dynalink-summary.html

Sample:

http://hg.openjdk.java.net/jdk9/dev/nashorn/file/17cc754c8936/samples/dynalink/DOMLinkerExporter.java
http://hg.openjdk.java.net/jdk9/dev/nashorn/file/17cc754c8936/samples/dynalink/dom_linker_gutenberg.js
http://hg.openjdk.java.net/jdk9/dev/nashorn/file/17cc754c8936/samples/dynalink/dom_linker.js

Hope this helps,
-Sundar


On 19/03/18, 7:50 PM, Mike Hearn wrote:
> Hello,
>
> Thanks for writing Nashorn, it's useful!
>
> I'm trying to run https://github.com/domchristie/turndown in Nashorn, using
> JSoup to provide a simple DOM, but have hit an issue because Turndown
> expects to be able to add its own properties to DOM objects. This is
> something browsers support but Nashorn doesn't. I do realise that Nashorn's
> approach is allowed by the specs, but I'm wondering if there's any way to
> hack things up such that the library can do what it wants. I can also just
> change the code, but I'm curious if there's a quick fix here.


More information about the nashorn-dev mailing list