reflecting on JS functions/objects

Michael Roberts mike at 7f.com
Fri Oct 18 15:30:00 PDT 2013


Hi, I am looking at Nashorn for the first time and have a lightweight
question.

One thing which springs immediately to mind is the need to reflect on the
contents of a js script.  I.e., I might do something trivial like :

ScriptEngine e = (new ScriptEngineManager).getEngineByName("nashorn");
e.eval("function foo() { return -1; }; function foo2() { return 0; }");

I'd then like to enumerate through the functions the script defined so I
can create an external binding to them, without knowing beforehand that my
script contains foo and foo2, as the examples I have seen do.  Does this
exist currently and if so, where should I be looking?

best regards

M


More information about the nashorn-dev mailing list