001    package ca.discotek.feenix.asm;
002    
003    import ca.discotek.rebundled.org.objectweb.asm.ClassWriter;
004    import ca.discotek.rebundled.org.objectweb.asm.MethodVisitor;
005    import ca.discotek.rebundled.org.objectweb.asm.Opcodes;
006    
007    public class InterfaceGenerator {
008    
009        public static final String INVOKE_METHOD_NAME = "__invoke__";
010        
011        public static byte[] generate(String interfaceName, String invokerType) {
012            ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
013            
014            cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC | Opcodes.ACC_INTERFACE, interfaceName, null, "java/lang/Object", null);
015            
016            MethodVisitor mv = 
017                cw.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, INVOKE_METHOD_NAME, "(IL" + invokerType + ";[Ljava/lang/Object;)Ljava/lang/Object;", null, null);
018            mv.visitEnd();
019            
020            cw.visitEnd();
021            
022            return cw.toByteArray();
023        }
024    }