Fix https://github.com/joeferner/node-java/issues/143#152
Conversation
Fix joeferner#150 breaking gyp on Windows.
…ng.Object if they are not defined on the js proxy.
|
I've made the equals/hashCode methods for dynamic proxies equivalent to Object.equals and Object.hashCode if the js object doesn't define equals or hashCode. Ie if on separate calls into Java you pass in the same object on the js code, they should be equal and they should produce the same hash code. The implementation is perhaps a bit unintuitive in that you must operate on the java InvocationHandler rather than the java Proxy, as it seems a new Proxy is created for every call into Java. I must admit I don't quite understand the reasoning behind this, it seems a bit wasteful. |
|
Thanks for the pull request. Where do you see the new proxy being created each time? |
|
I believe it's in the v8ToJava conversion code (I haven't checked that that exhaustively), but I can tell it's happening because if I debug Java, each time the method is called with the same object on the Node side, it's a different Proxy object on the Java side. I mean the java.lang.reflect.Proxy is created each time, if that wasn't clear. |
Fixes #143 - the threading bug on Windows. I think it's because the previous code wasn't strictly following the rules on JNI - you can't pass objects (ie the args), nor the JNIEnv across the thread boundary from a Java thread to the V8 main thread.
Also fixes the gyp problems from #150, for Windows at least.