I’m working in the Rhino JavaScript engine (implemented in Java) in a context where a Java object has been shared into my JavaScript code’s runtime. It seems the object is somehow simultaneously an instance of two different classes.
When I use instanceof
to try and find out what kind of object it is, it passes for two different classes:
foreignObject instanceof Packages.java.lang.String; // true
foreignObject instanceof GlideElement; // true
How could this have been implemented? Is there a pure Java way to get an object to pass both these instanceof
tests? Is there some other kind of magic going on here specific to the Rhino JavaScript engine?