Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
BEGIN LICENSE BLOCK ***** Version: CPL 1.0/GPL 2.0/LGPL 2.1 The contents of this file are subject to the Common Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.eclipse.org/legal/cpl-v10.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyright (C) 2006 Ola Bini <ola@ologix.com> Alternatively, the contents of this file may be used under the terms of either of the GNU General Public License Version 2 or later (the "GPL"), or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which case the provisions of the GPL or the LGPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of either the GPL or the LGPL, and not to allow others to use your version of this file under the terms of the CPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL or the LGPL. If you do not delete the provisions above, a recipient may use your version of this file under the terms of any one of the CPL, the GPL or the LGPL. END LICENSE BLOCK ***
  
  package org.jruby.runtime.callback;
  
  
  import org.jruby.Ruby;
  import  org.objectweb.asm.ClassWriter;
  import  org.objectweb.asm.Label;
  import  org.objectweb.asm.MethodVisitor;
  import  org.objectweb.asm.Opcodes;
  import static org.jruby.util.CodegenUtils.* ;
  
  public class InvocationCallbackFactory extends CallbackFactory implements Opcodes {
      private final Class type;
      protected final JRubyClassLoader classLoader;
      private final String typePath;
      protected final Ruby runtime;
  
      @Deprecated
      private final static String SUPER_CLASS = p(InvocationCallback.class);
      @Deprecated
      private final static String FAST_SUPER_CLASS = p(FastInvocationCallback.class);
      @Deprecated
      private final static String CALL_SIG = sig(.params(Object.class,
              Object[].classBlock.class));
      @Deprecated
      private final static String FAST_CALL_SIG = sig(.params(
              Object.classObject[].class));
      private final static String BLOCK_CALL_SIG = sig(.params(
              ThreadContext.class.IRubyObject.class));
      private final static String BLOCK_CALL_SIG19 = sig(.params(
              ThreadContext.classIRubyObject.classIRubyObject[].classBlock.class));
      private final static String IRUB = p(.);
      
      
      public static final int DISPATCHER_THREADCONTEXT_INDEX = 1;
      public static final int DISPATCHER_SELF_INDEX = 2;
      public static final int DISPATCHER_RUBYMODULE_INDEX = 3;
      public static final int DISPATCHER_METHOD_INDEX = 4;
      public static final int DISPATCHER_NAME_INDEX = 5;
      public static final int DISPATCHER_ARGS_INDEX = 6;
      public static final int DISPATCHER_CALLTYPE_INDEX = 7;
      public static final int DISPATCHER_BLOCK_INDEX = 8;
      public static final int DISPATCHER_RUNTIME_INDEX = 9;
  
      private static final int METHOD_ARGS_INDEX = 2;
  
      public InvocationCallbackFactory(Ruby runtimefinal Class typeClassLoader classLoader) {
          this. = type;
          if (classLoader instanceof JRubyClassLoader) {
              this. = (JRubyClassLoader)classLoader;
          } else {
             this. = new JRubyClassLoader(classLoader);
         }
         this. = p(type);
         this. = runtime;
         
         SecurityManager sm = System.getSecurityManager();
         if (sm == null) {
             this. = type.getProtectionDomain();
         } else {
             this. = AccessController.doPrivileged(
                     new PrivilegedAction<ProtectionDomain>() {
                         public ProtectionDomain run() {
                             return type.getProtectionDomain();
                         }
                     });
         }
     }
 
     @Deprecated
     private Class getReturnClass(String methodClass[] argsthrows Exception {
         return .getMethod(methodargs).getReturnType();
     }
 
     @Deprecated
     private ClassWriter createCtor(String namePaththrows Exception {
         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
         cw.visit(V1_4, ACC_PUBLIC + ACC_SUPER, namePathnullnull);
         MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>""()V"nullnull);
         mv.visitCode();
         mv.visitVarInsn(ALOAD, 0);
         mv.visitMethodInsn(INVOKESPECIAL, "<init>""()V");
         Label line = new Label();
         mv.visitLineNumber(0, line);
         mv.visitInsn(RETURN);
         mv.visitMaxs(1, 1);
         mv.visitEnd();
         return cw;
     }
 
     @Deprecated
     private ClassWriter createCtorFast(String namePaththrows Exception {
         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
         cw.visit(V1_4, ACC_PUBLIC + ACC_SUPER, namePathnullnull);
         MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>""()V"nullnull);
         mv.visitCode();
         mv.visitVarInsn(ALOAD, 0);
         mv.visitMethodInsn(INVOKESPECIAL, "<init>""()V");
         Label line = new Label();
         mv.visitLineNumber(0, line);
         mv.visitInsn(RETURN);
         mv.visitMaxs(1, 1);
         mv.visitEnd();
         return cw;
     }
 
     @Deprecated
     private ClassWriter createBlockCtor(String namePathClass fieldClassthrows Exception {
         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
         cw.visit(., ACC_PUBLIC + ACC_SUPER, namePathnullp(CompiledBlockCallback.class), null);
         cw.visitField(ACC_PRIVATE | ACC_FINAL, "$scriptObject"ci(fieldClass), nullnull);
         SkinnyMethodAdapter mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "<init>"sig(.params(Object.class)), nullnull);
         mv.start();
         mv.aload(0);
         mv.invokespecial(p(CompiledBlockCallback.class), "<init>"sig(void.class));
         mv.aload(0);
         mv.aload(1);
         mv.checkcast(p(fieldClass));
         mv.putfield(namePath"$scriptObject"ci(fieldClass));
         mv.voidreturn();
         mv.end();
 
         return cw;
     }
 
     @Deprecated
     private ClassWriter createBlockCtor19(String namePathClass fieldClassthrows Exception {
         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
         cw.visit(., ACC_PUBLIC + ACC_SUPER, namePathnullp(Object.class), new String[] {p(CompiledBlockCallback19.class)});
         cw.visitField(ACC_PRIVATE | ACC_FINAL, "$scriptObject"ci(fieldClass), nullnull);
         SkinnyMethodAdapter mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC, "<init>"sig(.params(Object.class)), nullnull);
         mv.start();
         mv.aload(0);
         mv.invokespecial(p(Object.class), "<init>"sig(void.class));
         mv.aload(0);
         mv.aload(1);
         mv.checkcast(p(fieldClass));
         mv.putfield(namePath"$scriptObject"ci(fieldClass));
         mv.voidreturn();
         mv.end();
         
         return cw;
     }
 
     @Deprecated
     private Class tryClass(String name) {
         try {
             return .loadClass(name);
         } catch (Exception e) {
             return null;
         }
     }
 
     @Deprecated
     private MethodVisitor startCall(ClassWriter cw) {
         MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "call"nullnull);
         
         mv.visitCode();
         Label line = new Label();
         mv.visitLineNumber(0, line);
         mv.visitVarInsn(ALOAD, 1);
         mv.visitTypeInsn(CHECKCAST, );
         return mv;
     }
 
     @Deprecated
     private MethodVisitor startCallS(ClassWriter cw) {
         MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "call"nullnull);
         
         mv.visitCode();
         Label line = new Label();
         mv.visitLineNumber(0, line);
         mv.visitVarInsn(ALOAD, 1);
         checkCast(mvIRubyObject.class);
         return mv;
     }
 
     @Deprecated
     private MethodVisitor startCallFast(ClassWriter cw) {
         MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "call"nullnull);
         
         mv.visitCode();
         Label line = new Label();
         mv.visitLineNumber(0, line);
         mv.visitVarInsn(ALOAD, 1);
         mv.visitTypeInsn(CHECKCAST, );
         return mv;
     }
 
     @Deprecated
     private MethodVisitor startDispatcher(ClassWriter cw) {
         MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "callMethod"sig(IRubyObject.classparams(ThreadContext.classIRubyObject.classRubyClass.class.String.class,
                 IRubyObject[].classCallType.classBlock.class)), nullnull);
         
         mv.visitCode();
         Label line = new Label();
         mv.visitLineNumber(0, line);
         mv.visitVarInsn(ALOAD, 2);
         mv.visitTypeInsn(CHECKCAST, );
         return mv;
     }
 
     @Deprecated
     private MethodVisitor startCallSFast(ClassWriter cw) {
         MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "call"nullnull);
         
         mv.visitCode();
         Label line = new Label();
         mv.visitLineNumber(0, line);
         mv.visitVarInsn(ALOAD, 1);
         mv.visitTypeInsn(CHECKCAST, );
         return mv;
     }
 
     @Deprecated
     private SkinnyMethodAdapter startBlockCall(ClassWriter cw) {
         SkinnyMethodAdapter mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_SYNTHETIC | ACC_FINAL, "call"nullnull);
         
         mv.visitCode();
         Label line = new Label();
         mv.visitLineNumber(0, line);
         return mv;
     }
 
     @Deprecated
     private SkinnyMethodAdapter startBlockCall19(ClassWriter cw) {
         SkinnyMethodAdapter mv = new SkinnyMethodAdapter(cw, ACC_PUBLIC | ACC_SYNTHETIC | ACC_FINAL, "call"nullnull);
 
         mv.visitCode();
         Label line = new Label();
         mv.visitLineNumber(0, line);
         return mv;
     }
 
     @Deprecated
     protected Class endCall(ClassWriter cw, MethodVisitor mvString name) {
         mv.visitEnd();
         cw.visitEnd();
         byte[] code = cw.toByteArray();
         return .defineClass(namecode);
     }
 
     @Deprecated
     public Callback getMethod(String method) {
         String mname = .getName() + "Callback$" + method + "_0";
         String mnamePath =  + "Callback$" + method + "_0";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     Class[] signature = new Class[] { Block.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCall(cw);
                     
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(1, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.noArguments());
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getMethod(String methodClass arg1) {
         String mname = .getName() + "Callback$" + method + "_1";
         String mnamePath =  + "Callback$" + method + "_1";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] {arg1};
                 if (c == null) {
                     Class[] signature = new Class[] { arg1Block.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCall(cw);
                     
                     loadArguments(mv, 1, descriptor);
 
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(3, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.singleArgument());
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getMethod(String methodClass arg1Class arg2) {
         String mname = .getName() + "Callback$" + method + "_2";
         String mnamePath =  + "Callback$" + method + "_2";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] { arg1arg2 };
                 if (c == null) {
                     Class[] signature = new Class[] { arg1arg2Block.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCall(cw);
                     
                     loadArguments(mv, 2, descriptor);
 
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(4, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.twoArguments());
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
     
     @Deprecated
     public Callback getMethod(String methodClass arg1Class arg2Class arg3) {
         String mname = .getName() + "Callback$" + method + "_3";
         String mnamePath =  + "Callback$" + method + "_3";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] { arg1arg2arg3 }; 
                 if (c == null) {
                     Class[] signature = new Class[] { arg1arg2arg3Block.class }; 
                     Class ret = getReturnClass(method,
                             descriptor);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCall(cw);
                     
                     loadArguments(mv, 3, descriptor);
                     
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(5, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.fixed(3));
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getSingletonMethod(String method) {
         String mname = .getName() + "Callback$" + method + "S0";
         String mnamePath =  + "Callback$" + method + "S0";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     Class[] signature = new Class[] { .Block.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCallS(cw);
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(1, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.noArguments());
                 ic.setJavaName(method);
                 ic.setSingleton(true);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getSingletonMethod(String methodClass arg1) {
         String mname = .getName() + "Callback$" + method + "_S1";
         String mnamePath =  + "Callback$" + method + "_S1";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] {arg1};
                 if (c == null) {
                     Class[] signature = new Class[] { .arg1Block.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCallS(cw);
                     
                     loadArguments(mv, 1, descriptor);
 
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(3, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.singleArgument());
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 ic.setSingleton(true);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getSingletonMethod(String methodClass arg1Class arg2) {
         String mname = .getName() + "Callback$" + method + "_S2";
         String mnamePath =  + "Callback$" + method + "_S2";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] {arg1arg2};
                 if (c == null) {
                     Class[] signature = new Class[] { .arg1arg2Block.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCallS(cw);
                     
                     loadArguments(mv, 2, descriptor);
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(4, 4);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.twoArguments());
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 ic.setSingleton(true);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getSingletonMethod(String methodClass arg1Class arg2Class arg3) {
         String mname = .getName() + "Callback$" + method + "_S3";
         String mnamePath =  + "Callback$" + method + "_S3";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] {arg1arg2arg3};
                 if (c == null) {
                     Class[] signature = new Class[] { .arg1arg2arg3Block.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCallS(cw);
                     
                     loadArguments(mv, 3, descriptor);
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(5, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.fixed(3));
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 ic.setSingleton(true);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getBlockMethod(String method) {
         // TODO: This is probably BAD...
         return new ReflectionCallback(methodnew Class[] { .,
                 . }, falsetrue, Arity.fixed(2), false);
     }
 
     @Deprecated
     public CompiledBlockCallback getBlockCallback(String methodObject scriptObject) {
         Class typeClass = scriptObject.getClass();
         String typePathString = p(typeClass);
         String mname = typeClass.getName() + "BlockCallback$" + method + "xx1";
         String mnamePath = typePathString + "BlockCallback$" + method + "xx1";
         synchronized () {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     ClassWriter cw = createBlockCtor(mnamePathtypeClass);
                     SkinnyMethodAdapter mv = startBlockCall(cw);
                     mv.aload(0);
                     mv.getfield(mnamePath"$scriptObject"ci(typeClass));
                     mv.aload(1);
                     mv.aload(2);
                     mv.aload(3);
                     mv.invokestatic(typePathStringmethodsig(
                             ."L" + typePathString + ";"ThreadContext.class,
                                     .IRubyObject.class));
                     mv.areturn();
                     
                     mv.visitMaxs(2, 3);
                     c = endCall(cwmvmname);
                 }
                 CompiledBlockCallback ic = (CompiledBlockCallbackc.getConstructor(Object.class).newInstance(scriptObject);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 e.printStackTrace();
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public CompiledBlockCallback19 getBlockCallback19(String methodObject scriptObject) {
         Class typeClass = scriptObject.getClass();
         String typePathString = p(typeClass);
         String mname = typeClass.getName() + "BlockCallback$" + method + "xx1";
         String mnamePath = typePathString + "BlockCallback$" + method + "xx1";
         synchronized () {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     ClassWriter cw = createBlockCtor19(mnamePathtypeClass);
                     SkinnyMethodAdapter mv = startBlockCall19(cw);
                     mv.aload(0);
                     mv.getfield(mnamePath"$scriptObject"ci(typeClass));
                     mv.aload(1);
                     mv.aload(2);
                     mv.aload(3);
                     mv.aload(4);
                     mv.invokestatic(typePathStringmethodsig(
                             IRubyObject.class"L" + typePathString + ";"ThreadContext.class,
                                     IRubyObject.classIRubyObject[].classBlock.class));
                     mv.areturn();
 
                     mv.visitMaxs(2, 3);
                     c = endCall(cwmvmname);
                 }
                 CompiledBlockCallback19 ic = (CompiledBlockCallback19c.getConstructor(Object.class).newInstance(scriptObject);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 e.printStackTrace();
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getOptSingletonMethod(String method) {
         String mname = .getName() + "Callback$" + method + "_Sopt";
         String mnamePath =  + "Callback$" + method + "_Sopt";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     Class[] signature = new Class[] { .IRubyObject[].classBlock.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCallS(cw);
                     
                     mv.visitVarInsn(ALOAD, );
                     checkCast(mvIRubyObject[].class);
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(2, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.optional());
                 ic.setArgumentTypes(.);
                 ic.setJavaName(method);
                 ic.setSingleton(true);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getOptMethod(String method) {
         String mname = .getName() + "Callback$" + method + "_opt";
         String mnamePath =  + "Callback$" + method + "_opt";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     Class[] signature = new Class[] { IRubyObject[].classBlock.class };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtor(mnamePath);
                     MethodVisitor mv = startCall(cw);
                     
                     mv.visitVarInsn(ALOAD, );
                     checkCast(mvIRubyObject[].class);
                     mv.visitVarInsn(ALOAD, 3);
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(2, 3);
                     c = endCall(cwmvmname);
                 }
                 InvocationCallback ic = (InvocationCallbackc.newInstance();
                 ic.setArity(Arity.optional());
                 ic.setArgumentTypes(.);
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getFastMethod(String method) {
         String mname = .getName() + "Callback$" + method + "_F0";
         String mnamePath =  + "Callback$" + method + "_F0";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     Class ret = getReturnClass(methodnew Class[0]);
                     ClassWriter cw = createCtorFast(mnamePath);
                     MethodVisitor mv = startCallFast(cw);
 
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(ret));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(1, 3);
                     c = endCall(cwmvmname);
                 }
                 FastInvocationCallback ic = (FastInvocationCallbackc.newInstance();
                 ic.setArity(Arity.noArguments());
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getFastMethod(String methodClass arg1) {
         String mname = .getName() + "Callback$" + method + "_F1";
         String mnamePath =  + "Callback$" + method + "_F1";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] { arg1 };
                 if (c == null) {
                     Class[] signature = descriptor;
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtorFast(mnamePath);
                     MethodVisitor mv = startCallFast(cw);
                     
                     loadArguments(mv, 1, descriptor);
 
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(3, 3);
                     c = endCall(cwmvmname);
                 }
                 FastInvocationCallback ic = (FastInvocationCallbackc.newInstance();
                 ic.setArity(Arity.singleArgument());
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getFastMethod(String methodClass arg1Class arg2) {
         String mname = .getName() + "Callback$" + method + "_F2";
         String mnamePath =  + "Callback$" + method + "_F2";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] { arg1arg2 };
                 if (c == null) {
                     Class[] signature = descriptor;
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtorFast(mnamePath);
                     MethodVisitor mv = startCallFast(cw);
                     
                     loadArguments(mv, 2, descriptor);
 
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(4, 3);
                     c = endCall(cwmvmname);
                 }
                 FastInvocationCallback ic = (FastInvocationCallbackc.newInstance();
                 ic.setArity(Arity.twoArguments());
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getFastMethod(String methodClass arg1Class arg2Class arg3) {
         String mname = .getName() + "Callback$" + method + "_F3";
         String mnamePath =  + "Callback$" + method + "_F3";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] { arg1arg2arg3 };
                 if (c == null) {
                     Class[] signature = descriptor;
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtorFast(mnamePath);
                     MethodVisitor mv = startCallFast(cw);
                     
                     loadArguments(mv, 3, descriptor);
 
                     mv.visitMethodInsn(INVOKEVIRTUAL, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(5, 3);
                     c = endCall(cwmvmname);
                 }
                 FastInvocationCallback ic = (FastInvocationCallbackc.newInstance();
                 ic.setArity(Arity.fixed(3));
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getFastSingletonMethod(String method) {
         String mname = .getName() + "Callback$" + method + "_FS0";
         String mnamePath =  + "Callback$" + method + "_FS0";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 if (c == null) {
                     Class[] signature = new Class[] { . };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtorFast(mnamePath);
                     MethodVisitor mv = startCallSFast(cw);
 
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(1, 3);
                     c = endCall(cwmvmname);
                 }
                 FastInvocationCallback ic = (FastInvocationCallbackc.newInstance();
                 ic.setArity(Arity.noArguments());
                 ic.setJavaName(method);
                 ic.setSingleton(true);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getFastSingletonMethod(String methodClass arg1) {
         String mname = .getName() + "Callback$" + method + "_FS1";
         String mnamePath =  + "Callback$" + method + "_FS1";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] {arg1};
                 if (c == null) {
                     Class[] signature = new Class[] { .arg1 };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtorFast(mnamePath);
                     MethodVisitor mv = startCallSFast(cw);
                     
                     loadArguments(mv, 1, descriptor);
 
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(3, 3);
                     c = endCall(cwmvmname);
                 }
                 FastInvocationCallback ic = (FastInvocationCallbackc.newInstance();
                 ic.setArity(Arity.singleArgument());
                 ic.setArgumentTypes(descriptor);
                 ic.setJavaName(method);
                 ic.setSingleton(true);
                 return ic;
             } catch (IllegalArgumentException e) {
                 throw e;
             } catch (Exception e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
     }
 
     @Deprecated
     public Callback getFastSingletonMethod(String methodClass arg1Class arg2) {
         String mname = .getName() + "Callback$" + method + "_FS2";
         String mnamePath =  + "Callback$" + method + "_FS2";
         synchronized (.getJRubyClassLoader()) {
             Class c = tryClass(mname);
             try {
                 Class[] descriptor = new Class[] {arg1arg2};
                 if (c == null) {
                     Class[] signature = new Class[] { .arg1arg2 };
                     Class ret = getReturnClass(methodsignature);
                     ClassWriter cw = createCtorFast(mnamePath);
                     MethodVisitor mv = startCallSFast(cw);
                     
                     loadArguments(mv, 2, descriptor);
 
                     mv.visitMethodInsn(INVOKESTATIC, methodsig(retsignature));
                     mv.visitInsn(ARETURN);
                     mv.visitMaxs(4, 4);
                     c = endCall(cwmvmname);
                 }
                 FastInvocationCallback ic = (FastInvocationCallbackc.newInstance();
                 ic.setArity(Arity.twoArguments());