01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.weblogic.transform;
06:
07: import com.tc.asm.ClassAdapter;
08: import com.tc.asm.ClassVisitor;
09: import com.tc.asm.Label;
10: import com.tc.asm.MethodAdapter;
11: import com.tc.asm.MethodVisitor;
12: import com.tc.asm.Opcodes;
13: import com.tc.object.bytecode.ByteCodeUtil;
14: import com.tc.object.bytecode.ClassAdapterFactory;
15:
16: public class EJBCodeGeneratorAdapter extends ClassAdapter implements
17: ClassAdapterFactory {
18:
19: public EJBCodeGeneratorAdapter() {
20: super (null);
21: }
22:
23: private EJBCodeGeneratorAdapter(ClassVisitor cv, ClassLoader caller) {
24: super (cv);
25: }
26:
27: public ClassAdapter create(ClassVisitor visitor, ClassLoader loader) {
28: return new EJBCodeGeneratorAdapter(visitor, loader);
29: }
30:
31: public MethodVisitor visitMethod(int access, String name,
32: String desc, String signature, String[] exceptions) {
33: MethodVisitor mv = super .visitMethod(access, name, desc,
34: signature, exceptions);
35: if ("appendInterfaceMethodDeclaration".equals(name)) {
36: mv = new AppendInterfaceMethodDeclarationAdapter(mv);
37: }
38: return mv;
39: }
40:
41: private static class AppendInterfaceMethodDeclarationAdapter extends
42: MethodAdapter implements Opcodes {
43:
44: public AppendInterfaceMethodDeclarationAdapter(MethodVisitor mv) {
45: super (mv);
46: }
47:
48: public void visitCode() {
49: super .visitCode();
50: Label notTC = new Label();
51: mv.visitVarInsn(ALOAD, 2);
52: mv.visitMethodInsn(INVOKEVIRTUAL,
53: "java/lang/reflect/Method", "getName",
54: "()Ljava/lang/String;");
55: mv.visitLdcInsn(ByteCodeUtil.TC_METHOD_PREFIX);
56: mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String",
57: "startsWith", "(Ljava/lang/String;)Z");
58: mv.visitJumpInsn(IFEQ, notTC);
59: mv.visitInsn(RETURN);
60: mv.visitLabel(notTC);
61: }
62:
63: }
64:
65: }
|