From dec4be37381caaf4e2ec9af301153734088889fd Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 25 Jun 2009 05:33:04 +0200 Subject: Removed adding the statement: 'final int PRIME = 31;' in the HandleData's createHashCode method when there are 0 fields in the type (it would generate a local variable never used warning!) --- src/lombok/eclipse/handlers/HandleData.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lombok/eclipse/handlers/HandleData.java b/src/lombok/eclipse/handlers/HandleData.java index e90f33fd..c65ea5cf 100644 --- a/src/lombok/eclipse/handlers/HandleData.java +++ b/src/lombok/eclipse/handlers/HandleData.java @@ -449,13 +449,16 @@ public class HandleData implements EclipseAnnotationHandler { final char[] PRIME = "PRIME".toCharArray(); final char[] RESULT = "result".toCharArray(); + final boolean isEmpty = fields.isEmpty(); /* final int PRIME = 31; */ { - LocalDeclaration primeDecl = new LocalDeclaration(PRIME, 0 ,0); - primeDecl.modifiers = Modifier.FINAL; - primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0); - primeDecl.initialization = new IntLiteral("31".toCharArray(), 0, 0); - statements.add(primeDecl); + if ( !isEmpty ) { /* Without fields, PRIME isn't used, and that would trigger a 'local variable not used' warning. */ + LocalDeclaration primeDecl = new LocalDeclaration(PRIME, 0 ,0); + primeDecl.modifiers = Modifier.FINAL; + primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0); + primeDecl.initialization = new IntLiteral("31".toCharArray(), 0, 0); + statements.add(primeDecl); + } } /* int result = 1; */ { -- cgit