diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/core/AnnotationProcessor.java | 10 | ||||
-rw-r--r-- | src/core/lombok/core/Version.java | 4 | ||||
-rw-r--r-- | src/core/lombok/core/debug/DebugSnapshotStore.java | 3 | ||||
-rw-r--r-- | src/core/lombok/eclipse/HandlerLibrary.java | 15 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 42 | ||||
-rw-r--r-- | src/core/lombok/javac/HandlerLibrary.java | 13 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 18 |
7 files changed, 32 insertions, 73 deletions
diff --git a/src/core/lombok/core/AnnotationProcessor.java b/src/core/lombok/core/AnnotationProcessor.java index 734150cd..ecce1849 100644 --- a/src/core/lombok/core/AnnotationProcessor.java +++ b/src/core/lombok/core/AnnotationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,9 +29,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.WeakHashMap; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.ProcessingEnvironment; @@ -63,8 +61,8 @@ public class AnnotationProcessor extends AbstractProcessor { private final List<ProcessorDescriptor> active = new ArrayList<ProcessorDescriptor>(); private final List<String> delayedWarnings = new ArrayList<String>(); - private static final Map<ClassLoader, Boolean> lombokAlreadyAddedTo = new WeakHashMap<ClassLoader, Boolean>(); - + private static final BooleanFieldAugment<ClassLoader> lombokAlreadyAddedTo = BooleanFieldAugment.augment(ClassLoader.class, "lombok$alreadyAddedTo"); + static class JavacDescriptor extends ProcessorDescriptor { private Processor processor; @@ -100,7 +98,7 @@ public class AnnotationProcessor extends AbstractProcessor { private ClassLoader findAndPatchClassLoader(ProcessingEnvironment procEnv) throws Exception { ClassLoader environmentClassLoader = procEnv.getClass().getClassLoader(); if (environmentClassLoader != null && environmentClassLoader.getClass().getCanonicalName().equals("org.codehaus.plexus.compiler.javac.IsolatedClassLoader")) { - if (lombokAlreadyAddedTo.put(environmentClassLoader, true) == null) { + if (!lombokAlreadyAddedTo.set(environmentClassLoader)) { Method m = environmentClassLoader.getClass().getDeclaredMethod("addURL", URL.class); URL selfUrl = new File(ClassRootFinder.findClassRootOfClass(AnnotationProcessor.class)).toURI().toURL(); m.invoke(environmentClassLoader, selfUrl); diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index 6e68f035..2bd07d5a 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +28,7 @@ public class Version { // ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries). // Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example. // Official builds always end in an even number. (Since 0.10.2). - private static final String VERSION = "1.12.5"; + private static final String VERSION = "1.12.7"; private static final String RELEASE_NAME = "Edgy Guinea Pig"; // private static final String RELEASE_NAME = "Angry Butterfly"; diff --git a/src/core/lombok/core/debug/DebugSnapshotStore.java b/src/core/lombok/core/debug/DebugSnapshotStore.java index 19f4d5b1..daaf9509 100644 --- a/src/core/lombok/core/debug/DebugSnapshotStore.java +++ b/src/core/lombok/core/debug/DebugSnapshotStore.java @@ -35,8 +35,9 @@ import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; public class DebugSnapshotStore { public static final DebugSnapshotStore INSTANCE = new DebugSnapshotStore(); - public static boolean GLOBAL_DSS_DISABLE_SWITCH = true; + public static final boolean GLOBAL_DSS_DISABLE_SWITCH = true; + // All access should synchronize on the map private final Map<CompilationUnitDeclaration, List<DebugSnapshot>> map = new WeakHashMap<CompilationUnitDeclaration, List<DebugSnapshot>>(); diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index ad9c87b9..9726255c 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,12 +33,12 @@ import java.util.HashMap; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; -import java.util.WeakHashMap; import lombok.Lombok; import lombok.core.AnnotationValues; import lombok.core.AnnotationValues.AnnotationValueDecodeFail; import lombok.core.configuration.ConfigurationKeysLoader; +import lombok.core.BooleanFieldAugment; import lombok.core.HandlerPriority; import lombok.core.SpiLoadUtil; import lombok.core.TypeLibrary; @@ -188,19 +188,14 @@ public class HandlerLibrary { } } - private static final Map<ASTNode, Object> handledMap = new WeakHashMap<ASTNode, Object>(); - private static final Object MARKER = new Object(); + private static final BooleanFieldAugment<ASTNode> handled = BooleanFieldAugment.augment(ASTNode.class, "lombok$handled"); private boolean checkAndSetHandled(ASTNode node) { - synchronized (handledMap) { - return handledMap.put(node, MARKER) != MARKER; - } + return !handled.set(node); } private boolean needsHandling(ASTNode node) { - synchronized (handledMap) { - return handledMap.get(node) != MARKER; - } + return !handled.get(node); } /** diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 94fdffad..a93f321b 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -25,7 +25,6 @@ import static lombok.eclipse.Eclipse.*; import static lombok.core.handlers.HandlerUtil.*; import java.lang.reflect.Constructor; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -35,7 +34,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.WeakHashMap; import lombok.AccessLevel; import lombok.ConfigurationKeys; @@ -45,6 +43,8 @@ import lombok.Lombok; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.core.AnnotationValues.AnnotationValue; +import lombok.core.BooleanFieldAugment; +import lombok.core.ReferenceFieldAugment; import lombok.core.TypeResolver; import lombok.core.handlers.HandlerUtil; import lombok.eclipse.EclipseAST; @@ -208,27 +208,10 @@ public class EclipseHandlerUtil { } } - private static Field generatedByField; - - static { - try { - generatedByField = ASTNode.class.getDeclaredField("$generatedBy"); - } catch (Throwable t) { - //ignore - no $generatedBy exists when running in ecj. - } - } - - private static Map<ASTNode, ASTNode> generatedNodes = new WeakHashMap<ASTNode, ASTNode>(); + private static ReferenceFieldAugment<ASTNode, ASTNode> generatedNodes = ReferenceFieldAugment.augment(ASTNode.class, ASTNode.class, "$generatedBy"); public static ASTNode getGeneratedBy(ASTNode node) { - if (generatedByField != null) { - try { - return (ASTNode) generatedByField.get(node); - } catch (Exception e) {} - } - synchronized (generatedNodes) { - return generatedNodes.get(node); - } + return generatedNodes.get(node); } public static boolean isGenerated(ASTNode node) { @@ -236,15 +219,7 @@ public class EclipseHandlerUtil { } public static ASTNode setGeneratedBy(ASTNode node, ASTNode source) { - if (generatedByField != null) { - try { - generatedByField.set(node, source); - return node; - } catch (Exception e) {} - } - synchronized (generatedNodes) { - generatedNodes.put(node, source); - } + generatedNodes.set(node, source); return node; } @@ -866,12 +841,11 @@ public class EclipseHandlerUtil { } } - private static final Map<FieldDeclaration, Object> generatedLazyGettersWithPrimitiveBoolean = new WeakHashMap<FieldDeclaration, Object>(); - private static final Object MARKER = new Object(); + private static final BooleanFieldAugment<FieldDeclaration> generatedLazyGettersWithPrimitiveBoolean = BooleanFieldAugment.augment(FieldDeclaration.class, "lombok$booleanLazyGetter"); static void registerCreatedLazyGetter(FieldDeclaration field, char[] methodName, TypeReference returnType) { if (isBoolean(returnType)) { - generatedLazyGettersWithPrimitiveBoolean.put(field, MARKER); + generatedLazyGettersWithPrimitiveBoolean.set(field); } } @@ -881,7 +855,7 @@ public class EclipseHandlerUtil { private static GetterMethod findGetter(EclipseNode field) { FieldDeclaration fieldDeclaration = (FieldDeclaration) field.get(); - boolean forceBool = generatedLazyGettersWithPrimitiveBoolean.containsKey(fieldDeclaration); + boolean forceBool = generatedLazyGettersWithPrimitiveBoolean.get(fieldDeclaration); TypeReference fieldType = fieldDeclaration.type; boolean isBoolean = forceBool || isBoolean(fieldType); diff --git a/src/core/lombok/javac/HandlerLibrary.java b/src/core/lombok/javac/HandlerLibrary.java index 0905170b..7d40204b 100644 --- a/src/core/lombok/javac/HandlerLibrary.java +++ b/src/core/lombok/javac/HandlerLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * Copyright (C) 2009-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,16 +30,16 @@ import java.util.HashMap; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; -import java.util.WeakHashMap; import javax.annotation.processing.Messager; import javax.tools.Diagnostic; +import lombok.core.AnnotationValues.AnnotationValueDecodeFail; +import lombok.core.BooleanFieldAugment; import lombok.core.HandlerPriority; import lombok.core.SpiLoadUtil; import lombok.core.TypeLibrary; import lombok.core.TypeResolver; -import lombok.core.AnnotationValues.AnnotationValueDecodeFail; import lombok.core.configuration.ConfigurationKeysLoader; import lombok.javac.handlers.JavacHandlerUtil; @@ -206,13 +206,10 @@ public class HandlerLibrary { if (t != null) t.printStackTrace(); } - private static final Map<JCTree, Object> handledMap = new WeakHashMap<JCTree, Object>(); - private static final Object MARKER = new Object(); + private static final BooleanFieldAugment<JCTree> handled = BooleanFieldAugment.augment(JCTree.class, "lombok$handled"); private boolean checkAndSetHandled(JCTree node) { - synchronized (handledMap) { - return handledMap.put(node, MARKER) != MARKER; - } + return !handled.set(node); } /** diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 37164a6c..aa395e08 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -25,14 +25,12 @@ import static lombok.core.handlers.HandlerUtil.*; 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.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.WeakHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -43,8 +41,9 @@ import lombok.Getter; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.core.AnnotationValues.AnnotationValue; -import lombok.core.handlers.HandlerUtil; +import lombok.core.ReferenceFieldAugment; import lombok.core.TypeResolver; +import lombok.core.handlers.HandlerUtil; import lombok.delombok.LombokOptionsFactory; import lombok.experimental.Accessors; import lombok.javac.Javac; @@ -111,7 +110,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 @@ -128,10 +127,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) { @@ -147,10 +143,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; } |