List of usage examples for org.objectweb.asm Opcodes ILOAD
int ILOAD
To view the source code for org.objectweb.asm Opcodes ILOAD.
Click Source Link
From source file:com.google.monitoring.runtime.instrumentation.adapters.AllocationMethodAdapter.java
License:Apache License
private void pushProductOfIntArrayOnStack() { final Label beginScopeLabel = new Label(); final Label endScopeLabel = new Label(); final int dimsArrayIndex = newLocal("[I", beginScopeLabel, endScopeLabel); final int counterIndex = newLocal("I", beginScopeLabel, endScopeLabel); final int productIndex = newLocal("I", beginScopeLabel, endScopeLabel); final Label loopLabel = new Label(); final Label endLabel = new Label(); super.visitLabel(beginScopeLabel); // stack: ... intArray super.visitVarInsn(Opcodes.ASTORE, dimsArrayIndex); // -> stack: ... // counter = 0 super.visitInsn(Opcodes.ICONST_0); super.visitVarInsn(Opcodes.ISTORE, counterIndex); // product = 1 super.visitInsn(Opcodes.ICONST_1); super.visitVarInsn(Opcodes.ISTORE, productIndex); // loop:/*from w ww . j av a2s .c om*/ super.visitLabel(loopLabel); // if index >= arraylength goto end: super.visitVarInsn(Opcodes.ILOAD, counterIndex); super.visitVarInsn(Opcodes.ALOAD, dimsArrayIndex); super.visitInsn(Opcodes.ARRAYLENGTH); super.visitJumpInsn(Opcodes.IF_ICMPGE, endLabel); // product = product * max(array[counter],1) super.visitVarInsn(Opcodes.ALOAD, dimsArrayIndex); super.visitVarInsn(Opcodes.ILOAD, counterIndex); super.visitInsn(Opcodes.IALOAD); super.visitInsn(Opcodes.DUP); final Label nonZeroDimension = new Label(); super.visitJumpInsn(Opcodes.IFNE, nonZeroDimension); super.visitInsn(Opcodes.POP); super.visitInsn(Opcodes.ICONST_1); super.visitLabel(nonZeroDimension); super.visitVarInsn(Opcodes.ILOAD, productIndex); super.visitInsn(Opcodes.IMUL); // if overflow happens it happens. super.visitVarInsn(Opcodes.ISTORE, productIndex); // iinc counter 1 super.visitIincInsn(counterIndex, 1); // goto loop super.visitJumpInsn(Opcodes.GOTO, loopLabel); // end: super.visitLabel(endLabel); // re-push dimensions array super.visitVarInsn(Opcodes.ALOAD, dimsArrayIndex); // push product super.visitVarInsn(Opcodes.ILOAD, productIndex); super.visitLabel(endScopeLabel); }
From source file:com.google.monitoring.runtime.instrumentation.adapters.AllocationMethodAdapter.java
License:Apache License
/** * Reflection-based allocation (@see java.lang.reflect.Array#newInstance) is * triggered with a static method call (INVOKESTATIC), so we hook it here. * Class initialization is triggered with a constructor call (INVOKESPECIAL) * so we hook that here too as a proxy for the new bytecode which leaves an * uninitialized object on the stack that we're not allowed to touch. * {@link java.lang.Object#clone} is also a call to INVOKESPECIAL, * and is hooked here. {@link java.lang.Class#newInstance} and * {@link java.lang.reflect.Constructor#newInstance} are both * INVOKEVIRTUAL calls, so they are hooked here, as well. */// ww w . ja v a 2 s .c o m @Override public void visitMethodInsn(final int opcode, final String owner, final String name, final String signature, final boolean itf) { if (opcode == Opcodes.INVOKESTATIC && // Array does its own native allocation. Grr. owner.equals("java/lang/reflect/Array") && name.equals("newInstance")) { if (signature.equals("(Ljava/lang/Class;I)Ljava/lang/Object;")) { final Label beginScopeLabel = new Label(); final Label endScopeLabel = new Label(); super.visitLabel(beginScopeLabel); // stack: ... class count final int countIndex = newLocal("I", beginScopeLabel, endScopeLabel); super.visitVarInsn(Opcodes.ISTORE, countIndex); // -> stack: ... class pushClassNameOnStack(); // -> stack: ... class className final int typeNameIndex = newLocal("Ljava/lang/String;", beginScopeLabel, endScopeLabel); super.visitVarInsn(Opcodes.ASTORE, typeNameIndex); // -> stack: ... class super.visitVarInsn(Opcodes.ILOAD, countIndex); // -> stack: ... class count super.visitMethodInsn(opcode, owner, name, signature, itf); // -> stack: ... newobj super.visitInsn(Opcodes.DUP); // -> stack: ... newobj newobj super.visitVarInsn(Opcodes.ILOAD, countIndex); // -> stack: ... newobj newobj count super.visitInsn(Opcodes.SWAP); // -> stack: ... newobj count newobj super.visitVarInsn(Opcodes.ALOAD, typeNameIndex); super.visitLabel(endScopeLabel); // -> stack: ... newobj count newobj className super.visitInsn(Opcodes.SWAP); // -> stack: ... newobj count className newobj super.visitMethodInsn(Opcodes.INVOKESTATIC, recorderClass, recorderMethod, RECORDER_SIGNATURE, false); // -> stack: ... newobj return; } else if (signature.equals("(Ljava/lang/Class;[I)Ljava/lang/Object;")) { final Label beginScopeLabel = new Label(); final Label endScopeLabel = new Label(); super.visitLabel(beginScopeLabel); final int dimsArrayIndex = newLocal("[I", beginScopeLabel, endScopeLabel); // stack: ... class dimsArray pushProductOfIntArrayOnStack(); // -> stack: ... class dimsArray product final int productIndex = newLocal("I", beginScopeLabel, endScopeLabel); super.visitVarInsn(Opcodes.ISTORE, productIndex); // -> stack: ... class dimsArray super.visitVarInsn(Opcodes.ASTORE, dimsArrayIndex); // -> stack: ... class pushClassNameOnStack(); // -> stack: ... class className final int typeNameIndex = newLocal("Ljava/lang/String;", beginScopeLabel, endScopeLabel); super.visitVarInsn(Opcodes.ASTORE, typeNameIndex); // -> stack: ... class super.visitVarInsn(Opcodes.ALOAD, dimsArrayIndex); // -> stack: ... class dimsArray super.visitMethodInsn(opcode, owner, name, signature, itf); // -> stack: ... newobj super.visitInsn(Opcodes.DUP); // -> stack: ... newobj newobj super.visitVarInsn(Opcodes.ILOAD, productIndex); // -> stack: ... newobj newobj product super.visitInsn(Opcodes.SWAP); // -> stack: ... newobj product newobj super.visitVarInsn(Opcodes.ALOAD, typeNameIndex); super.visitLabel(endScopeLabel); // -> stack: ... newobj product newobj className super.visitInsn(Opcodes.SWAP); // -> stack: ... newobj product className newobj super.visitMethodInsn(Opcodes.INVOKESTATIC, recorderClass, recorderMethod, RECORDER_SIGNATURE, false); // -> stack: ... newobj return; } } if (opcode == Opcodes.INVOKEVIRTUAL) { if ("clone".equals(name) && owner.startsWith("[")) { super.visitMethodInsn(opcode, owner, name, signature, itf); int i = 0; while (i < owner.length()) { if (owner.charAt(i) != '[') { break; } i++; } if (i > 1) { // -> stack: ... newobj super.visitTypeInsn(Opcodes.CHECKCAST, owner); // -> stack: ... arrayref calculateArrayLengthAndDispatch(owner.substring(i), i); } else { // -> stack: ... newobj super.visitInsn(Opcodes.DUP); // -> stack: ... newobj newobj super.visitTypeInsn(Opcodes.CHECKCAST, owner); // -> stack: ... newobj arrayref super.visitInsn(Opcodes.ARRAYLENGTH); // -> stack: ... newobj length super.visitInsn(Opcodes.SWAP); // -> stack: ... length newobj invokeRecordAllocation(owner.substring(i)); } return; } else if ("newInstance".equals(name)) { if ("java/lang/Class".equals(owner) && "()Ljava/lang/Object;".equals(signature)) { super.visitInsn(Opcodes.DUP); // -> stack: ... Class Class super.visitMethodInsn(opcode, owner, name, signature, itf); // -> stack: ... Class newobj super.visitInsn(Opcodes.DUP_X1); // -> stack: ... newobj Class newobj super.visitMethodInsn(Opcodes.INVOKESTATIC, recorderClass, recorderMethod, CLASS_RECORDER_SIG, false); // -> stack: ... newobj return; } else if ("java/lang/reflect/Constructor".equals(owner) && "([Ljava/lang/Object;)Ljava/lang/Object;".equals(signature)) { buildRecorderFromObject(opcode, owner, name, signature, itf); return; } } } if (opcode == Opcodes.INVOKESPECIAL) { if ("clone".equals(name) && "java/lang/Object".equals(owner)) { buildRecorderFromObject(opcode, owner, name, signature, itf); return; } else if ("<init>".equals(name) && outstandingAllocs > 0) { // Tricky because superclass initializers mean there can be more calls // to <init> than calls to NEW; hence outstandingAllocs. --outstandingAllocs; // Most of the time (i.e. in bytecode generated by javac) it is the case // that following an <init> call the top of the stack has a reference ot // the newly-initialized object. But nothing in the JVM Spec requires // this, so we need to play games with the stack to make an explicit // extra copy (and then discard it). dupStackElementBeforeSignatureArgs(signature); super.visitMethodInsn(opcode, owner, name, signature, itf); super.visitLdcInsn(-1); super.visitInsn(Opcodes.SWAP); invokeRecordAllocation(owner); super.visitInsn(Opcodes.POP); return; } } super.visitMethodInsn(opcode, owner, name, signature, itf); }
From source file:com.google.monitoring.runtime.instrumentation.adapters.AllocationMethodAdapter.java
License:Apache License
private void dupStackElementBeforeSignatureArgs(final String sig) { final Label beginScopeLabel = new Label(); final Label endScopeLabel = new Label(); super.visitLabel(beginScopeLabel); final Type[] argTypes = Type.getArgumentTypes(sig); final int[] args = new int[argTypes.length]; for (int i = argTypes.length - 1; i >= 0; --i) { args[i] = newLocal(argTypes[i], beginScopeLabel, endScopeLabel); super.visitVarInsn(argTypes[i].getOpcode(Opcodes.ISTORE), args[i]); }//from w w w .j av a 2s. co m super.visitInsn(Opcodes.DUP); for (int i = 0; i < argTypes.length; ++i) { final int op = argTypes[i].getOpcode(Opcodes.ILOAD); super.visitVarInsn(op, args[i]); if (op == Opcodes.ALOAD) { super.visitInsn(Opcodes.ACONST_NULL); super.visitVarInsn(Opcodes.ASTORE, args[i]); } } super.visitLabel(endScopeLabel); }
From source file:com.google.template.soy.jbcsrc.LocalVariable.java
License:Apache License
@Override void doGen(CodeBuilder mv) { mv.visitVarInsn(resultType().getOpcode(Opcodes.ILOAD), index()); }
From source file:com.google.template.soy.jbcsrc.restricted.LocalVariable.java
License:Apache License
@Override protected void doGen(CodeBuilder mv) { mv.visitVarInsn(resultType().getOpcode(Opcodes.ILOAD), index()); }
From source file:com.google.test.metric.asm.MethodVisitorBuilder.java
License:Apache License
public void visitVarInsn(final int opcode, final int var) { switch (opcode) { case Opcodes.ILOAD: load(var, JavaType.INT); break;//from w w w . j av a 2s .c o m case Opcodes.LLOAD: load(var, JavaType.LONG); break; case Opcodes.FLOAD: load(var, JavaType.FLOAT); break; case Opcodes.DLOAD: load(var, JavaType.DOUBLE); break; case Opcodes.ALOAD: load(var, JavaType.OBJECT); break; case Opcodes.ISTORE: store(var, JavaType.INT); break; case Opcodes.LSTORE: store(var, JavaType.LONG); break; case Opcodes.FSTORE: store(var, JavaType.FLOAT); break; case Opcodes.DSTORE: store(var, JavaType.DOUBLE); break; case Opcodes.ASTORE: store(var, JavaType.OBJECT); break; case Opcodes.RET: recorder.add(new Runnable() { public void run() { block.addOp(new RetSub(lineNumber)); } }); break; default: throw new UnsupportedOperationException("opcode: " + opcode); } }
From source file:com.googlecode.ddom.weaver.compound.CompoundClassGenerator.java
License:Apache License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC, name, desc, signature, exceptions); if (mv != null) { Type[] argumentTypes = Type.getArgumentTypes(desc); mv.visitCode();/* w w w .j a v a 2s . c om*/ Label l0 = new Label(); mv.visitLabel(l0); for (int i = 0; i < componentClasses.length; i++) { String componentClass = Util.classNameToInternalName(componentClasses[i]); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, className, "c" + i, "L" + componentClass + ";"); for (int j = 0; j < argumentTypes.length; j++) { mv.visitVarInsn(argumentTypes[j].getOpcode(Opcodes.ILOAD), j + 1); } mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, ifaceName, name, desc); } mv.visitInsn(Opcodes.RETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "L" + className + ";", null, l0, l1, 0); mv.visitMaxs(argumentTypes.length + 1, argumentTypes.length + 1); mv.visitEnd(); } return null; }
From source file:com.googlecode.ddom.weaver.ext.ModelExtensionClass.java
License:Apache License
public void accept(ClassVisitor classVisitor) { ImplementationInfo implementationInfo = info.getImplementation().get(ImplementationInfo.class); String name = Util.classNameToInternalName(info.getClassName()); String superName = Util.classNameToInternalName(info.getSuperClassName()); classVisitor.visit(Opcodes.V1_5,//from w w w . ja v a 2 s . c om info.isAbstract() ? Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT : Opcodes.ACC_PUBLIC, name, null, superName, new String[] { Util.classNameToInternalName(info.getExtensionInterface().getClassInfo().getName()) }); for (ConstructorInfo constructor : implementationInfo.getConstructors()) { MethodVisitor mv = classVisitor.visitMethod(Opcodes.ACC_PUBLIC, "<init>", constructor.getDescriptor(), constructor.getSignature(), constructor.getExceptions()); if (mv != null) { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 0); Type[] argumentTypes = constructor.getArgumentTypes(); for (int i = 0; i < argumentTypes.length; i++) { mv.visitVarInsn(argumentTypes[i].getOpcode(Opcodes.ILOAD), i + 1); } mv.visitMethodInsn(Opcodes.INVOKESPECIAL, superName, "<init>", constructor.getDescriptor()); mv.visitInsn(Opcodes.RETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "L" + name + ";", null, l0, l1, 0); for (int i = 0; i < argumentTypes.length; i++) { mv.visitLocalVariable("arg" + i, argumentTypes[i].getDescriptor(), null, l0, l1, i + 1); } mv.visitMaxs(argumentTypes.length + 1, argumentTypes.length + 1); mv.visitEnd(); } } classVisitor.visitEnd(); }
From source file:com.googlecode.ddom.weaver.ext.ModelExtensionFactoryDelegateImplementation.java
License:Apache License
public void accept(ClassVisitor classVisitor) { String factoryName = Util .classNameToInternalName(modelExtensionClassInfo.getFactoryDelegateImplementationClassName()); classVisitor.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, factoryName, null, "java/lang/Object", new String[] { Util.classNameToInternalName(implementationInfo.getFactoryDelegateInterfaceName()) }); String className = Util.classNameToInternalName(modelExtensionClassInfo.getClassName()); {/*from ww w . j av a 2 s.co m*/ MethodVisitor mv = classVisitor.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null); if (mv != null) { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); mv.visitInsn(Opcodes.RETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "L" + className + ";", null, l0, l1, 0); mv.visitMaxs(1, 1); mv.visitEnd(); } } for (ConstructorInfo constructor : implementationInfo.getConstructors()) { MethodVisitor mv = classVisitor.visitMethod(Opcodes.ACC_PUBLIC, "create", constructor.getFactoryDelegateMethodDescriptor(), constructor.getSignature(), constructor.getExceptions()); if (mv != null) { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitTypeInsn(Opcodes.NEW, className); mv.visitInsn(Opcodes.DUP); Type[] argumentTypes = constructor.getArgumentTypes(); for (int i = 0; i < argumentTypes.length; i++) { mv.visitVarInsn(argumentTypes[i].getOpcode(Opcodes.ILOAD), i + 1); } mv.visitMethodInsn(Opcodes.INVOKESPECIAL, className, "<init>", constructor.getDescriptor()); mv.visitInsn(Opcodes.ARETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "L" + factoryName + ";", null, l0, l1, 0); for (int i = 0; i < argumentTypes.length; i++) { mv.visitLocalVariable("arg" + i, argumentTypes[i].getDescriptor(), null, l0, l1, i + 1); } mv.visitMaxs(argumentTypes.length + 2, argumentTypes.length + 1); mv.visitEnd(); } } classVisitor.visitEnd(); }
From source file:com.googlecode.ddom.weaver.ext.ModelExtensionFactoryImplementation.java
License:Apache License
public void accept(ClassVisitor classVisitor) { // Note: the name chosen here must match what is expected in ExtensionFactoryLocator String name = Util.classNameToInternalName(implementationInfo.getFactoryInterface().getName() + "$$Impl"); String factoryInterfaceName = Util .classNameToInternalName(implementationInfo.getFactoryInterface().getName()); classVisitor.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", new String[] { factoryInterfaceName }); {// ww w . ja va 2s . c o m FieldVisitor fw = classVisitor.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_STATIC, "INSTANCE", "L" + factoryInterfaceName + ";", null, null); if (fw != null) { fw.visitEnd(); } } { FieldVisitor fw = classVisitor.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, "delegates", "Ljava/util/Map;", null, null); if (fw != null) { fw.visitEnd(); } } { MethodVisitor mv = classVisitor.visitMethod(Opcodes.ACC_PRIVATE, "<init>", "()V", null, null); if (mv != null) { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); // Call constructor from superclass mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); // Create delegates map mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitTypeInsn(Opcodes.NEW, "java/util/HashMap"); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/HashMap", "<init>", "()V"); mv.visitFieldInsn(Opcodes.PUTFIELD, name, "delegates", "Ljava/util/Map;"); // Populate delegates map for (ModelExtensionInfo modelExtensionInfo : implementationInfo.getModelExtensions()) { for (ModelExtensionInterfaceInfo extensionInterface : modelExtensionInfo .getExtensionInterfaces()) { if (!extensionInterface.isAbstract()) { // TODO: this is stupid; we should not recreate the info object here ModelExtensionClassInfo modelExtensionClassInfo = new ModelExtensionClassInfo( implementationInfo.getImplementation(), modelExtensionInfo.getRootInterface(), extensionInterface); String factoryDelegateImplName = Util.classNameToInternalName( modelExtensionClassInfo.getFactoryDelegateImplementationClassName()); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, name, "delegates", "Ljava/util/Map;"); mv.visitLdcInsn(Type.getObjectType(Util.classNameToInternalName( modelExtensionClassInfo.getExtensionInterface().getClassInfo().getName()))); mv.visitTypeInsn(Opcodes.NEW, factoryDelegateImplName); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, factoryDelegateImplName, "<init>", "()V"); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Map", "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); mv.visitInsn(Opcodes.POP); } } } mv.visitInsn(Opcodes.RETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "L" + name + ";", null, l0, l1, 0); mv.visitMaxs(4, 1); mv.visitEnd(); } } String factoryDelegateInterfaceName = Util .classNameToInternalName(implementationInfo.getFactoryDelegateInterfaceName()); String getDelegateDesc = "(Ljava/lang/Class;)L" + factoryDelegateInterfaceName + ";"; { MethodVisitor mv = classVisitor.visitMethod(Opcodes.ACC_PRIVATE, "getDelegate", getDelegateDesc, null, null); if (mv != null) { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, name, "delegates", "Ljava/util/Map;"); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Map", "get", "(Ljava/lang/Object;)Ljava/lang/Object;"); mv.visitTypeInsn(Opcodes.CHECKCAST, factoryDelegateInterfaceName); mv.visitInsn(Opcodes.ARETURN); Label l1 = new Label(); mv.visitLabel(l1); mv.visitLocalVariable("this", "L" + name + ";", null, l0, l1, 0); mv.visitLocalVariable("extensionInterface", "Ljava/lang/Class;", null, l0, l1, 1); mv.visitMaxs(2, 2); mv.visitEnd(); } } String implementationName = Util.classNameToInternalName(implementationInfo.getImplementation().getName()); for (ConstructorInfo constructor : implementationInfo.getConstructors()) { Type[] constructorArgumentTypes = constructor.getArgumentTypes(); Type[] argumentTypes = new Type[constructorArgumentTypes.length + 1]; argumentTypes[0] = Type.getObjectType("java/lang/Class"); System.arraycopy(constructorArgumentTypes, 0, argumentTypes, 1, constructorArgumentTypes.length); MethodVisitor mv = classVisitor.visitMethod(Opcodes.ACC_PUBLIC, "create", Type.getMethodDescriptor(Type.getObjectType(implementationName), argumentTypes), null, null); if (mv != null) { mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(Opcodes.ALOAD, 1); Label l1 = new Label(); mv.visitJumpInsn(Opcodes.IFNONNULL, l1); mv.visitTypeInsn(Opcodes.NEW, implementationName); mv.visitInsn(Opcodes.DUP); for (int i = 0; i < constructorArgumentTypes.length; i++) { mv.visitVarInsn(constructorArgumentTypes[i].getOpcode(Opcodes.ILOAD), i + 2); } mv.visitMethodInsn(Opcodes.INVOKESPECIAL, implementationName, "<init>", constructor.getDescriptor()); mv.visitInsn(Opcodes.ARETURN); mv.visitLabel(l1); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, name, "getDelegate", getDelegateDesc); for (int i = 0; i < constructorArgumentTypes.length; i++) { mv.visitVarInsn(constructorArgumentTypes[i].getOpcode(Opcodes.ILOAD), i + 2); } mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, factoryDelegateInterfaceName, "create", constructor.getFactoryDelegateMethodDescriptor()); mv.visitInsn(Opcodes.ARETURN); Label l3 = new Label(); mv.visitLabel(l3); mv.visitLocalVariable("this", "L" + name + ";", null, l0, l3, 0); mv.visitLocalVariable("extensionInterface", "Ljava/lang/Class;", null, l0, l3, 1); for (int i = 0; i < constructorArgumentTypes.length; i++) { mv.visitLocalVariable("arg" + i, constructorArgumentTypes[i].getDescriptor(), null, l0, l3, i + 2); } mv.visitMaxs(argumentTypes.length + 1, argumentTypes.length + 1); mv.visitEnd(); } } { MethodVisitor mv = classVisitor.visitMethod(Opcodes.ACC_STATIC, "<clinit>", "()V", null, null); if (mv != null) { mv.visitCode(); mv.visitTypeInsn(Opcodes.NEW, name); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, name, "<init>", "()V"); mv.visitFieldInsn(Opcodes.PUTSTATIC, name, "INSTANCE", "L" + factoryInterfaceName + ";"); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 0); mv.visitEnd(); } } classVisitor.visitEnd(); }