001    package org.shiftone.jrat.inject.bytecode.asm;
002    
003    
004    import org.objectweb.asm.MethodAdapter;
005    import org.objectweb.asm.MethodVisitor;
006    import org.objectweb.asm.Opcodes;
007    import org.shiftone.jrat.util.log.Logger;
008    
009    
010    /**
011     * All this visitor does is add a single instruction to the start of the static
012     * intitializer to call the JRat initializer method.
013     *
014     * @author jeff@shiftone.org (Jeff Drost)
015     */
016    public class ClassInitMethodVisitor extends MethodAdapter implements Constants {
017    
018        private static final Logger LOG = Logger.getLogger(ClassInitMethodVisitor.class);
019        private String className;
020    
021        public ClassInitMethodVisitor(String className, MethodVisitor mv) {
022    
023            super(mv);
024    
025            this.className = className;
026        }
027    
028    
029        public void visitCode() {
030            super.visitMethodInsn(Opcodes.INVOKESTATIC, className, initializeName, "()V");
031            super.visitCode();
032        }
033    }