diff options
9 files changed, 160 insertions, 94 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 82a8f00e..50991e7b 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 The Project Lombok Authors. + * Copyright (C) 2009-2012 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 @@ -32,6 +32,16 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import lombok.AccessLevel; +import lombok.EqualsAndHashCode; +import lombok.core.AST.Kind; +import lombok.core.AnnotationValues; +import lombok.eclipse.Eclipse; +import lombok.eclipse.EclipseAnnotationHandler; +import lombok.eclipse.EclipseNode; +import lombok.eclipse.handlers.EclipseHandlerUtil.FieldAccess; +import lombok.eclipse.handlers.EclipseHandlerUtil.MemberExistsResult; + import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Argument; @@ -72,19 +82,15 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.mangosdk.spi.ProviderFor; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.core.AnnotationValues; -import lombok.core.AST.Kind; -import lombok.eclipse.Eclipse; -import lombok.eclipse.EclipseAnnotationHandler; -import lombok.eclipse.EclipseNode; - /** * Handles the {@code EqualsAndHashCode} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndHashCode> { + + private final char[] PRIME = "PRIME".toCharArray(); + private final char[] RESULT = "result".toCharArray(); + private static final Set<String> BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList( "byte", "short", "int", "long", "char", "boolean", "double", "float"))); @@ -257,10 +263,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH method.arguments = null; List<Statement> statements = new ArrayList<Statement>(); - List<Expression> intoResult = new ArrayList<Expression>(); - final char[] PRIME = "PRIME".toCharArray(); - final char[] RESULT = "result".toCharArray(); final boolean isEmpty = fields.isEmpty(); /* final int PRIME = 31; */ { @@ -294,16 +297,30 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH callToSuper.receiver = new SuperReference(pS, pE); setGeneratedBy(callToSuper.receiver, source); callToSuper.selector = "hashCode".toCharArray(); - intoResult.add(callToSuper); + statements.add(createResultCalculation(source, callToSuper)); } - int tempCounter = 0; for (EclipseNode field : fields) { TypeReference fType = getFieldType(field, fieldAccess); + char[] dollarFieldName = ("$" + field.getName()).toCharArray(); char[] token = fType.getLastToken(); Expression fieldAccessor = createFieldAccessor(field, fieldAccess, source); if (fType.dimensions() == 0 && token != null) { - if (Arrays.equals(TypeConstants.FLOAT, token)) { + if (Arrays.equals(TypeConstants.BOOLEAN, token)) { + /* booleanField ? 1231 : 1237 */ + IntLiteral int1231 = makeIntLiteral("1231".toCharArray(), source); + IntLiteral int1237 = makeIntLiteral("1237".toCharArray(), source); + ConditionalExpression int1231or1237 = new ConditionalExpression(fieldAccessor, int1231, int1237); + setGeneratedBy(int1231or1237, source); + statements.add(createResultCalculation(source, int1231or1237)); + } else if (Arrays.equals(TypeConstants.LONG, token)) { + statements.add(createLocalDeclaration(source, dollarFieldName, TypeReference.baseTypeReference(TypeIds.T_long, 0), fieldAccessor)); + SingleNameReference copy1 = new SingleNameReference(dollarFieldName, p); + setGeneratedBy(copy1, source); + SingleNameReference copy2 = new SingleNameReference(dollarFieldName, p); + setGeneratedBy(copy2, source); + statements.add(createResultCalculation(source, longToIntForHashCode(copy1, copy2, source))); + } else if (Arrays.equals(TypeConstants.FLOAT, token)) { /* Float.floatToIntBits(fieldName) */ MessageSend floatToIntBits = new MessageSend(); floatToIntBits.sourceStart = pS; floatToIntBits.sourceEnd = pE; @@ -311,7 +328,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH floatToIntBits.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA_LANG_FLOAT); floatToIntBits.selector = "floatToIntBits".toCharArray(); floatToIntBits.arguments = new Expression[] { fieldAccessor }; - intoResult.add(floatToIntBits); + statements.add(createResultCalculation(source, floatToIntBits)); } else if (Arrays.equals(TypeConstants.DOUBLE, token)) { /* longToIntForHashCode(Double.doubleToLongBits(fieldName)) */ MessageSend doubleToLongBits = new MessageSend(); @@ -320,47 +337,38 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH doubleToLongBits.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA_LANG_DOUBLE); doubleToLongBits.selector = "doubleToLongBits".toCharArray(); doubleToLongBits.arguments = new Expression[] { fieldAccessor }; - final char[] tempName = ("temp" + ++tempCounter).toCharArray(); - LocalDeclaration tempVar = new LocalDeclaration(tempName, pS, pE); - setGeneratedBy(tempVar, source); - tempVar.initialization = doubleToLongBits; - tempVar.type = TypeReference.baseTypeReference(TypeIds.T_long, 0); - tempVar.type.sourceStart = pS; tempVar.type.sourceEnd = pE; - setGeneratedBy(tempVar.type, source); - tempVar.modifiers = Modifier.FINAL; - statements.add(tempVar); - SingleNameReference copy1 = new SingleNameReference(tempName, p); + statements.add(createLocalDeclaration(source, dollarFieldName, TypeReference.baseTypeReference(TypeIds.T_long, 0), doubleToLongBits)); + SingleNameReference copy1 = new SingleNameReference(dollarFieldName, p); setGeneratedBy(copy1, source); - SingleNameReference copy2 = new SingleNameReference(tempName, p); + SingleNameReference copy2 = new SingleNameReference(dollarFieldName, p); setGeneratedBy(copy2, source); - intoResult.add(longToIntForHashCode(copy1, copy2, source)); - } else if (Arrays.equals(TypeConstants.BOOLEAN, token)) { - /* booleanField ? 1231 : 1237 */ - IntLiteral int1231 = makeIntLiteral("1231".toCharArray(), source); - IntLiteral int1237 = makeIntLiteral("1237".toCharArray(), source); - ConditionalExpression int1231or1237 = new ConditionalExpression(fieldAccessor, int1231, int1237); - setGeneratedBy(int1231or1237, source); - intoResult.add(int1231or1237); - } else if (Arrays.equals(TypeConstants.LONG, token)) { - intoResult.add(longToIntForHashCode(fieldAccessor, createFieldAccessor(field, fieldAccess, source), source)); + statements.add(createResultCalculation(source, longToIntForHashCode(copy1, copy2, source))); } else if (BUILT_IN_TYPES.contains(new String(token))) { - intoResult.add(fieldAccessor); + statements.add(createResultCalculation(source, fieldAccessor)); } else /* objects */ { - /* this.fieldName == null ? 0 : this.fieldName.hashCode() */ + /* final java.lang.Object $fieldName = this.fieldName; */ + /* $fieldName == null ? 0 : $fieldName.hashCode() */ + statements.add(createLocalDeclaration(source, dollarFieldName, generateQualifiedTypeRef(source, TypeConstants.JAVA_LANG_OBJECT), fieldAccessor)); + + SingleNameReference copy1 = new SingleNameReference(dollarFieldName, p); + setGeneratedBy(copy1, source); + SingleNameReference copy2 = new SingleNameReference(dollarFieldName, p); + setGeneratedBy(copy2, source); + MessageSend hashCodeCall = new MessageSend(); hashCodeCall.sourceStart = pS; hashCodeCall.sourceEnd = pE; setGeneratedBy(hashCodeCall, source); - hashCodeCall.receiver = createFieldAccessor(field, fieldAccess, source); + hashCodeCall.receiver = copy1; hashCodeCall.selector = "hashCode".toCharArray(); NullLiteral nullLiteral = new NullLiteral(pS, pE); setGeneratedBy(nullLiteral, source); - EqualExpression objIsNull = new EqualExpression(fieldAccessor, nullLiteral, OperatorIds.EQUAL_EQUAL); + EqualExpression objIsNull = new EqualExpression(copy2, nullLiteral, OperatorIds.EQUAL_EQUAL); setGeneratedBy(objIsNull, source); IntLiteral int0 = makeIntLiteral("0".toCharArray(), source); ConditionalExpression nullOrHashCode = new ConditionalExpression(objIsNull, int0, hashCodeCall); nullOrHashCode.sourceStart = pS; nullOrHashCode.sourceEnd = pE; setGeneratedBy(nullOrHashCode, source); - intoResult.add(nullOrHashCode); + statements.add(createResultCalculation(source, nullOrHashCode)); } } else if (fType.dimensions() > 0 && token != null) { /* Arrays.deepHashCode(array) //just hashCode for simple arrays */ @@ -374,29 +382,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH arraysHashCodeCall.selector = "hashCode".toCharArray(); } arraysHashCodeCall.arguments = new Expression[] { fieldAccessor }; - intoResult.add(arraysHashCodeCall); - } - } - - /* fold each intoResult entry into: - result = result * PRIME + (item); */ { - for (Expression ex : intoResult) { - SingleNameReference resultRef = new SingleNameReference(RESULT, p); - setGeneratedBy(resultRef, source); - SingleNameReference primeRef = new SingleNameReference(PRIME, p); - setGeneratedBy(primeRef, source); - BinaryExpression multiplyByPrime = new BinaryExpression(resultRef, primeRef, OperatorIds.MULTIPLY); - multiplyByPrime.sourceStart = pS; multiplyByPrime.sourceEnd = pE; - setGeneratedBy(multiplyByPrime, source); - BinaryExpression addItem = new BinaryExpression(multiplyByPrime, ex, OperatorIds.PLUS); - addItem.sourceStart = pS; addItem.sourceEnd = pE; - setGeneratedBy(addItem, source); - resultRef = new SingleNameReference(RESULT, p); - setGeneratedBy(resultRef, source); - Assignment assignment = new Assignment(resultRef, addItem, pE); - assignment.sourceStart = pS; assignment.sourceEnd = assignment.statementEnd = pE; - setGeneratedBy(assignment, source); - statements.add(assignment); + statements.add(createResultCalculation(source, arraysHashCodeCall)); } } @@ -410,6 +396,40 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH method.statements = statements.toArray(new Statement[statements.size()]); return method; } + + private LocalDeclaration createLocalDeclaration(ASTNode source, char[] dollarFieldName, TypeReference type, Expression initializer) { + int pS = source.sourceStart, pE = source.sourceEnd; + LocalDeclaration tempVar = new LocalDeclaration(dollarFieldName, pS, pE); + setGeneratedBy(tempVar, source); + tempVar.initialization = initializer; + tempVar.type = type; + tempVar.type.sourceStart = pS; tempVar.type.sourceEnd = pE; + setGeneratedBy(tempVar.type, source); + tempVar.modifiers = Modifier.FINAL; + return tempVar; + } + + private Expression createResultCalculation(ASTNode source, Expression ex) { + /* result = result * PRIME + (ex); */ + int pS = source.sourceStart, pE = source.sourceEnd; + long p = (long)pS << 32 | pE; + SingleNameReference resultRef = new SingleNameReference(RESULT, p); + setGeneratedBy(resultRef, source); + SingleNameReference primeRef = new SingleNameReference(PRIME, p); + setGeneratedBy(primeRef, source); + BinaryExpression multiplyByPrime = new BinaryExpression(resultRef, primeRef, OperatorIds.MULTIPLY); + multiplyByPrime.sourceStart = pS; multiplyByPrime.sourceEnd = pE; + setGeneratedBy(multiplyByPrime, source); + BinaryExpression addItem = new BinaryExpression(multiplyByPrime, ex, OperatorIds.PLUS); + addItem.sourceStart = pS; addItem.sourceEnd = pE; + setGeneratedBy(addItem, source); + resultRef = new SingleNameReference(RESULT, p); + setGeneratedBy(resultRef, source); + Assignment assignment = new Assignment(resultRef, addItem, pE); + assignment.sourceStart = pS; assignment.sourceEnd = assignment.statementEnd = pE; + setGeneratedBy(assignment, source); + return assignment; + } private TypeReference createTypeReference(EclipseNode type, long p) { List<String> list = new ArrayList<String>(); @@ -611,21 +631,37 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH setGeneratedBy(ifStatement, source); statements.add(ifStatement); } else /* objects */ { + /* final java.lang.Object this$fieldName = this.fieldName; */ + /* final java.lang.Object other$fieldName = other.fieldName; */ + /* if (this$fieldName == null ? other$fieldName != null : !this$fieldName.equals(other$fieldName)) return false;; */ + char[] thisDollarFieldName = ("this$" + field.getName()).toCharArray(); + char[] otherDollarFieldName = ("other$" + field.getName()).toCharArray(); + + statements.add(createLocalDeclaration(source, thisDollarFieldName, generateQualifiedTypeRef(source, TypeConstants.JAVA_LANG_OBJECT), thisFieldAccessor)); + statements.add(createLocalDeclaration(source, otherDollarFieldName, generateQualifiedTypeRef(source, TypeConstants.JAVA_LANG_OBJECT), otherFieldAccessor)); + + SingleNameReference this1 = new SingleNameReference(thisDollarFieldName, p); + setGeneratedBy(this1, source); + SingleNameReference this2 = new SingleNameReference(thisDollarFieldName, p); + setGeneratedBy(this2, source); + SingleNameReference other1 = new SingleNameReference(otherDollarFieldName, p); + setGeneratedBy(other1, source); + SingleNameReference other2 = new SingleNameReference(otherDollarFieldName, p); + setGeneratedBy(other2, source); + + NullLiteral nullLiteral = new NullLiteral(pS, pE); setGeneratedBy(nullLiteral, source); - EqualExpression fieldIsNull = new EqualExpression(thisFieldAccessor, nullLiteral, OperatorIds.EQUAL_EQUAL); + EqualExpression fieldIsNull = new EqualExpression(this1, nullLiteral, OperatorIds.EQUAL_EQUAL); nullLiteral = new NullLiteral(pS, pE); setGeneratedBy(nullLiteral, source); - EqualExpression otherFieldIsntNull = new EqualExpression(otherFieldAccessor, nullLiteral, OperatorIds.NOT_EQUAL); + EqualExpression otherFieldIsntNull = new EqualExpression(other1, nullLiteral, OperatorIds.NOT_EQUAL); MessageSend equalsCall = new MessageSend(); equalsCall.sourceStart = pS; equalsCall.sourceEnd = pE; setGeneratedBy(equalsCall, source); - equalsCall.receiver = createFieldAccessor(field, fieldAccess, source); + equalsCall.receiver = this2; equalsCall.selector = "equals".toCharArray(); - Expression equalsArg = createFieldAccessor(field, fieldAccess, source, otherName); - CastExpression castEqualsArg = makeCastExpression(equalsArg, generateQualifiedTypeRef(source, TypeConstants.JAVA_LANG_OBJECT), source); - castEqualsArg.sourceStart = pS; castEqualsArg.sourceEnd = pE; - equalsCall.arguments = new Expression[] { castEqualsArg }; + equalsCall.arguments = new Expression[] { other2 }; UnaryExpression fieldsNotEqual = new UnaryExpression(equalsCall, OperatorIds.NOT); fieldsNotEqual.sourceStart = pS; fieldsNotEqual.sourceEnd = pE; setGeneratedBy(fieldsNotEqual, source); diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index 9869cf94..1017609b 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -434,7 +434,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas statements.append(generateCompareFloatOrDouble(thisFieldAccessor, otherFieldAccessor, maker, typeNode, false)); break; case DOUBLE: - /* if (Double(this.fieldName, other.fieldName) != 0) return false; */ + /* if (Double.compare(this.fieldName, other.fieldName) != 0) return false; */ statements.append(generateCompareFloatOrDouble(thisFieldAccessor, otherFieldAccessor, maker, typeNode, true)); break; default: diff --git a/test/transform/resource/after-ecj/Accessors.java b/test/transform/resource/after-ecj/Accessors.java index 4ee0ebcd..ae7eb0bb 100644 --- a/test/transform/resource/after-ecj/Accessors.java +++ b/test/transform/resource/after-ecj/Accessors.java @@ -74,7 +74,9 @@ class AccessorsChain { final @java.lang.SuppressWarnings("all") AccessorsPrefix3 other = (AccessorsPrefix3) o; if ((! other.canEqual((java.lang.Object) this))) return false; - if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals((java.lang.Object) other.getName())))) + final java.lang.Object this$fName = this.getName(); + final java.lang.Object other$fName = other.getName(); + if (((this$fName == null) ? (other$fName != null) : (! this$fName.equals(other$fName)))) return false; return true; } @@ -84,7 +86,8 @@ class AccessorsChain { public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { final int PRIME = 31; int result = 1; - result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode())); + final java.lang.Object $fName = this.getName(); + result = ((result * PRIME) + (($fName == null) ? 0 : $fName.hashCode())); return result; } AccessorsPrefix3() { diff --git a/test/transform/resource/after-ecj/DataOnLocalClass.java b/test/transform/resource/after-ecj/DataOnLocalClass.java index 44ae0ddc..76a4b47d 100644 --- a/test/transform/resource/after-ecj/DataOnLocalClass.java +++ b/test/transform/resource/after-ecj/DataOnLocalClass.java @@ -30,7 +30,9 @@ class DataOnLocalClass1 { return false; if ((this.getX() != other.getX())) return false; - if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals((java.lang.Object) other.getName())))) + final java.lang.Object this$name = this.getName(); + final java.lang.Object other$name = other.getName(); + if (((this$name == null) ? (other$name != null) : (! this$name.equals(other$name)))) return false; return true; } @@ -41,7 +43,8 @@ class DataOnLocalClass1 { final int PRIME = 31; int result = 1; result = ((result * PRIME) + this.getX()); - result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode())); + final java.lang.Object $name = this.getName(); + result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { @@ -77,7 +80,9 @@ class DataOnLocalClass2 { final @java.lang.SuppressWarnings("all") InnerLocal other = (InnerLocal) o; if ((! other.canEqual((java.lang.Object) this))) return false; - if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals((java.lang.Object) other.getName())))) + final java.lang.Object this$name = this.getName(); + final java.lang.Object other$name = other.getName(); + if (((this$name == null) ? (other$name != null) : (! this$name.equals(other$name)))) return false; return true; } @@ -87,7 +92,8 @@ class DataOnLocalClass2 { public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { final int PRIME = 31; int result = 1; - result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode())); + final java.lang.Object $name = this.getName(); + result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { diff --git a/test/transform/resource/after-ecj/DataPlain.java b/test/transform/resource/after-ecj/DataPlain.java index 6322d347..0828bc44 100644 --- a/test/transform/resource/after-ecj/DataPlain.java +++ b/test/transform/resource/after-ecj/DataPlain.java @@ -25,7 +25,9 @@ import lombok.Data; return false; if ((this.getX() != other.getX())) return false; - if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals((java.lang.Object) other.getName())))) + final java.lang.Object this$name = this.getName(); + final java.lang.Object other$name = other.getName(); + if (((this$name == null) ? (other$name != null) : (! this$name.equals(other$name)))) return false; return true; } @@ -36,7 +38,8 @@ import lombok.Data; final int PRIME = 31; int result = 1; result = ((result * PRIME) + this.getX()); - result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode())); + final java.lang.Object $name = this.getName(); + result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { @@ -69,7 +72,9 @@ import lombok.Data; return false; if ((this.getX() != other.getX())) return false; - if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals((java.lang.Object) other.getName())))) + final java.lang.Object this$name = this.getName(); + final java.lang.Object other$name = other.getName(); + if (((this$name == null) ? (other$name != null) : (! this$name.equals(other$name)))) return false; return true; } @@ -80,7 +85,8 @@ import lombok.Data; final int PRIME = 31; int result = 1; result = ((result * PRIME) + this.getX()); - result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode())); + final java.lang.Object $name = this.getName(); + result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { @@ -111,7 +117,9 @@ final @Data class Data3 { final @java.lang.SuppressWarnings("all") Data3 other = (Data3) o; if ((this.getX() != other.getX())) return false; - if (((this.getName() == null) ? (other.getName() != null) : (! this.getName().equals((java.lang.Object) other.getName())))) + final java.lang.Object this$name = this.getName(); + final java.lang.Object other$name = other.getName(); + if (((this$name == null) ? (other$name != null) : (! this$name.equals(other$name)))) return false; return true; } @@ -119,7 +127,8 @@ final @Data class Data3 { final int PRIME = 31; int result = 1; result = ((result * PRIME) + this.getX()); - result = ((result * PRIME) + ((this.getName() == null) ? 0 : this.getName().hashCode())); + final java.lang.Object $name = this.getName(); + result = ((result * PRIME) + (($name == null) ? 0 : $name.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { diff --git a/test/transform/resource/after-ecj/DataWithGetter.java b/test/transform/resource/after-ecj/DataWithGetter.java index 80e11be4..cc9ce1c0 100644 --- a/test/transform/resource/after-ecj/DataWithGetter.java +++ b/test/transform/resource/after-ecj/DataWithGetter.java @@ -24,7 +24,9 @@ return false; if ((this.getY() != other.getY())) return false; - if (((this.getZ() == null) ? (other.getZ() != null) : (! this.getZ().equals((java.lang.Object) other.getZ())))) + final java.lang.Object this$z = this.getZ(); + final java.lang.Object other$z = other.getZ(); + if (((this$z == null) ? (other$z != null) : (! this$z.equals(other$z)))) return false; return true; } @@ -36,7 +38,8 @@ int result = 1; result = ((result * PRIME) + this.getX()); result = ((result * PRIME) + this.getY()); - result = ((result * PRIME) + ((this.getZ() == null) ? 0 : this.getZ().hashCode())); + final java.lang.Object $z = this.getZ(); + result = ((result * PRIME) + (($z == null) ? 0 : $z.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { diff --git a/test/transform/resource/after-ecj/DataWithGetterNone.java b/test/transform/resource/after-ecj/DataWithGetterNone.java index a31ebece..6fa5659e 100644 --- a/test/transform/resource/after-ecj/DataWithGetterNone.java +++ b/test/transform/resource/after-ecj/DataWithGetterNone.java @@ -24,7 +24,9 @@ return false; if ((this.y != other.y)) return false; - if (((this.z == null) ? (other.z != null) : (! this.z.equals((java.lang.Object) other.z)))) + final java.lang.Object this$z = this.z; + final java.lang.Object other$z = other.z; + if (((this$z == null) ? (other$z != null) : (! this$z.equals(other$z)))) return false; return true; } @@ -36,7 +38,8 @@ int result = 1; result = ((result * PRIME) + this.x); result = ((result * PRIME) + this.y); - result = ((result * PRIME) + ((this.z == null) ? 0 : this.z.hashCode())); + final java.lang.Object $z = this.z; + result = ((result * PRIME) + (($z == null) ? 0 : $z.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { diff --git a/test/transform/resource/after-ecj/EqualsAndHashCode.java b/test/transform/resource/after-ecj/EqualsAndHashCode.java index 0417f54c..ebbc1ffe 100644 --- a/test/transform/resource/after-ecj/EqualsAndHashCode.java +++ b/test/transform/resource/after-ecj/EqualsAndHashCode.java @@ -25,7 +25,7 @@ final java.lang.Object this$b = this.b; final java.lang.Object other$b = other.b; if (((this$b == null) ? (other$b != null) : (! this$b.equals(other$b)))) - return false; + return false; return true; } public @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { diff --git a/test/transform/resource/after-ecj/GetterLazyEahcToString.java b/test/transform/resource/after-ecj/GetterLazyEahcToString.java index 15c774a2..9faab0de 100644 --- a/test/transform/resource/after-ecj/GetterLazyEahcToString.java +++ b/test/transform/resource/after-ecj/GetterLazyEahcToString.java @@ -29,9 +29,13 @@ final @java.lang.SuppressWarnings("all") GetterLazyEahcToString other = (GetterLazyEahcToString) o; if ((! other.canEqual((java.lang.Object) this))) return false; - if (((this.getValue() == null) ? (other.getValue() != null) : (! this.getValue().equals((java.lang.Object) other.getValue())))) + final java.lang.Object this$value = this.getValue(); + final java.lang.Object other$value = other.getValue(); + if (((this$value == null) ? (other$value != null) : (! this$value.equals(other$value)))) return false; - if (((this.value2 == null) ? (other.value2 != null) : (! this.value2.equals((java.lang.Object) other.value2)))) + final java.lang.Object this$value2 = this.value2; + final java.lang.Object other$value2 = other.value2; + if (((this$value2 == null) ? (other$value2 != null) : (! this$value2.equals(other$value2)))) return false; return true; } @@ -41,8 +45,10 @@ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { final int PRIME = 31; int result = 1; - result = ((result * PRIME) + ((this.getValue() == null) ? 0 : this.getValue().hashCode())); - result = ((result * PRIME) + ((this.value2 == null) ? 0 : this.value2.hashCode())); + final java.lang.Object $value = this.getValue(); + result = ((result * PRIME) + (($value == null) ? 0 : $value.hashCode())); + final java.lang.Object $value2 = this.value2; + result = ((result * PRIME) + (($value2 == null) ? 0 : $value2.hashCode())); return result; } public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { |