1 4 package com.tc.object.bytecode; 5 import com.tc.asm.ClassAdapter; 6 import com.tc.asm.ClassVisitor; 7 import com.tc.asm.Label; 8 import com.tc.asm.MethodVisitor; 9 import com.tc.asm.Opcodes; 10 11 public class JavaUtilConcurrentLinkedBlockingQueueNodeClassAdapter extends ClassAdapter implements Opcodes { 12 13 public JavaUtilConcurrentLinkedBlockingQueueNodeClassAdapter(ClassVisitor cv) { 14 super(cv); 15 } 16 17 public void visitEnd() { 18 addGetItemMethod(); 19 super.visitEnd(); 20 } 21 22 private void addGetItemMethod() { 23 MethodVisitor mv = cv.visitMethod(0, "getItem", "()Ljava/lang/Object;", "()TE;", null); 24 mv.visitCode(); 25 Label l0 = new Label(); 26 mv.visitLabel(l0); 27 mv.visitLineNumber(64, l0); 28 mv.visitVarInsn(ALOAD, 0); 29 mv.visitFieldInsn(GETFIELD, "java/util/concurrent/LinkedBlockingQueue$Node", "item", "Ljava/lang/Object;"); 30 mv.visitTypeInsn(INSTANCEOF, "com/tc/object/ObjectID"); 31 Label l1 = new Label(); 32 mv.visitJumpInsn(IFEQ, l1); 33 Label l2 = new Label(); 34 mv.visitLabel(l2); 35 mv.visitLineNumber(65, l2); 36 mv.visitVarInsn(ALOAD, 0); 37 mv.visitVarInsn(ALOAD, 0); 38 mv.visitFieldInsn(GETFIELD, "java/util/concurrent/LinkedBlockingQueue$Node", "item", "Ljava/lang/Object;"); 39 mv.visitTypeInsn(CHECKCAST, "com/tc/object/ObjectID"); 40 mv.visitMethodInsn(INVOKESTATIC, "com/tc/object/bytecode/ManagerUtil", "lookupObject", "(Lcom/tc/object/ObjectID;)Ljava/lang/Object;"); 41 mv.visitFieldInsn(PUTFIELD, "java/util/concurrent/LinkedBlockingQueue$Node", "item", "Ljava/lang/Object;"); 42 mv.visitLabel(l1); 43 mv.visitLineNumber(67, l1); 44 mv.visitVarInsn(ALOAD, 0); 45 mv.visitFieldInsn(GETFIELD, "java/util/concurrent/LinkedBlockingQueue$Node", "item", "Ljava/lang/Object;"); 46 mv.visitInsn(ARETURN); 47 Label l3 = new Label(); 48 mv.visitLabel(l3); 49 mv.visitLocalVariable("this", "Ljava/util/concurrent/LinkedBlockingQueue$Node;", "Ljava/util/concurrent/LinkedBlockingQueue<TE;>.Node<TE;>;", l0, l3, 0); 50 mv.visitMaxs(2, 1); 51 mv.visitEnd(); 52 } 53 } | Popular Tags |