Open botic opened 2 years ago
Rewriting this will be fun. The org.ringojs.wrappers.Binary
class relies on initialization as host object inside the current RhinoEngine instance. The Java implementation of Binary
registers the ByteArray
and ByteString
subtypes in a Rhino lifecycle hook with:
initClass(scope, prototype, Type.ByteArray);
initClass(scope, prototype, Type.ByteString);
I haven't found why these must be host objects of the engine. But I guess it's because there of CommonJS' Binary/B:
In multi-sandbox scenarios, the implementation should strive to consistently export the same "Binary", "ByteArray", and "ByteString"
The
io
module introducesByteArray
andByteString
viadefineClass()
. This adds both to the engine's global host objects. This prevents usingconst
in the context of i/o.I don't see a chance to fix this anyway, but leave this as an issue to discuss for the future. Maybe we find a non-radical solution to this problem.