KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > bytecode > LinkedListAdapter


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.bytecode;
5
6 import com.tc.asm.ClassVisitor;
7 import com.tc.asm.MethodAdapter;
8 import com.tc.asm.MethodVisitor;
9 import com.tc.asm.Opcodes;
10
11 public class LinkedListAdapter {
12
13   public static class ListIteratorAdapter extends AbstractMethodAdapter {
14
15
16     public MethodVisitor adapt(ClassVisitor classVisitor) {
17       MethodVisitor mv = visitOriginal(classVisitor);
18       return new Adapter(mv);
19     }
20
21     public boolean doesOriginalNeedAdapting() {
22       return false;
23     }
24
25     private static class Adapter extends MethodAdapter implements Opcodes {
26
27       public Adapter(MethodVisitor mv) {
28         super(mv);
29         mv.visitTypeInsn(NEW, "com/tc/util/ListIteratorWrapper");
30         mv.visitInsn(DUP);
31         mv.visitVarInsn(ALOAD, 0);
32       }
33
34       public void visitInsn(int opcode) {
35         if (ARETURN == opcode) {
36           mv.visitMethodInsn(INVOKESPECIAL, "com/tc/util/ListIteratorWrapper", "<init>", "(Ljava/util/List;Ljava/util/ListIterator;)V");
37         }
38         super.visitInsn(opcode);
39       }
40
41
42     }
43   }
44 }
45
Popular Tags