aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/JavacHandlerUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index bc4dda8e..de73b3be 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -25,13 +25,11 @@ import static lombok.core.TransformationsUtil.INVALID_ON_BUILDERS;
import static lombok.javac.Javac.*;
import java.lang.annotation.Annotation;
-import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import java.util.WeakHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -41,6 +39,7 @@ import lombok.Getter;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValue;
+import lombok.core.ReferenceFieldAugment;
import lombok.core.TransformationsUtil;
import lombok.core.TypeResolver;
import lombok.delombok.LombokOptionsFactory;
@@ -109,7 +108,7 @@ public class JavacHandlerUtil {
}
}
- private static Map<JCTree, WeakReference<JCTree>> generatedNodes = new WeakHashMap<JCTree, WeakReference<JCTree>>();
+ private static ReferenceFieldAugment<JCTree, JCTree> generatedNodes = ReferenceFieldAugment.augmentWeakField(JCTree.class, JCTree.class, "lombok$generatedNodes");
/**
* Contributed by Jan Lahoda; many lombok transformations should not be run (or a lite version should be run) when the netbeans editor
@@ -126,10 +125,7 @@ public class JavacHandlerUtil {
}
public static JCTree getGeneratedBy(JCTree node) {
- synchronized (generatedNodes) {
- WeakReference<JCTree> ref = generatedNodes.get(node);
- return ref == null ? null : ref.get();
- }
+ return generatedNodes.get(node);
}
public static boolean isGenerated(JCTree node) {
@@ -145,10 +141,8 @@ public class JavacHandlerUtil {
public static <T extends JCTree> T setGeneratedBy(T node, JCTree source, Context context) {
if (node == null) return null;
- synchronized (generatedNodes) {
- if (source == null) generatedNodes.remove(node);
- else generatedNodes.put(node, new WeakReference<JCTree>(source));
- }
+ if (source == null) generatedNodes.clear(node);
+ else generatedNodes.set(node, source);
if (source != null && (!inNetbeansEditor(context) || (node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0))) node.pos = source.pos;
return node;
}