1
2
3
4
5
6
7
8 package it.imolinfo.jbi4corba.webservice.generator.bcm;
9
10 import it.imolinfo.jbi4corba.Logger;
11 import it.imolinfo.jbi4corba.LoggerFactory;
12 import it.imolinfo.jbi4corba.webservice.generator.TypeUtils;
13 import it.imolinfo.jbi4corba.webservice.generator.UnionType;
14 import it.imolinfo.jbi4corba.webservice.generator.UnionTypeUtils;
15
16 import java.util.Map;
17
18 import org.objectweb.asm.MethodVisitor;
19 import org.objectweb.asm.Opcodes;
20 import org.objectweb.asm.util.TraceMethodVisitor;
21
22
23
24
25
26 public class ReplaceUnionsMethodVisitor extends TraceMethodVisitor {
27
28
29
30
31
32
33 private static final Logger LOG = LoggerFactory
34 .getLogger(ConstructorModMethodVisitor.class);
35
36 private Map<String, UnionType> allUnionTypes;
37
38
39
40
41
42
43
44
45
46
47
48
49 public ReplaceUnionsMethodVisitor(MethodVisitor mv,
50 Map<String, UnionType> allUnionTypes) {
51 super(mv);
52
53 this.allUnionTypes = allUnionTypes;
54 }
55
56
57
58
59
60 @Override
61 public void visitFieldInsn(int opcode, String className, String fieldName,
62 String fieldType) {
63
64 LOG.debug("<<<<< AppenderMethodVisitor.visitFieldInsn - end");
65 if (opcode == Opcodes.PUTFIELD || opcode == Opcodes.GETFIELD) {
66 boolean isArray = TypeUtils.isArray(fieldType);
67 UnionType unionField = UnionTypeUtils.isUnionType(fieldType, isArray, allUnionTypes);
68 if ( unionField != null) {
69 String arrayStr = TypeUtils.getArrayDimmentionAsPrefix(fieldType);
70
71 fieldType = arrayStr + "L" + unionField.getTypeName().replace('.', '/') + "Wrapper;";
72
73
74 }
75 }
76 super.visitFieldInsn(opcode, className, fieldName, fieldType);
77
78 }
79
80
81
82 }