List of usage examples for org.objectweb.asm Opcodes F_SAME
int F_SAME
To view the source code for org.objectweb.asm Opcodes F_SAME.
Click Source Link
From source file:edu.illinois.nondex.instr.IdentityHashMapShufflingAdder.java
License:Open Source License
public void addNextIndex() { MethodVisitor mv = super.visitMethod(Opcodes.ACC_PROTECTED, "nextIndex", "()I", null, null); mv.visitCode();//from ww w. ja v a 2 s . com mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "modCount", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "expectedModCount", "I"); Label l0 = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPEQ, l0); mv.visitTypeInsn(Opcodes.NEW, "java/util/ConcurrentModificationException"); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ConcurrentModificationException", "<init>", "()V", false); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/IdentityHashMap$IdentityHashMapIterator", "hasNext", "()Z", false); Label l1 = new Label(); mv.visitJumpInsn(Opcodes.IFNE, l1); mv.visitTypeInsn(Opcodes.NEW, "java/util/NoSuchElementException"); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/NoSuchElementException", "<init>", "()V", false); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "keys", "Ljava/util/List;"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitInsn(Opcodes.DUP); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "idx", "I"); mv.visitInsn(Opcodes.DUP_X1); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "idx", "I"); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;", true); mv.visitVarInsn(Opcodes.ASTORE, 1); mv.visitInsn(Opcodes.ICONST_0); mv.visitVarInsn(Opcodes.ISTORE, 2); Label l2 = new Label(); mv.visitLabel(l2); mv.visitFrame(Opcodes.F_APPEND, 2, new Object[] { "java/lang/Object", Opcodes.INTEGER }, 0, null); mv.visitVarInsn(Opcodes.ILOAD, 2); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "table", "[Ljava/lang/Object;"); mv.visitInsn(Opcodes.ARRAYLENGTH); Label l3 = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPGE, l3); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "table", "[Ljava/lang/Object;"); mv.visitVarInsn(Opcodes.ILOAD, 2); mv.visitInsn(Opcodes.AALOAD); mv.visitVarInsn(Opcodes.ALOAD, 1); Label l4 = new Label(); mv.visitJumpInsn(Opcodes.IF_ACMPNE, l4); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ILOAD, 2); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "lastReturnedIndex", "I"); mv.visitJumpInsn(Opcodes.GOTO, l3); mv.visitLabel(l4); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitIincInsn(2, 2); mv.visitJumpInsn(Opcodes.GOTO, l2); mv.visitLabel(l3); mv.visitFrame(Opcodes.F_CHOP, 1, null, 0, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "lastReturnedIndex", "I"); mv.visitInsn(Opcodes.IRETURN); mv.visitMaxs(5, 3); mv.visitEnd(); }
From source file:edu.illinois.nondex.instr.IdentityHashMapShufflingAdder.java
License:Open Source License
public void addHasNext() { MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC, "hasNext", "()Z", null, null); mv.visitCode();// w w w . j a v a 2s . c o m mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "idx", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "order", "Ljava/util/List;"); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "size", "()I", true); Label l0 = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPGE, l0); mv.visitInsn(Opcodes.ICONST_1); Label l1 = new Label(); mv.visitJumpInsn(Opcodes.GOTO, l1); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitInsn(Opcodes.ICONST_0); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] { Opcodes.INTEGER }); mv.visitInsn(Opcodes.IRETURN); mv.visitMaxs(2, 1); mv.visitEnd(); }
From source file:edu.illinois.nondex.instr.IdentityHashMapShufflingAdder.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if ("hasNext".equals(name)) { return super.visitMethod(access, "originalHasNext", desc, signature, exceptions); }/*www. j ava 2 s . com*/ if ("nextIndex".equals(name)) { return super.visitMethod(access, "originalNextIndex", desc, signature, exceptions); } if ("<init>".equals(name)) { return new MethodVisitor(Opcodes.ASM5, super.visitMethod(access, name, desc, signature, exceptions)) { @Override public void visitInsn(int opcode) { if (opcode == Opcodes.RETURN) { super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 1); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "size", "I"); Label l0 = new Label(); super.visitJumpInsn(Opcodes.IFEQ, l0); super.visitInsn(Opcodes.ICONST_0); Label l1 = new Label(); super.visitJumpInsn(Opcodes.GOTO, l1); super.visitLabel(l0); super.visitFrame(Opcodes.F_FULL, 2, new Object[] { "java/util/IdentityHashMap$IdentityHashMapIterator", "java/util/IdentityHashMap" }, 1, new Object[] { "java/util/IdentityHashMap$IdentityHashMapIterator" }); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "table", "[Ljava/lang/Object;"); super.visitInsn(Opcodes.ARRAYLENGTH); super.visitLabel(l1); super.visitFrame(Opcodes.F_FULL, 2, new Object[] { "java/util/IdentityHashMap$IdentityHashMapIterator", "java/util/IdentityHashMap" }, 2, new Object[] { "java/util/IdentityHashMap$IdentityHashMapIterator", Opcodes.INTEGER }); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "index", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "modCount", "I"); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "expectedModCount", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ICONST_M1); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "lastReturnedIndex", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "table", "[Ljava/lang/Object;"); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "traversalTable", "[Ljava/lang/Object;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitTypeInsn(Opcodes.NEW, "java/util/ArrayList"); super.visitInsn(Opcodes.DUP); super.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V", false); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "order", "Ljava/util/List;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitTypeInsn(Opcodes.NEW, "java/util/ArrayList"); super.visitInsn(Opcodes.DUP); super.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V", false); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "keys", "Ljava/util/List;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ICONST_0); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "idx", "I"); Label l2 = new Label(); super.visitLabel(l2); super.visitFrame(Opcodes.F_SAME, 0, null, 0, null); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/IdentityHashMap$IdentityHashMapIterator", "originalHasNext", "()Z", false); Label l3 = new Label(); super.visitJumpInsn(Opcodes.IFEQ, l3); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "order", "Ljava/util/List;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/IdentityHashMap$IdentityHashMapIterator", "originalNextIndex", "()I", false); super.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true); super.visitInsn(Opcodes.POP); super.visitJumpInsn(Opcodes.GOTO, l2); super.visitLabel(l3); super.visitFrame(Opcodes.F_SAME, 0, null, 0, null); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "order", "Ljava/util/List;"); super.visitMethodInsn(Opcodes.INVOKESTATIC, "edu/illinois/nondex/shuffling/ControlNondeterminism", "shuffle", "(Ljava/util/List;)Ljava/util/List;", false); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "order", "Ljava/util/List;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "order", "Ljava/util/List;"); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "iterator", "()Ljava/util/Iterator;", true); super.visitVarInsn(Opcodes.ASTORE, 2); Label l4 = new Label(); super.visitLabel(l4); super.visitFrame(Opcodes.F_APPEND, 1, new Object[] { "java/util/Iterator" }, 0, null); super.visitVarInsn(Opcodes.ALOAD, 2); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); Label l5 = new Label(); super.visitJumpInsn(Opcodes.IFEQ, l5); super.visitVarInsn(Opcodes.ALOAD, 2); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); super.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Integer"); super.visitVarInsn(Opcodes.ASTORE, 3); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "keys", "Ljava/util/List;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap$IdentityHashMapIterator", "this$0", "Ljava/util/IdentityHashMap;"); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/IdentityHashMap", "table", "[Ljava/lang/Object;"); super.visitVarInsn(Opcodes.ALOAD, 3); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false); super.visitInsn(Opcodes.AALOAD); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true); super.visitInsn(Opcodes.POP); super.visitJumpInsn(Opcodes.GOTO, l4); super.visitLabel(l5); super.visitFrame(Opcodes.F_CHOP, 1, null, 0, null); } super.visitInsn(opcode); } }; } return super.visitMethod(access, name, desc, signature, exceptions); }
From source file:edu.illinois.nondex.instr.PriorityQueueShufflingAdder.java
License:Open Source License
public void addNext() { MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC, "next", "()Ljava/lang/Object;", "()TE;", null); mv.visitCode();// w w w . j a va 2 s. c o m mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "expectedModCount", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "this$0", "Ljava/util/PriorityQueue;"); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue", "modCount", "I"); Label l0 = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPEQ, l0); mv.visitTypeInsn(Opcodes.NEW, "java/util/ConcurrentModificationException"); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ConcurrentModificationException", "<init>", "()V", false); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "iter", "Ljava/util/Iterator;"); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRetElt", "Ljava/lang/Object;"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitInsn(Opcodes.ICONST_M1); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRet", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "lastRetElt", "Ljava/lang/Object;"); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(2, 1); mv.visitEnd(); }
From source file:edu.illinois.nondex.instr.PriorityQueueShufflingAdder.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if ("hasNext".equals(name)) { return super.visitMethod(access, "originalHasNext", desc, signature, exceptions); }/*from ww w. j av a2s . c o m*/ if ("next".equals(name)) { return super.visitMethod(access, "originalNext", desc, signature, exceptions); } if ("<init>".equals(name)) { return new MethodVisitor(Opcodes.ASM5, super.visitMethod(access, name, desc, signature, exceptions)) { @Override public void visitInsn(int opcode) { if (opcode == Opcodes.RETURN) { super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 1); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "this$0", "Ljava/util/PriorityQueue;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ICONST_0); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "cursor", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ICONST_M1); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRet", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "forgetMeNot", "Ljava/util/ArrayDeque;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRetElt", "Ljava/lang/Object;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "this$0", "Ljava/util/PriorityQueue;"); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue", "modCount", "I"); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "expectedModCount", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitTypeInsn(Opcodes.NEW, "java/util/ArrayList"); super.visitInsn(Opcodes.DUP); super.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V", false); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "elements", "Ljava/util/List;"); Label l0 = new Label(); super.visitLabel(l0); super.visitFrame(Opcodes.F_FULL, 2, new Object[] { "java/util/PriorityQueue$Itr", "java/util/PriorityQueue" }, 0, new Object[] {}); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/PriorityQueue$Itr", "originalHasNext", "()Z", false); Label l1 = new Label(); super.visitJumpInsn(Opcodes.IFEQ, l1); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "elements", "Ljava/util/List;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/PriorityQueue$Itr", "originalNext", "()Ljava/lang/Object;", false); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true); super.visitInsn(Opcodes.POP); super.visitJumpInsn(Opcodes.GOTO, l0); super.visitLabel(l1); super.visitFrame(Opcodes.F_SAME, 0, null, 0, null); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "elements", "Ljava/util/List;"); super.visitMethodInsn(Opcodes.INVOKESTATIC, "edu/illinois/nondex/shuffling/ControlNondeterminism", "shuffle", "(Ljava/util/List;)Ljava/util/List;", false); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "elements", "Ljava/util/List;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/PriorityQueue$Itr", "elements", "Ljava/util/List;"); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "iterator", "()Ljava/util/Iterator;", true); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "iter", "Ljava/util/Iterator;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ICONST_M1); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRet", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/PriorityQueue$Itr", "lastRetElt", "Ljava/lang/Object;"); } super.visitInsn(opcode); } }; } return super.visitMethod(access, name, desc, signature, exceptions); }
From source file:edu.illinois.nondex.instr.WeakHashMapShufflingAdder.java
License:Open Source License
public void addNextEntry() { MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC, "nextEntry", "()Ljava/util/WeakHashMap$Entry;", "()Ljava/util/WeakHashMap$Entry<TK;TV;>;", null); mv.visitCode();/*from w w w . j av a2 s .c o m*/ mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "this$0", "Ljava/util/WeakHashMap;"); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap", "modCount", "I"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "expectedModCount", "I"); Label l0 = new Label(); mv.visitJumpInsn(Opcodes.IF_ICMPEQ, l0); mv.visitTypeInsn(Opcodes.NEW, "java/util/ConcurrentModificationException"); mv.visitInsn(Opcodes.DUP); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ConcurrentModificationException", "<init>", "()V", false); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "iter", "Ljava/util/Iterator;"); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/WeakHashMap$Entry"); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/WeakHashMap$Entry", "get", "()Ljava/lang/Object;", false); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "currentKey", "Ljava/lang/Object;"); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(2, 1); mv.visitEnd(); }
From source file:edu.illinois.nondex.instr.WeakHashMapShufflingAdder.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if ("hasNext".equals(name)) { return super.visitMethod(access, "originalHasNext", desc, signature, exceptions); }/*from w w w.j a va 2s . co m*/ if ("nextEntry".equals(name)) { return super.visitMethod(access, "originalNextEntry", desc, signature, exceptions); } if ("<init>".equals(name)) { return new MethodVisitor(Opcodes.ASM5, super.visitMethod(access, name, desc, signature, exceptions)) { @Override public void visitInsn(int opcode) { if (opcode == Opcodes.RETURN) { super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 1); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "this$0", "Ljava/util/WeakHashMap;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "entry", "Ljava/util/WeakHashMap$Entry;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap$HashIterator", "this$0", "Ljava/util/WeakHashMap;"); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap", "modCount", "I"); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "expectedModCount", "I"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "nextKey", "Ljava/lang/Object;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "currentKey", "Ljava/lang/Object;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "iter", "Ljava/util/Iterator;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 1); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/WeakHashMap", "isEmpty", "()Z", false); Label l0 = new Label(); super.visitJumpInsn(Opcodes.IFEQ, l0); super.visitInsn(Opcodes.ICONST_0); Label l1 = new Label(); super.visitJumpInsn(Opcodes.GOTO, l1); super.visitLabel(l0); super.visitFrame(Opcodes.F_FULL, 2, new Object[] { "java/util/WeakHashMap$HashIterator", "java/util/WeakHashMap" }, 1, new Object[] { "java/util/WeakHashMap$HashIterator" }); super.visitVarInsn(Opcodes.ALOAD, 1); super.visitFieldInsn(Opcodes.GETFIELD, "java/util/WeakHashMap", "table", "[Ljava/util/WeakHashMap$Entry;"); super.visitInsn(Opcodes.ARRAYLENGTH); super.visitLabel(l1); super.visitFrame(Opcodes.F_FULL, 2, new Object[] { "java/util/WeakHashMap$HashIterator", "java/util/WeakHashMap" }, 2, new Object[] { "java/util/WeakHashMap$HashIterator", Opcodes.INTEGER }); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "index", "I"); super.visitTypeInsn(Opcodes.NEW, "java/util/ArrayList"); super.visitInsn(Opcodes.DUP); super.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V", false); super.visitVarInsn(Opcodes.ASTORE, 2); Label l2 = new Label(); super.visitLabel(l2); super.visitFrame(Opcodes.F_APPEND, 1, new Object[] { "java/util/List" }, 0, null); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/WeakHashMap$HashIterator", "originalHasNext", "()Z", false); Label l3 = new Label(); super.visitJumpInsn(Opcodes.IFEQ, l3); super.visitVarInsn(Opcodes.ALOAD, 2); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/WeakHashMap$HashIterator", "originalNextEntry", "()Ljava/util/WeakHashMap$Entry;", false); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true); super.visitInsn(Opcodes.POP); super.visitJumpInsn(Opcodes.GOTO, l2); super.visitLabel(l3); super.visitFrame(Opcodes.F_SAME, 0, null, 0, null); super.visitVarInsn(Opcodes.ALOAD, 2); super.visitMethodInsn(Opcodes.INVOKESTATIC, "edu/illinois/nondex/shuffling/ControlNondeterminism", "shuffle", "(Ljava/util/List;)Ljava/util/List;", false); super.visitVarInsn(Opcodes.ASTORE, 2); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitVarInsn(Opcodes.ALOAD, 2); super.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "iterator", "()Ljava/util/Iterator;", true); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "iter", "Ljava/util/Iterator;"); super.visitVarInsn(Opcodes.ALOAD, 0); super.visitInsn(Opcodes.ACONST_NULL); super.visitFieldInsn(Opcodes.PUTFIELD, "java/util/WeakHashMap$HashIterator", "lastReturned", "Ljava/util/WeakHashMap$Entry;"); } super.visitInsn(opcode); } }; } return super.visitMethod(access, name, desc, signature, exceptions); }
From source file:io.github.btpka3.asm.H.java
public static byte[] dump() throws Exception { ClassWriter cw = new ClassWriter(0); FieldVisitor fv;/*from w ww . j ava2 s . c o m*/ MethodVisitor mv; AnnotationVisitor av0; cw.visit(V1_8, ACC_PUBLIC + ACC_SUPER, "JP/co/esm/caddies/jomt/license/h", null, "java/lang/Object", null); { fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, "a", "Ljava/lang/String;", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PRIVATE + ACC_STATIC, "b", "Z", null, null); fv.visitEnd(); } { fv = cw.visitField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, "c", "Lorg/slf4j/Logger;", null, null); fv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } // public static boolean a() { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "a", "()Z", null, null); mv.visitCode(); mv.visitFieldInsn(GETSTATIC, "JP/co/esm/caddies/jomt/license/h", "a", "Ljava/lang/String;"); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "b", "(Ljava/lang/String;)Z", false); Label l0 = new Label(); mv.visitJumpInsn(IFEQ, l0); mv.visitFieldInsn(GETSTATIC, "JP/co/esm/caddies/jomt/license/h", "a", "Ljava/lang/String;"); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "d", "(Ljava/lang/String;)V", false); mv.visitFieldInsn(GETSTATIC, "JP/co/esm/caddies/jomt/jsystem/c", "q", "Z"); Label l1 = new Label(); mv.visitJumpInsn(IFEQ, l1); mv.visitFieldInsn(GETSTATIC, "JP/co/esm/caddies/jomt/license/h", "b", "Z"); Label l2 = new Label(); mv.visitJumpInsn(IFNE, l2); mv.visitLdcInsn("app"); mv.visitLdcInsn("without_any_license"); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/jview/eO", "d", "(Ljava/lang/String;Ljava/lang/String;)V", false); mv.visitLabel(l2); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitInsn(ICONST_1); mv.visitFieldInsn(PUTSTATIC, "JP/co/esm/caddies/jomt/license/h", "b", "Z"); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitFieldInsn(GETSTATIC, "JP/co/esm/caddies/jomt/jsystem/c", "q", "Z"); Label l3 = new Label(); mv.visitJumpInsn(IFNE, l3); mv.visitInsn(ICONST_1); Label l4 = new Label(); mv.visitJumpInsn(GOTO, l4); mv.visitLabel(l3); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitInsn(ICONST_0); mv.visitLabel(l4); mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] { Opcodes.INTEGER }); mv.visitInsn(IRETURN); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "b", "()Ljava/lang/String;", false); mv.visitVarInsn(ASTORE, 0); mv.visitFieldInsn(GETSTATIC, "JP/co/esm/caddies/jomt/license/h", "a", "Ljava/lang/String;"); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "a", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", false); mv.visitInsn(POP); mv.visitInsn(ICONST_1); mv.visitFieldInsn(PUTSTATIC, "JP/co/esm/caddies/jomt/jsystem/c", "p", "Z"); mv.visitInsn(ICONST_1); mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); mv.visitVarInsn(ASTORE, 1); mv.visitVarInsn(ALOAD, 1); mv.visitInsn(ICONST_0); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "a", "(Ljava/lang/String;)Ljava/lang/String;", false); mv.visitInsn(AASTORE); mv.visitLdcInsn("app"); mv.visitLdcInsn("license_evaluation_term.message"); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/jview/eO", "e", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V", false); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/p", "c", "()LJP/co/esm/caddies/jomt/license/p;", false); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/jsystem/j", "d", "()Ljava/lang/String;", false); mv.visitLdcInsn("P"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); Label l5 = new Label(); mv.visitJumpInsn(IFEQ, l5); mv.visitLdcInsn("astah_professional"); Label l6 = new Label(); mv.visitJumpInsn(GOTO, l6); mv.visitLabel(l5); mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] { "JP/co/esm/caddies/jomt/license/p" }); mv.visitLdcInsn("astah_UML"); mv.visitLabel(l6); mv.visitFrame(Opcodes.F_FULL, 0, new Object[] {}, 2, new Object[] { "JP/co/esm/caddies/jomt/license/p", "java/lang/String" }); mv.visitLdcInsn("USER_TYPE"); mv.visitLdcInsn("Evaluation"); mv.visitMethodInsn(INVOKEVIRTUAL, "JP/co/esm/caddies/jomt/license/p", "a", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", false); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitMaxs(4, 2); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC, "b", "()Ljava/lang/String;", null, null); mv.visitCode(); mv.visitLdcInsn("yyyy/MM/dd"); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/jutil/JomtUtilities", "getDateString", "(Ljava/lang/String;)Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitMaxs(1, 0); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC, "f", "(Ljava/lang/String;)Ljava/util/GregorianCalendar;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitInsn(ICONST_4); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(II)Ljava/lang/String;", false); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I", false); mv.visitVarInsn(ISTORE, 1); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_5); mv.visitIntInsn(BIPUSH, 7); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(II)Ljava/lang/String;", false); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I", false); mv.visitInsn(ICONST_1); mv.visitInsn(ISUB); mv.visitVarInsn(ISTORE, 2); mv.visitVarInsn(ALOAD, 0); mv.visitIntInsn(BIPUSH, 8); mv.visitIntInsn(BIPUSH, 10); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(II)Ljava/lang/String;", false); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I", false); mv.visitVarInsn(ISTORE, 3); mv.visitTypeInsn(NEW, "java/util/GregorianCalendar"); mv.visitInsn(DUP); mv.visitVarInsn(ILOAD, 1); mv.visitVarInsn(ILOAD, 2); mv.visitVarInsn(ILOAD, 3); mv.visitMethodInsn(INVOKESPECIAL, "java/util/GregorianCalendar", "<init>", "(III)V", false); mv.visitInsn(ARETURN); mv.visitMaxs(5, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC, "c", "()Ljava/util/GregorianCalendar;", null, null); mv.visitCode(); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "b", "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "f", "(Ljava/lang/String;)Ljava/util/GregorianCalendar;", false); mv.visitInsn(ARETURN); mv.visitMaxs(1, 0); mv.visitEnd(); } // private static GregorianCalendar g(String var0) { mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC, "g", "(Ljava/lang/String;)Ljava/util/GregorianCalendar;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_0); mv.visitInsn(ICONST_4); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(II)Ljava/lang/String;", false); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I", false); mv.visitVarInsn(ISTORE, 1); mv.visitVarInsn(ALOAD, 0); mv.visitInsn(ICONST_5); mv.visitIntInsn(BIPUSH, 7); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(II)Ljava/lang/String;", false); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I", false); mv.visitInsn(ICONST_1); mv.visitInsn(ISUB); mv.visitVarInsn(ISTORE, 2); mv.visitVarInsn(ALOAD, 0); mv.visitIntInsn(BIPUSH, 8); mv.visitIntInsn(BIPUSH, 10); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "substring", "(II)Ljava/lang/String;", false); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "parseInt", "(Ljava/lang/String;)I", false); mv.visitVarInsn(ISTORE, 3); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "c", "()Ljava/util/GregorianCalendar;", false); mv.visitVarInsn(ASTORE, 4); mv.visitVarInsn(ALOAD, 4); mv.visitVarInsn(ILOAD, 1); mv.visitVarInsn(ILOAD, 2); mv.visitVarInsn(ILOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/GregorianCalendar", "set", "(III)V", false); mv.visitVarInsn(ALOAD, 4); mv.visitInsn(ICONST_5); //mv.visitIntInsn(BIPUSH, 20); mv.visitIntInsn(BIPUSH, 3650); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/GregorianCalendar", "add", "(II)V", false); mv.visitVarInsn(ALOAD, 4); mv.visitInsn(ARETURN); mv.visitMaxs(4, 5); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "a", "(Ljava/lang/String;)Ljava/lang/String;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "g", "(Ljava/lang/String;)Ljava/util/GregorianCalendar;", false); mv.visitVarInsn(ASTORE, 1); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/GregorianCalendar", "getTime", "()Ljava/util/Date;", false); mv.visitVarInsn(ASTORE, 2); mv.visitInsn(ICONST_1); mv.visitMethodInsn(INVOKESTATIC, "java/text/DateFormat", "getDateInstance", "(I)Ljava/text/DateFormat;", false); mv.visitVarInsn(ASTORE, 3); mv.visitVarInsn(ALOAD, 3); mv.visitVarInsn(ALOAD, 2); mv.visitMethodInsn(INVOKEVIRTUAL, "java/text/DateFormat", "format", "(Ljava/util/Date;)Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitMaxs(2, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "b", "(Ljava/lang/String;)Z", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, "java/io/File"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/io/File", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(ASTORE, 1); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/File", "exists", "()Z", false); Label l0 = new Label(); mv.visitJumpInsn(IFEQ, l0); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_CHOP, 1, null, 0, null); mv.visitInsn(ICONST_0); mv.visitInsn(IRETURN); mv.visitMaxs(3, 2); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "c", "(Ljava/lang/String;)Ljava/lang/String;", null, null); mv.visitCode(); Label l0 = new Label(); Label l1 = new Label(); Label l2 = new Label(); mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception"); mv.visitLdcInsn(""); mv.visitVarInsn(ASTORE, 1); mv.visitInsn(ACONST_NULL); mv.visitVarInsn(ASTORE, 2); mv.visitLabel(l0); mv.visitTypeInsn(NEW, "java/util/zip/GZIPInputStream"); mv.visitInsn(DUP); mv.visitTypeInsn(NEW, "java/io/FileInputStream"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/io/FileInputStream", "<init>", "(Ljava/lang/String;)V", false); mv.visitMethodInsn(INVOKESPECIAL, "java/util/zip/GZIPInputStream", "<init>", "(Ljava/io/InputStream;)V", false); mv.visitVarInsn(ASTORE, 2); mv.visitTypeInsn(NEW, "java/io/InputStreamReader"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 2); mv.visitLdcInsn("UTF-8"); mv.visitMethodInsn(INVOKESPECIAL, "java/io/InputStreamReader", "<init>", "(Ljava/io/InputStream;Ljava/lang/String;)V", false); mv.visitVarInsn(ASTORE, 3); mv.visitTypeInsn(NEW, "java/io/BufferedReader"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKESPECIAL, "java/io/BufferedReader", "<init>", "(Ljava/io/Reader;)V", false); mv.visitVarInsn(ASTORE, 4); Label l3 = new Label(); mv.visitLabel(l3); mv.visitFrame(Opcodes.F_FULL, 5, new Object[] { Opcodes.TOP, "java/lang/String", Opcodes.TOP, Opcodes.TOP, "java/io/BufferedReader" }, 0, new Object[] {}); mv.visitVarInsn(ALOAD, 4); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/BufferedReader", "readLine", "()Ljava/lang/String;", false); mv.visitInsn(DUP); mv.visitVarInsn(ASTORE, 5); Label l4 = new Label(); mv.visitJumpInsn(IFNULL, l4); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "length", "()I", false); mv.visitJumpInsn(IFLE, l3); mv.visitVarInsn(ALOAD, 5); mv.visitVarInsn(ASTORE, 1); mv.visitJumpInsn(GOTO, l3); mv.visitLabel(l4); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(ALOAD, 4); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/BufferedReader", "close", "()V", false); mv.visitLabel(l1); Label l5 = new Label(); mv.visitJumpInsn(GOTO, l5); mv.visitLabel(l2); mv.visitFrame(Opcodes.F_FULL, 0, new Object[] {}, 1, new Object[] { "java/lang/Exception" }); mv.visitVarInsn(ASTORE, 3); mv.visitFieldInsn(GETSTATIC, "JP/co/esm/caddies/jomt/license/h", "c", "Lorg/slf4j/Logger;"); mv.visitLdcInsn("error has occurred."); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKEINTERFACE, "org/slf4j/Logger", "error", "(Ljava/lang/String;Ljava/lang/Throwable;)V", true); mv.visitInsn(ACONST_NULL); mv.visitInsn(ARETURN); mv.visitLabel(l5); mv.visitFrame(Opcodes.F_APPEND, 2, new Object[] { Opcodes.TOP, "java/lang/String" }, 0, null); mv.visitVarInsn(ALOAD, 1); mv.visitInsn(ARETURN); mv.visitMaxs(5, 6); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "a", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", null, null); mv.visitCode(); Label l0 = new Label(); Label l1 = new Label(); Label l2 = new Label(); mv.visitTryCatchBlock(l0, l1, l2, "java/io/IOException"); Label l3 = new Label(); Label l4 = new Label(); Label l5 = new Label(); mv.visitTryCatchBlock(l3, l4, l5, "java/lang/Throwable"); Label l6 = new Label(); Label l7 = new Label(); Label l8 = new Label(); mv.visitTryCatchBlock(l6, l7, l8, "java/io/IOException"); Label l9 = new Label(); mv.visitTryCatchBlock(l3, l4, l9, null); Label l10 = new Label(); mv.visitTryCatchBlock(l5, l10, l9, null); Label l11 = new Label(); Label l12 = new Label(); Label l13 = new Label(); mv.visitTryCatchBlock(l11, l12, l13, "java/io/IOException"); Label l14 = new Label(); mv.visitTryCatchBlock(l9, l14, l9, null); mv.visitInsn(ACONST_NULL); mv.visitVarInsn(ASTORE, 2); mv.visitLabel(l3); mv.visitTypeInsn(NEW, "java/io/BufferedWriter"); mv.visitInsn(DUP); mv.visitTypeInsn(NEW, "java/io/OutputStreamWriter"); mv.visitInsn(DUP); mv.visitTypeInsn(NEW, "java/util/zip/GZIPOutputStream"); mv.visitInsn(DUP); mv.visitTypeInsn(NEW, "java/io/FileOutputStream"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/io/FileOutputStream", "<init>", "(Ljava/lang/String;)V", false); mv.visitMethodInsn(INVOKESPECIAL, "java/util/zip/GZIPOutputStream", "<init>", "(Ljava/io/OutputStream;)V", false); mv.visitLdcInsn("UTF-8"); mv.visitMethodInsn(INVOKESPECIAL, "java/io/OutputStreamWriter", "<init>", "(Ljava/io/OutputStream;Ljava/lang/String;)V", false); mv.visitMethodInsn(INVOKESPECIAL, "java/io/BufferedWriter", "<init>", "(Ljava/io/Writer;)V", false); mv.visitVarInsn(ASTORE, 2); mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/BufferedWriter", "write", "(Ljava/lang/String;)V", false); mv.visitLabel(l4); mv.visitVarInsn(ALOAD, 2); Label l15 = new Label(); mv.visitJumpInsn(IFNULL, l15); mv.visitLabel(l0); mv.visitVarInsn(ALOAD, 2); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/BufferedWriter", "close", "()V", false); mv.visitLabel(l1); mv.visitJumpInsn(GOTO, l15); mv.visitLabel(l2); mv.visitFrame(Opcodes.F_FULL, 0, new Object[] {}, 1, new Object[] { "java/io/IOException" }); mv.visitVarInsn(ASTORE, 3); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/IOException", "getMessage", "()Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitLabel(l5); mv.visitFrame(Opcodes.F_FULL, 3, new Object[] { Opcodes.TOP, Opcodes.TOP, "java/io/BufferedWriter" }, 1, new Object[] { "java/lang/Throwable" }); mv.visitVarInsn(ASTORE, 3); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Throwable", "getMessage", "()Ljava/lang/String;", false); mv.visitVarInsn(ASTORE, 4); mv.visitLabel(l10); mv.visitVarInsn(ALOAD, 2); Label l16 = new Label(); mv.visitJumpInsn(IFNULL, l16); mv.visitLabel(l6); mv.visitVarInsn(ALOAD, 2); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/BufferedWriter", "close", "()V", false); mv.visitLabel(l7); mv.visitJumpInsn(GOTO, l16); mv.visitLabel(l8); mv.visitFrame(Opcodes.F_FULL, 0, new Object[] {}, 1, new Object[] { "java/io/IOException" }); mv.visitVarInsn(ASTORE, 5); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/IOException", "getMessage", "()Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitLabel(l16); mv.visitFrame(Opcodes.F_FULL, 5, new Object[] { Opcodes.TOP, Opcodes.TOP, Opcodes.TOP, Opcodes.TOP, "java/lang/String" }, 0, new Object[] {}); mv.visitVarInsn(ALOAD, 4); mv.visitInsn(ARETURN); mv.visitLabel(l9); mv.visitFrame(Opcodes.F_FULL, 3, new Object[] { Opcodes.TOP, Opcodes.TOP, "java/io/BufferedWriter" }, 1, new Object[] { "java/lang/Throwable" }); mv.visitVarInsn(ASTORE, 6); mv.visitLabel(l14); mv.visitVarInsn(ALOAD, 2); Label l17 = new Label(); mv.visitJumpInsn(IFNULL, l17); mv.visitLabel(l11); mv.visitVarInsn(ALOAD, 2); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/BufferedWriter", "close", "()V", false); mv.visitLabel(l12); mv.visitJumpInsn(GOTO, l17); mv.visitLabel(l13); mv.visitFrame(Opcodes.F_FULL, 0, new Object[] {}, 1, new Object[] { "java/io/IOException" }); mv.visitVarInsn(ASTORE, 7); mv.visitVarInsn(ALOAD, 7); mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/IOException", "getMessage", "()Ljava/lang/String;", false); mv.visitInsn(ARETURN); mv.visitLabel(l17); mv.visitFrame(Opcodes.F_FULL, 7, new Object[] { Opcodes.TOP, Opcodes.TOP, Opcodes.TOP, Opcodes.TOP, Opcodes.TOP, Opcodes.TOP, "java/lang/Throwable" }, 0, new Object[] {}); mv.visitVarInsn(ALOAD, 6); mv.visitInsn(ATHROW); mv.visitLabel(l15); mv.visitFrame(Opcodes.F_FULL, 0, new Object[] {}, 0, new Object[] {}); mv.visitLdcInsn(""); mv.visitInsn(ARETURN); mv.visitMaxs(9, 8); mv.visitEnd(); } // public static void d(String var0) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "d", "(Ljava/lang/String;)V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "c", "(Ljava/lang/String;)Ljava/lang/String;", false); mv.visitVarInsn(ASTORE, 1); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "e", "(Ljava/lang/String;)Z", false); mv.visitVarInsn(ISTORE, 2); mv.visitVarInsn(ILOAD, 2); Label l0 = new Label(); mv.visitJumpInsn(IFEQ, l0); mv.visitInsn(ICONST_1); mv.visitFieldInsn(PUTSTATIC, "JP/co/esm/caddies/jomt/jsystem/c", "p", "Z"); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/p", "c", "()LJP/co/esm/caddies/jomt/license/p;", false); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/jsystem/j", "d", "()Ljava/lang/String;", false); mv.visitLdcInsn("P"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); Label l1 = new Label(); mv.visitJumpInsn(IFEQ, l1); mv.visitLdcInsn("astah_professional"); Label l2 = new Label(); mv.visitJumpInsn(GOTO, l2); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_FULL, 2, new Object[] { Opcodes.TOP, "java/lang/String" }, 1, new Object[] { "JP/co/esm/caddies/jomt/license/p" }); mv.visitLdcInsn("astah_UML"); mv.visitLabel(l2); mv.visitFrame(Opcodes.F_FULL, 2, new Object[] { Opcodes.TOP, "java/lang/String" }, 2, new Object[] { "JP/co/esm/caddies/jomt/license/p", "java/lang/String" }); mv.visitLdcInsn("USER_TYPE"); mv.visitLdcInsn("Evaluation"); mv.visitMethodInsn(INVOKEVIRTUAL, "JP/co/esm/caddies/jomt/license/p", "a", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", false); mv.visitInsn(ICONST_1); mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); mv.visitVarInsn(ASTORE, 3); mv.visitVarInsn(ALOAD, 3); mv.visitInsn(ICONST_0); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "a", "(Ljava/lang/String;)Ljava/lang/String;", false); mv.visitInsn(AASTORE); mv.visitLdcInsn("app"); mv.visitLdcInsn("license_evaluation_term.message"); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/jview/eO", "e", "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V", false); Label l3 = new Label(); mv.visitJumpInsn(GOTO, l3); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_CHOP, 2, null, 0, null); mv.visitInsn(ICONST_1); mv.visitFieldInsn(PUTSTATIC, "JP/co/esm/caddies/jomt/jsystem/c", "q", "Z"); mv.visitLabel(l3); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitInsn(RETURN); mv.visitMaxs(4, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "e", "(Ljava/lang/String;)Z", null, null); mv.visitCode(); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "c", "()Ljava/util/GregorianCalendar;", false); mv.visitVarInsn(ASTORE, 1); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "f", "(Ljava/lang/String;)Ljava/util/GregorianCalendar;", false); mv.visitVarInsn(ASTORE, 2); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/license/h", "g", "(Ljava/lang/String;)Ljava/util/GregorianCalendar;", false); mv.visitVarInsn(ASTORE, 3); mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/GregorianCalendar", "equals", "(Ljava/lang/Object;)Z", false); Label l0 = new Label(); mv.visitJumpInsn(IFEQ, l0); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_FULL, 4, new Object[] { Opcodes.TOP, "java/util/GregorianCalendar", "java/util/GregorianCalendar", "java/util/GregorianCalendar" }, 0, new Object[] {}); mv.visitVarInsn(ALOAD, 3); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/GregorianCalendar", "equals", "(Ljava/lang/Object;)Z", false); Label l1 = new Label(); mv.visitJumpInsn(IFEQ, l1); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ALOAD, 1); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/GregorianCalendar", "before", "(Ljava/lang/Object;)Z", false); Label l2 = new Label(); mv.visitJumpInsn(IFEQ, l2); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 3); mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/GregorianCalendar", "before", "(Ljava/lang/Object;)Z", false); mv.visitJumpInsn(IFEQ, l2); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitLabel(l2); mv.visitFrame(Opcodes.F_FULL, 0, new Object[] {}, 0, new Object[] {}); mv.visitInsn(ICONST_0); mv.visitInsn(IRETURN); mv.visitMaxs(2, 4); mv.visitEnd(); } { mv = cw.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null); mv.visitCode(); mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "()V", false); mv.visitMethodInsn(INVOKESTATIC, "JP/co/esm/caddies/jomt/jsystem/j", "s", "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitFieldInsn(GETSTATIC, "java/io/File", "separator", "Ljava/lang/String;"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitLdcInsn(".ael"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); mv.visitFieldInsn(PUTSTATIC, "JP/co/esm/caddies/jomt/license/h", "a", "Ljava/lang/String;"); mv.visitInsn(ICONST_0); mv.visitFieldInsn(PUTSTATIC, "JP/co/esm/caddies/jomt/license/h", "b", "Z"); mv.visitLdcInsn(Type.getType("LJP/co/esm/caddies/jomt/license/h;")); mv.visitMethodInsn(INVOKESTATIC, "org/slf4j/LoggerFactory", "getLogger", "(Ljava/lang/Class;)Lorg/slf4j/Logger;", false); mv.visitFieldInsn(PUTSTATIC, "JP/co/esm/caddies/jomt/license/h", "c", "Lorg/slf4j/Logger;"); mv.visitInsn(RETURN); mv.visitMaxs(2, 0); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
From source file:io.syncframework.optimizer.OControllerClassVisitor.java
License:Apache License
/** * Generates _asActions() method as following: * //from w w w .j a va 2s. c o m * if(name.equals("upload")) * return upload(); * else if(name.equals("save")) * return save(); * else if(name.equals("main")) * return main(); * else if(name.equals("redir")) * return redir(); * else * throw new RuntimeException("no action named "+name); */ private void createActionMethod() { StringBuilder sb = new StringBuilder(); sb.append("(").append(Type.getType(String.class)).append(")").append(Type.getType(Result.class)); String desc = sb.toString(); MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC, "_asAction", desc, null, null); Label start = new Label(); Label next = new Label(); Label variable = new Label(); boolean first = true; for (String name : reflector.getActions().keySet()) { Label l0 = null; Label l1 = new Label(); if (first) { l0 = new Label(); first = false; } else { l0 = next; next = new Label(); } mv.visitLabel(l0); if (!first) { mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); } mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitLdcInsn(name); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); mv.visitJumpInsn(Opcodes.IFEQ, next); mv.visitLabel(l1); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, reflector.getClazzInternalName(), name, "()" + Type.getType(Result.class), false); mv.visitInsn(Opcodes.ARETURN); } mv.visitLabel(next); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitTypeInsn(Opcodes.NEW, "java/lang/NoSuchMethodException"); mv.visitInsn(Opcodes.DUP); mv.visitTypeInsn(Opcodes.NEW, "java/lang/StringBuilder"); mv.visitInsn(Opcodes.DUP); mv.visitLdcInsn("no @Action named "); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/NoSuchMethodException", "<init>", "(Ljava/lang/String;)V", false); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(variable); mv.visitLocalVariable("this", reflector.getClazzDescriptor(), null, start, next, 0); mv.visitLocalVariable("name", "Ljava/lang/String;", null, start, next, 1); mv.visitMaxs(5, 2); mv.visitEnd(); }
From source file:io.syncframework.optimizer.OControllerClassVisitor.java
License:Apache License
/** * Generates this code://from ww w.j ava 2s.co m * * public boolean _asActionIsDefined(String name) { * if(_asActions.containsKey(name)) * return true; * return false; * } */ public void createActionIsDefinedMethod() { MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC, "_asActionIsDefined", "(Ljava/lang/String;)Z", null, null); Label l0 = new Label(); Label l1 = new Label(); Label l2 = new Label(); Label l3 = new Label(); mv.visitLabel(l0); mv.visitFieldInsn(Opcodes.GETSTATIC, reflector.getClazzInternalName(), "_asActions", "Ljava/util/Map;"); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Map", "containsKey", "(Ljava/lang/Object;)Z", true); mv.visitJumpInsn(Opcodes.IFEQ, l1); mv.visitLabel(l2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IRETURN); mv.visitLabel(l1); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); mv.visitInsn(Opcodes.ICONST_0); mv.visitInsn(Opcodes.IRETURN); mv.visitLabel(l3); mv.visitLocalVariable("this", reflector.getClazzDescriptor(), null, l0, l3, 0); mv.visitLocalVariable("name", "Ljava/lang/String;", null, l0, l3, 1); mv.visitMaxs(2, 2); mv.visitEnd(); }