It appears that getWindow
returns a new JSObject
which describes the window. So each call to getWindow
is a new instance, but with the same data, so equals returns false. Both JSObjects describe the window, but are not the same object.
public class MyClass
{
int a;
public MyClass(int arg)
{
a = arg;
}
public MyClass getMyClass()
{
return new MyClass(a);
}
public static void main(String args[])
{
MyClass parent = new MyClass(1);
MyClass obj1 = parent.getMyClass();
MyClass obj2 = parent.getMyClass();
System.out.println(obj1.equals(obj2));
}
}
This prints false, because even though the objects have the same value in them, they are still different objects.
Edit: updated to use a get
method to make it clearer.