From 34055fcdff786c9b809ce1a08c1c9218968ebc7d Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sun, 22 Jul 2012 07:17:52 +0200 Subject: A potential fix for issue #394; Memory leaks in eclipse introduced in lombok 0.11.2 due to a fix involving WeakHashMaps for lazy getters of type boolean. --- src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java') diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 7120a602..ae488612 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -773,18 +773,19 @@ public class EclipseHandlerUtil { } } - private static final Map generatedLazyGetters = new WeakHashMap(); + private static final Map generatedLazyGettersWithPrimitiveBoolean = new WeakHashMap(); + private static final Object MARKER = new Object(); static void registerCreatedLazyGetter(FieldDeclaration field, char[] methodName, TypeReference returnType) { - generatedLazyGetters.put(field, new GetterMethod(methodName, returnType)); + if (!nameEquals(returnType.getTypeName(), "boolean") || returnType.dimensions() > 0) return; + generatedLazyGettersWithPrimitiveBoolean.put(field, MARKER); } private static GetterMethod findGetter(EclipseNode field) { FieldDeclaration fieldDeclaration = (FieldDeclaration) field.get(); - GetterMethod gm = generatedLazyGetters.get(fieldDeclaration); - if (gm != null) return gm; + boolean forceBool = generatedLazyGettersWithPrimitiveBoolean.containsKey(fieldDeclaration); TypeReference fieldType = fieldDeclaration.type; - boolean isBoolean = nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0; + boolean isBoolean = forceBool || (nameEquals(fieldType.getTypeName(), "boolean") && fieldType.dimensions() == 0); EclipseNode typeNode = field.up(); for (String potentialGetterName : toAllGetterNames(field, isBoolean)) { -- cgit