I use e.g.
context.getBindings("js").putMember("thing", new Thing(this));
to define a variable for my javascript.
How can I expose Java's Math
""""object""""?
I can't do
context.getBindings("js").putMember("math", Math);
nor
context.getBindings("js").putMember("math", new Math());
(bc the constructor is private)
Even using reflection like this to pass it
Doesn't work in the end, because graaljs doesn't make static properties of Java host objects visible to the JavaScript.
So the solution is to use the
.static
property ofMath.class
As I learnt here