// list of interfaces we implement
singleton.addReadAttribute(context, "java_interfaces");
// We capture the original "new" and make it private
DynamicMethod newMethod = singleton.searchMethod("new").dup();
singleton.addMethod("__jredef_new", newMethod);
newMethod.setVisibility(Visibility.PRIVATE);
// The replacement "new" allocates and inits the Ruby object as before, but
// also instantiates our proxified Java object by calling __jcreate!
singleton.addMethod("new", new org.jruby.internal.runtime.methods.JavaMethod(singleton, Visibility.PUBLIC) {
@Override