Skip to content

Fix https://github.com/joeferner/node-java/issues/143#152

Merged
joeferner merged 2 commits into
joeferner:masterfrom
facboy:master
Aug 31, 2014
Merged

Fix https://github.com/joeferner/node-java/issues/143#152
joeferner merged 2 commits into
joeferner:masterfrom
facboy:master

Conversation

@facboy
Copy link
Copy Markdown
Contributor

@facboy facboy commented Aug 30, 2014

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.

facboy added 2 commits August 30, 2014 03:05
…ng.Object if they are not defined on the js proxy.
@facboy
Copy link
Copy Markdown
Contributor Author

facboy commented Aug 30, 2014

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.

joeferner added a commit that referenced this pull request Aug 31, 2014
@joeferner joeferner merged commit b46f4bb into joeferner:master Aug 31, 2014
@joeferner
Copy link
Copy Markdown
Owner

Thanks for the pull request.

Where do you see the new proxy being created each time?

@facboy
Copy link
Copy Markdown
Contributor Author

facboy commented Aug 31, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using java.newProxy instance from another thread causes assert error

2 participants