1
2
3
4
5
6
7
8
9 package it.imolinfo.jbi4corba.webservice.generator.bcm;
10
11 import it.imolinfo.jbi4corba.Logger;
12 import it.imolinfo.jbi4corba.LoggerFactory;
13
14 import org.objectweb.asm.ClassAdapter;
15 import org.objectweb.asm.ClassVisitor;
16 import org.objectweb.asm.ClassWriter;
17 import org.objectweb.asm.FieldVisitor;
18 import org.objectweb.asm.Opcodes;
19
20
21
22
23
24
25 public class UIDAdapter extends ClassAdapter {
26
27
28
29
30 private static final Logger LOG = LoggerFactory.getLogger(UIDAdapter.class);
31
32
33
34
35 protected ClassWriter classWriter = null;
36
37
38
39
40
41 protected Long newSerialVersionUID = null;
42
43
44
45
46
47
48
49
50
51 public UIDAdapter(ClassVisitor cv,
52 ClassWriter cw,
53 Long uid) {
54 super(cv);
55
56 classWriter = cw;
57 newSerialVersionUID = uid;
58
59 LOG.debug("new UIDAdapter; ClassVisitor=" + cv
60 + "; ClassWriter=" + cw
61 + "; newSerialVersionUID=" + uid);
62 }
63
64
65
66
67
68
69 @Override
70 public void visitEnd() {
71
72 if (newSerialVersionUID != null) {
73 LOG.debug("addSerialVersionUid. uid=" + newSerialVersionUID
74 + "; classWriter=" + classWriter);
75
76 FieldVisitor fieldVisitor = super.visitField(
77 Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC,
78 "serialVersionUID",
79 "J",
80 null,
81 newSerialVersionUID);
82
83 fieldVisitor.visitEnd();
84
85 }
86
87 super.visitEnd();
88 }
89
90 }