Reputation: 103
in nashorn, i try to accomplish something like this
a.test = function(key){print(key);};
but variable a is java entity(pojo), when i do
a.test( "someting" );
it give me error
amavisca.monsterpuzzle.entity.a@adfbc1 has no such function "test"
my question :
how to add java pojo, new properties in nashorn?
example :
a.test = function(key){print(key);};
Upvotes: 1
Views: 231
Reputation: 4595
You can't. POJOs in Nashorn act as if they were sealed JS objects (they are non-extensible and their properties are non-configurable, same as if they had Object.seal(obj)
called on them).
Upvotes: 2