Map should support hasOwnProperty?
Hannes Wallnöfer
hannes.wallnoefer at oracle.com
Thu Feb 2 17:20:45 UTC 2017
Hi Jörg,
We have currently no plans to make Object.prototype.hasOwnProperty on non-JavaScript objects. However, I recently pushed a change that makes the in-operator work with Java objects, maps, lists, and arrays to JDK 9.
https://bugs.openjdk.java.net/browse/JDK-8173480
Hannes
> Am 02.02.2017 um 16:28 schrieb Frantzius, Jörg <Joerg.Frantzius at aperto.com>:
>
> Hi,
>
> Nashorn’s extensions let Java Map objects behave somewhat like Javascript objects by making its key-values accessible as object properties.
>
> Unfortunately, it seems that hasOwnProperty() is commonly used in Javascript code to iterate the properties of an object, and this doesn’t work on Map objects. Maybe it would be a good idea to also support hasOwnProperty() on Map objects?
>
> Currently it seems impossible to let 3d party Javascript code traverse a a Java object graph with nested Map objects. While I may be able to traverse and convert a Java object graph if it is made from Collections, Arrays and Maps, this will fail as soon as there is a custom Java class involved that has a Map field (that is accessed from Javascript).
>
> Thanks for any thoughts,
> Jörg
>
>
> ---
>
> Dipl. Inf. Jörg von Frantzius, Technical Director
>
> E-Mail joerg.frantzius at aperto.com
>
> Phone +49 30 283921-318
> Fax +49 30 283921-29
>
> Aperto GmbH – An IBM Company
> Chausseestraße 5, D-10115 Berlin
> http://www.aperto.com<http://www.aperto.de/>
> http://www.facebook.com/aperto
> https://www.xing.com/companies/apertoag
>
> HRB 77049 B, AG Berlin Charlottenburg
> Geschäftsführer: Dirk Buddensiek, Kai Großmann, Stephan Haagen, Daniel Simon
>
More information about the nashorn-dev
mailing list