Ah, got it.

From: Mike Rettig [mailto:[email protected]]
Sent: Wednesday, September 03, 2014 11:56 AM
To: Bullotta, Rick
Cc: Hannes Wallnoefer; [email protected]
Subject: Re: Inconsistent missing property handling with java objects

How about this example which demonstrates the inconsistent behavior of js 
objects versus java objects?

        ScriptEngineManager engineManager =
                new ScriptEngineManager();
        final ScriptEngine nashorn = engineManager.getEngineByName("nashorn");
        nashorn.eval("'use sctrict'");
        nashorn.eval("var jsD={}");
        nashorn.eval("jsD.badProp=1233");
        nashorn.eval("print(jsD.badProp)");

        nashorn.eval("var d= new java.util.Date()");
        nashorn.eval("d.badProp=4567");
        nashorn.eval("print(d.badProp)");


This prints:

1233
undefined

For the java object, the assignment is allowed to the invalid field, but 
retrieving that value returns 'undefined'.  This is inconsistent with 
javascript objects AND java objects.

Is the intended behavior for nashorn to treat java objects like js objects or 
like POJO's?

Mike

Reply via email to