package jnius;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class NativeInvocationHandler implements InvocationHandler {
    public NativeInvocationHandler(long ptr) {
        this.ptr = ptr;
    }

    public Object invoke(Object proxy, Method method, Object[] args) {
        /**
        if ( method.getName() == "toString" ) {
            System.out.println("+ java:invoke toString.");
            return "<proxy>";
        }
        /**/
        System.out.print("+ java:invoke(<proxy>, ");
        // don't call it, or recursive lookup/proxy will go!
        //System.out.print(proxy);
        //System.out.print(", ");
        System.out.print(method);
        System.out.print(", ");
        System.out.print(args);
        System.out.println(")");
        System.out.flush();

        //System.out.print("+ java:call native invoke0() >>>");
        Object ret = invoke0(proxy, method, args);
        //System.out.println("+ java:call native invoke0() <<<");

        System.out.print("+ java:invoke returned: ");
        System.out.println(ret);
        return ret;
    }

    native Object invoke0(Object proxy, Method method, Object[] args);

    private long ptr;
}

@@ -154,16 +154,73 @@
 ndler %7B%0A
+    static boolean DEBUG = false;%0A    private long ptr;%0A%0A
     publ
@@ -372,172 +372,27 @@
     
-/**%0A        if ( method.getName() == %22toString%22 ) %7B%0A            System.out.println(%22+ java:invoke toString.%22);%0A            return %22%3Cproxy%3E%22;%0A        %7D%0A        /**/%0A
+if ( DEBUG ) %7B%0A    
     
@@ -436,24 +436,28 @@
 proxy%3E, %22);%0A
+    
         // d
@@ -505,32 +505,36 @@
 ill go!%0A        
+    
 //System.out.pri
@@ -544,32 +544,36 @@
 proxy);%0A        
+ 
+   
 //System.out.pri
@@ -582,32 +582,36 @@
 (%22, %22);%0A        
+  
+  
 System.out.print
@@ -620,32 +620,36 @@
 ethod);%0A        
+   
+ 
 System.out.print
@@ -648,32 +648,36 @@
 ut.print(%22, %22);%0A
+    
         System.o
@@ -692,32 +692,36 @@
 (args);%0A        
+ 
+   
 System.out.print
@@ -729,32 +729,36 @@
 n(%22)%22);%0A        
+  
+  
 System.out.flush
@@ -761,25 +761,24 @@
 lush();%0A
-%0A
         
 //System
@@ -773,63 +773,10 @@
     
-//System.out.print(%22+ java:call native invoke0() %3E%3E%3E%22);
+%7D%0A
 %0A   
@@ -823,24 +823,25 @@
  args);%0A
+%0A
         
 //System
@@ -836,67 +836,27 @@
     
-//System.out.println(%22+ java:call native invoke0() %3C%3C%3C%22);%0A%0A
+if ( DEBUG ) %7B%0A    
     
@@ -905,32 +905,36 @@
 ed: %22);%0A        
+    
 System.out.print
@@ -942,16 +942,27 @@
 n(ret);%0A
+        %7D%0A%0A
         
@@ -1054,30 +1054,7 @@
 gs);
-%0A%0A    private long ptr;
 %0A%7D%0A

add DEBUG boolean in the java class