X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/7341eedbaf526ef2f0986b576c656906050e270a..9ec2b9397cc7a924bb0aa9a44ba3747fd32fa36d:/Java/Cycript.java

diff --git a/Java/Cycript.java b/Java/Cycript.java
index cf1cc8e..8fb7817 100644
--- a/Java/Cycript.java
+++ b/Java/Cycript.java
@@ -62,22 +62,36 @@ public static class Wrapper
         return protect_;
     }
 
+    public Object call(String property, Object[] arguments) {
+        try {
+            return handle(protect_, property, arguments);
+        } catch (Throwable throwable) {
+            return new RuntimeException(throwable);
+        }
+    }
+
+    public String toString() {
+        return call("toString", null).toString();
+    }
+
     public Object invoke(Object proxy, Method method, Object[] args)
         throws Throwable
     {
         if (false)
             return null;
         else if (method.equals(Object$equals))
+            // XXX: this assumes there is only one proxy
             return proxy == args[0];
         else if (method == Object$hashCode)
-            return System.identityHashCode(proxy);
+            // XXX: this assumes there is only one wrapper
+            return hashCode();
         else
             return handle(protect_, method.getName(), args);
     }
 }
 
-public static Object proxy(Class proxy, long protect) {
-    return Proxy.newProxyInstance(proxy.getClassLoader(), new Class[] {proxy}, new Wrapper(protect));
+public static Object proxy(Class proxy, Wrapper wrapper) {
+    return Proxy.newProxyInstance(proxy.getClassLoader(), new Class[] {proxy}, wrapper);
 }
 
 }