final Ruby ruby = getRuntime();
if (!asClass.isInterface()) {
throw ruby.newTypeError(asClass.getCanonicalName() + " is not an interface");
}
return MiniJava.javaToRuby(ruby, Proxy.newProxyInstance(Ruby.getClassLoader(), new Class[] {asClass}, new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
IRubyObject[] rubyArgs = new IRubyObject[args.length + 1];
rubyArgs[0] = RubySymbol.newSymbol(ruby, method.getName());
for (int i = 1; i < rubyArgs.length; i++) {
rubyArgs[i] = MiniJava.javaToRuby(ruby, args[i - 1]);