Skip to content

Commit d1f9524

Browse files
committed
Update NodeDynamicProxy.java to compare Proxy rather than InvocationHandler. Update dynamicProxy-test accordingly.
1 parent d502320 commit d1f9524

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed
178 Bytes
Binary file not shown.

src-java/node/NodeDynamicProxyClass.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package node;
22

33
import java.lang.reflect.Method;
4-
import java.lang.reflect.Proxy;
54

65
public class NodeDynamicProxyClass implements java.lang.reflect.InvocationHandler {
76
private static final Method EQUALS;
@@ -43,9 +42,9 @@ public Object invoke(Object proxy, java.lang.reflect.Method m, Object[] args) th
4342
// 'this', not the 'proxy' argument, so we operate on this.
4443
if (EQUALS.equals(m)) {
4544
// need to check if the arg is a Proxy, and if so, if its invocation handler == this!
46-
return Proxy.isProxyClass(args[0].getClass()) && Proxy.getInvocationHandler(args[0]) == this;
45+
return args[0] == proxy;
4746
} else if (HASHCODE.equals(m)) {
48-
return System.identityHashCode(this);
47+
return System.identityHashCode(proxy);
4948
}
5049
throw e;
5150
}

test/dynamicProxy-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ exports['Dynamic Proxy'] = nodeunit.testCase({
157157
var runInterface = java.newInstanceSync("RunInterface");
158158
var result = runInterface.runHashCodeSync(myProxy);
159159
var result2 = runInterface.runHashCodeSync(myProxy);
160+
var systemHashCode = java.callStaticMethodSync("java.lang.System", "identityHashCode", myProxy);
160161

161162
test.equals(result, result2);
163+
test.equals(result, systemHashCode);
162164

163165
test.done();
164166
},

0 commit comments

Comments
 (0)