aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2011-07-24 04:38:31 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2011-07-24 04:38:31 +0200
commit92eb7033fa16ef14c05cb4461dc005a752399180 (patch)
treef10fa176acc63aeeca57d18a084c14f66c689839 /src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
parentd4b4a92302af4d52a2a1d07524cb506bdecadf14 (diff)
parenta24daba66ce4705429b266972319ad15b1db0d70 (diff)
downloadlombok-92eb7033fa16ef14c05cb4461dc005a752399180.tar.gz
lombok-92eb7033fa16ef14c05cb4461dc005a752399180.tar.bz2
lombok-92eb7033fa16ef14c05cb4461dc005a752399180.zip
Merge branch 'i164diag'
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index c49346bc..f67bd4e3 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -21,11 +21,15 @@
*/
package lombok.eclipse.agent;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
+import java.security.ProtectionDomain;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import lombok.bytecode.ClassFileMetaData;
import lombok.core.Agent;
import lombok.patcher.Hook;
import lombok.patcher.MethodTarget;
@@ -68,6 +72,15 @@ public class EclipsePatcher extends Agent {
else ecj = injected;
registerPatchScripts(instrumentation, injected, ecj);
+ instrumentation.addTransformer(new ClassFileTransformer() {
+ @Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
+ ClassFileMetaData meta = new ClassFileMetaData(classfileBuffer);
+ if (meta.usesField("org/eclipse/jdt/internal/compiler/ast/TypeDeclaration", "scope")) {
+ return Issue164Fixer.fix(classfileBuffer);
+ }
+ return null;
+ }
+ }, true);
}
private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses, boolean ecjOnly) {