aboutsummaryrefslogtreecommitdiff
path: root/src_eclipseagent/lombok/eclipse/agent/EclipseCUDTransformer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src_eclipseagent/lombok/eclipse/agent/EclipseCUDTransformer.java')
-rw-r--r--src_eclipseagent/lombok/eclipse/agent/EclipseCUDTransformer.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src_eclipseagent/lombok/eclipse/agent/EclipseCUDTransformer.java b/src_eclipseagent/lombok/eclipse/agent/EclipseCUDTransformer.java
new file mode 100644
index 00000000..b1dc85cc
--- /dev/null
+++ b/src_eclipseagent/lombok/eclipse/agent/EclipseCUDTransformer.java
@@ -0,0 +1,31 @@
+package lombok.eclipse.agent;
+
+import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Opcodes;
+
+class EclipseCUDTransformer {
+ public byte[] transform(byte[] classfileBuffer) {
+ ClassReader reader = new ClassReader(classfileBuffer);
+ ClassWriter writer = new ClassWriter(reader, 0);
+
+ ClassAdapter adapter = new CUDPatcherAdapter(writer);
+ reader.accept(adapter, 0);
+ return writer.toByteArray();
+ }
+
+ private static class CUDPatcherAdapter extends ClassAdapter {
+ CUDPatcherAdapter(ClassVisitor cv) {
+ super(cv);
+ }
+
+ @Override public void visitEnd() {
+ FieldVisitor fv = cv.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_TRANSIENT, "$lombokAST", "Ljava/lang/Object;", null, null);
+ fv.visitEnd();
+ cv.visitEnd();
+ }
+ }
+}