I'm experimenting with multi-threaded scripts loading and evaluation in Nashorn and get kind of shocking behavior:
// having some object o loaded in another thread
print(o.constructor === o.constructor); // false
print(o.constructor === Object); // false as well
print(o.foo === o.foo); // true - OK
How can this be possible within single script engine? o
above is just an object created using object literal notation (in another thread). Printing o.constructor
gives usual function Object() { [native code] };
.
At the same time:
print({}.constructor === {}.constructor); // true
Any ideas?
Update
It turned out this was unrelated to multi-threading at all. See my answer below for details.