1 4 package com.tc.object.bytecode; 5 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 HashtableMethodCreator implements MethodCreator, Opcodes { 12 13 public void createMethods(ClassVisitor classVisitor) { 14 MethodVisitor mv = classVisitor.visitMethod(ACC_PUBLIC, "getEntry", 15 "(Ljava/lang/Object;)Ljava/util/Hashtable$Entry;", null, null); 16 Label l0 = new Label(); 17 mv.visitLabel(l0); 18 mv.visitVarInsn(ALOAD, 0); 19 mv.visitFieldInsn(GETFIELD, "java/util/Hashtable", "table", "[Ljava/util/Hashtable$Entry;"); 20 mv.visitVarInsn(ASTORE, 2); 21 Label l1 = new Label(); 22 mv.visitLabel(l1); 23 mv.visitVarInsn(ALOAD, 1); 24 mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "hashCode", "()I"); 25 mv.visitVarInsn(ISTORE, 3); 26 Label l2 = new Label(); 27 mv.visitLabel(l2); 28 mv.visitVarInsn(ILOAD, 3); 29 mv.visitLdcInsn(new Integer (2147483647)); 30 mv.visitInsn(IAND); 31 mv.visitVarInsn(ALOAD, 2); 32 mv.visitInsn(ARRAYLENGTH); 33 mv.visitInsn(IREM); 34 mv.visitVarInsn(ISTORE, 4); 35 Label l3 = new Label(); 36 mv.visitLabel(l3); 37 mv.visitVarInsn(ALOAD, 2); 38 mv.visitVarInsn(ILOAD, 4); 39 mv.visitInsn(AALOAD); 40 mv.visitVarInsn(ASTORE, 5); 41 Label l4 = new Label(); 42 mv.visitLabel(l4); 43 mv.visitVarInsn(ALOAD, 5); 44 Label l5 = new Label(); 45 mv.visitJumpInsn(IFNULL, l5); 46 Label l6 = new Label(); 47 mv.visitLabel(l6); 48 mv.visitVarInsn(ALOAD, 5); 49 mv.visitFieldInsn(GETFIELD, "java/util/Hashtable$Entry", "hash", "I"); 50 mv.visitVarInsn(ILOAD, 3); 51 Label l7 = new Label(); 52 mv.visitJumpInsn(IF_ICMPNE, l7); 53 mv.visitVarInsn(ALOAD, 5); 54 mv.visitFieldInsn(GETFIELD, "java/util/Hashtable$Entry", "key", "Ljava/lang/Object;"); 55 mv.visitVarInsn(ALOAD, 1); 56 mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z"); 57 mv.visitJumpInsn(IFEQ, l7); 58 Label l8 = new Label(); 59 mv.visitLabel(l8); 60 mv.visitVarInsn(ALOAD, 5); 61 mv.visitTypeInsn(CHECKCAST, "java/util/Hashtable$Entry"); 62 mv.visitInsn(ARETURN); 63 mv.visitLabel(l7); 64 mv.visitVarInsn(ALOAD, 5); 65 mv.visitFieldInsn(GETFIELD, "java/util/Hashtable$Entry", "next", "Ljava/util/Hashtable$Entry;"); 66 mv.visitVarInsn(ASTORE, 5); 67 mv.visitJumpInsn(GOTO, l4); 68 mv.visitLabel(l5); 69 mv.visitInsn(ACONST_NULL); 70 mv.visitInsn(ARETURN); 71 mv.visitMaxs(0, 0); 72 } 73 74 } 75 | Popular Tags |