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