You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/11/17 12:06:13 UTC
[1/6] groovy git commit: GROOVY-8380: Regression in 2.4.13 (snapshot)
with and/or/xor and @CS
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_5_X f08f259d8 -> 7011a8436
GROOVY-8380: Regression in 2.4.13 (snapshot) with and/or/xor and @CS
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/34345fe7
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/34345fe7
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/34345fe7
Branch: refs/heads/GROOVY_2_5_X
Commit: 34345fe7af0d76021617efc977edd9509e64a05f
Parents: 5f8c757
Author: paulk <pa...@asert.com.au>
Authored: Fri Nov 17 20:32:34 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Nov 17 21:56:38 2017 +1000
----------------------------------------------------------------------
.../asm/sc/StaticTypesCallSiteWriter.java | 3 ++-
.../stc/StaticTypeCheckingVisitor.java | 6 +++---
.../groovy/transform/stc/MiscSTCTest.groovy | 20 ++++++++++++++++++++
3 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/34345fe7/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
index 928e791..65c968f 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java
@@ -654,7 +654,8 @@ public class StaticTypesCallSiteWriter extends CallSiteWriter implements Opcodes
} else if ("power".equals(message)) {
writePowerCall(receiver, arguments, rType, aType);
return true;
- } else if ("mod".equals(message) || "leftShift".equals(message) || "rightShift".equals(message) || "rightShiftUnsigned".equals(message)) {
+ } else if ("mod".equals(message) || "leftShift".equals(message) || "rightShift".equals(message) || "rightShiftUnsigned".equals(message)
+ || "and".equals(message) || "or".equals(message) || "xor".equals(message)) {
writeOperatorCall(receiver, arguments, message);
return true;
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/34345fe7/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 7a983f6..511f61b 100644
--- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -3661,9 +3661,9 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
} else if (isPowerOperator(op)) {
return Number_TYPE;
} else if (isBitOperator(op)) {
- if (isIntCategory(leftRedirect) && isIntCategory(rightRedirect)) return int_TYPE;
- if (isLongCategory(leftRedirect) && isLongCategory(rightRedirect)) return long_TYPE;
- if (isBigIntCategory(leftRedirect) && isBigIntCategory(rightRedirect)) return BigInteger_TYPE;
+ if (isIntCategory(getUnwrapper(leftRedirect)) && isIntCategory(getUnwrapper(rightRedirect))) return int_TYPE;
+ if (isLongCategory(getUnwrapper(leftRedirect)) && isLongCategory(getUnwrapper(rightRedirect))) return long_TYPE;
+ if (isBigIntCategory(getUnwrapper(leftRedirect)) && isBigIntCategory(getUnwrapper(rightRedirect))) return BigInteger_TYPE;
} else if (isCompareToBoolean(op) || op == COMPARE_EQUAL || op == COMPARE_NOT_EQUAL) {
return boolean_TYPE;
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/34345fe7/src/test/groovy/transform/stc/MiscSTCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/MiscSTCTest.groovy b/src/test/groovy/transform/stc/MiscSTCTest.groovy
index fd132e3..0b786d8 100644
--- a/src/test/groovy/transform/stc/MiscSTCTest.groovy
+++ b/src/test/groovy/transform/stc/MiscSTCTest.groovy
@@ -389,4 +389,24 @@ class MiscSTCTest extends StaticTypeCheckingTestCase {
''', 'Cannot find matching method Foo#newInstance2(CustomNumber)'
}
+ // GROOVY-8380
+ void testBitOperatorsWithNumbers() {
+ assertScript '''
+ def method() {
+ Long wl = 2L
+ long pl = 3L
+ assert new Long(wl & 3L) == 2
+ assert new Long(pl & pl) == 3
+ assert new Long(6L & 3L) == 2
+ assert new Long(-2L & 3L) == 2
+ Integer wi = 2
+ int pi = 2
+ assert new Integer(wi & 34) == 2
+ assert new Integer(pi & pi) == 2
+ assert new Integer(6 & 3) == 2
+ assert new Integer(-2 & 3) == 2
+ }
+ method()
+ '''
+ }
}
[6/6] groovy git commit: Improve performance of generated hashCode()
methods for instances with null fields and properties by avoiding calling
NullObject.is() method for which no call site caching occurs.
Posted by pa...@apache.org.
Improve performance of generated hashCode() methods for instances with null fields and properties by avoiding calling NullObject.is() method for which no call site caching occurs.
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7011a843
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7011a843
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7011a843
Branch: refs/heads/GROOVY_2_5_X
Commit: 7011a84364387674bc67a4c45f6cf949cfd7fd58
Parents: 7a78809
Author: Marcin Erdmann <er...@gmail.com>
Authored: Thu Nov 16 22:47:23 2017 +0000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Nov 17 22:01:08 2017 +1000
----------------------------------------------------------------------
.../codehaus/groovy/ast/tools/GeneralUtils.java | 7 ++++
.../EqualsAndHashCodeASTTransformation.java | 40 ++++++++++----------
2 files changed, 27 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/7011a843/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java b/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
index 252d6e3..b2beb96 100644
--- a/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
+++ b/src/main/org/codehaus/groovy/ast/tools/GeneralUtils.java
@@ -72,6 +72,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import static org.codehaus.groovy.syntax.Types.COMPARE_NOT_IDENTICAL;
+
/**
* Handy methods when working with the Groovy AST
*/
@@ -79,6 +81,7 @@ public class GeneralUtils {
public static final Token ASSIGN = Token.newSymbol(Types.ASSIGN, -1, -1);
public static final Token EQ = Token.newSymbol(Types.COMPARE_EQUAL, -1, -1);
public static final Token NE = Token.newSymbol(Types.COMPARE_NOT_EQUAL, -1, -1);
+ public static final Token NOT_IDENTICAL = Token.newSymbol(COMPARE_NOT_IDENTICAL, -1, -1);
public static final Token LT = Token.newSymbol(Types.COMPARE_LESS_THAN, -1, -1);
public static final Token AND = Token.newSymbol(Types.LOGICAL_AND, -1, -1);
public static final Token OR = Token.newSymbol(Types.LOGICAL_OR, -1, -1);
@@ -565,6 +568,10 @@ public class GeneralUtils {
return new BinaryExpression(lhv, LT, rhv);
}
+ public static BinaryExpression notIdenticalX(Expression lhv, Expression rhv) {
+ return new BinaryExpression(lhv, NOT_IDENTICAL, rhv);
+ }
+
/**
* @deprecated use MethodNodeUtils#methodDescriptorWithoutReturnType(MethodNode) instead
*/
http://git-wip-us.apache.org/repos/asf/groovy/blob/7011a843/src/main/org/codehaus/groovy/transform/EqualsAndHashCodeASTTransformation.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/transform/EqualsAndHashCodeASTTransformation.java b/src/main/org/codehaus/groovy/transform/EqualsAndHashCodeASTTransformation.java
index 1c95a56..e8dbd53 100644
--- a/src/main/org/codehaus/groovy/transform/EqualsAndHashCodeASTTransformation.java
+++ b/src/main/org/codehaus/groovy/transform/EqualsAndHashCodeASTTransformation.java
@@ -73,20 +73,20 @@ public class EqualsAndHashCodeASTTransformation extends AbstractASTTransformatio
boolean includeFields = memberHasValue(anno, "includeFields", true);
List<String> excludes = getMemberStringList(anno, "excludes");
List<String> includes = getMemberStringList(anno, "includes");
- final boolean allNames = memberHasValue(anno, "allNames", true);
+ final boolean allNames = memberHasValue(anno, "allNames", true);
if (!checkIncludeExcludeUndefinedAware(anno, excludes, includes, MY_TYPE_NAME)) return;
if (!checkPropertyList(cNode, includes, "includes", anno, MY_TYPE_NAME, includeFields)) return;
if (!checkPropertyList(cNode, excludes, "excludes", anno, MY_TYPE_NAME, includeFields)) return;
- createHashCode(cNode, cacheHashCode, includeFields, callSuper, excludes, includes, allNames);
- createEquals(cNode, includeFields, callSuper, useCanEqual, excludes, includes, allNames);
+ createHashCode(cNode, cacheHashCode, includeFields, callSuper, excludes, includes, allNames);
+ createEquals(cNode, includeFields, callSuper, useCanEqual, excludes, includes, allNames);
}
}
public static void createHashCode(ClassNode cNode, boolean cacheResult, boolean includeFields, boolean callSuper, List<String> excludes, List<String> includes) {
- createHashCode(cNode, cacheResult, includeFields, callSuper, excludes, includes, false);
- }
-
- public static void createHashCode(ClassNode cNode, boolean cacheResult, boolean includeFields, boolean callSuper, List<String> excludes, List<String> includes, boolean allNames) {
+ createHashCode(cNode, cacheResult, includeFields, callSuper, excludes, includes, false);
+ }
+
+ public static void createHashCode(ClassNode cNode, boolean cacheResult, boolean includeFields, boolean callSuper, List<String> excludes, List<String> includes, boolean allNames) {
// make a public method if none exists otherwise try a private method with leading underscore
boolean hasExistingHashCode = hasDeclaredMethod(cNode, "hashCode", 0);
if (hasExistingHashCode && hasDeclaredMethod(cNode, "_hashCode", 0)) return;
@@ -98,11 +98,11 @@ public class EqualsAndHashCodeASTTransformation extends AbstractASTTransformatio
final Expression hash = varX(hashField);
body.addStatement(ifS(
isZeroX(hash),
- calculateHashStatements(cNode, hash, includeFields, callSuper, excludes, includes, allNames)
+ calculateHashStatements(cNode, hash, includeFields, callSuper, excludes, includes, allNames)
));
body.addStatement(returnS(hash));
} else {
- body.addStatement(calculateHashStatements(cNode, null, includeFields, callSuper, excludes, includes, allNames));
+ body.addStatement(calculateHashStatements(cNode, null, includeFields, callSuper, excludes, includes, allNames));
}
cNode.addMethod(new MethodNode(
@@ -114,7 +114,7 @@ public class EqualsAndHashCodeASTTransformation extends AbstractASTTransformatio
body));
}
- private static Statement calculateHashStatements(ClassNode cNode, Expression hash, boolean includeFields, boolean callSuper, List<String> excludes, List<String> includes, boolean allNames) {
+ private static Statement calculateHashStatements(ClassNode cNode, Expression hash, boolean includeFields, boolean callSuper, List<String> excludes, List<String> includes, boolean allNames) {
final List<PropertyNode> pList = getInstanceProperties(cNode);
final List<FieldNode> fList = new ArrayList<FieldNode>();
if (includeFields) {
@@ -126,22 +126,22 @@ public class EqualsAndHashCodeASTTransformation extends AbstractASTTransformatio
body.addStatement(declS(result, callX(HASHUTIL_TYPE, "initHash")));
for (PropertyNode pNode : pList) {
- if (shouldSkip(pNode.getName(), excludes, includes, allNames)) continue;
+ if (shouldSkip(pNode.getName(), excludes, includes, allNames)) continue;
// _result = HashCodeHelper.updateHash(_result, getProperty()) // plus self-reference checking
Expression getter = getterThisX(cNode, pNode);
final Expression current = callX(HASHUTIL_TYPE, "updateHash", args(result, getter));
body.addStatement(ifS(
- notX(sameX(getter, varX("this"))),
+ notIdenticalX(getter, varX("this")),
assignS(result, current)));
}
for (FieldNode fNode : fList) {
- if (shouldSkip(fNode.getName(), excludes, includes, allNames)) continue;
+ if (shouldSkip(fNode.getName(), excludes, includes, allNames)) continue;
// _result = HashCodeHelper.updateHash(_result, field) // plus self-reference checking
final Expression fieldExpr = varX(fNode);
final Expression current = callX(HASHUTIL_TYPE, "updateHash", args(result, fieldExpr));
body.addStatement(ifS(
- notX(sameX(fieldExpr, varX("this"))),
+ notIdenticalX(fieldExpr, varX("this")),
assignS(result, current)));
}
if (callSuper) {
@@ -176,10 +176,10 @@ public class EqualsAndHashCodeASTTransformation extends AbstractASTTransformatio
}
public static void createEquals(ClassNode cNode, boolean includeFields, boolean callSuper, boolean useCanEqual, List<String> excludes, List<String> includes) {
- createEquals(cNode, includeFields, callSuper, useCanEqual, excludes, includes, false);
- }
-
- public static void createEquals(ClassNode cNode, boolean includeFields, boolean callSuper, boolean useCanEqual, List<String> excludes, List<String> includes, boolean allNames) {
+ createEquals(cNode, includeFields, callSuper, useCanEqual, excludes, includes, false);
+ }
+
+ public static void createEquals(ClassNode cNode, boolean includeFields, boolean callSuper, boolean useCanEqual, List<String> excludes, List<String> includes, boolean allNames) {
if (useCanEqual) createCanEqual(cNode);
// make a public method if none exists otherwise try a private method with leading underscore
boolean hasExistingEquals = hasDeclaredMethod(cNode, "equals", 1);
@@ -209,7 +209,7 @@ public class EqualsAndHashCodeASTTransformation extends AbstractASTTransformatio
List<PropertyNode> pList = getInstanceProperties(cNode);
for (PropertyNode pNode : pList) {
- if (shouldSkip(pNode.getName(), excludes, includes, allNames)) continue;
+ if (shouldSkip(pNode.getName(), excludes, includes, allNames)) continue;
boolean canBeSelf = StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(
pNode.getOriginType(), cNode
);
@@ -232,7 +232,7 @@ public class EqualsAndHashCodeASTTransformation extends AbstractASTTransformatio
fList.addAll(getInstanceNonPropertyFields(cNode));
}
for (FieldNode fNode : fList) {
- if (shouldSkip(fNode.getName(), excludes, includes, allNames)) continue;
+ if (shouldSkip(fNode.getName(), excludes, includes, allNames)) continue;
body.addStatement(
ifS(notX(hasSameFieldX(fNode, otherTyped)),
ifElseS(differentSelfRecursiveFieldX(fNode, otherTyped),
[2/6] groovy git commit: trivial refactor (remove unused import)
Posted by pa...@apache.org.
trivial refactor (remove unused import)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5f8c757c
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5f8c757c
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5f8c757c
Branch: refs/heads/GROOVY_2_5_X
Commit: 5f8c757cb77ff245bf5b84829b1904bd2dfe9cc0
Parents: f08f259
Author: paulk <pa...@asert.com.au>
Authored: Fri Nov 17 09:17:17 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Nov 17 21:56:38 2017 +1000
----------------------------------------------------------------------
.../org/codehaus/groovy/macro/matcher/MatchingConstraints.groovy | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/5f8c757c/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/MatchingConstraints.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/MatchingConstraints.groovy b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/MatchingConstraints.groovy
index c3bfdbd..7bb0b78 100644
--- a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/MatchingConstraints.groovy
+++ b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/matcher/MatchingConstraints.groovy
@@ -20,7 +20,6 @@ package org.codehaus.groovy.macro.matcher
import groovy.transform.CompileStatic
import groovy.transform.Immutable
-import org.codehaus.groovy.ast.ASTNode
import org.codehaus.groovy.macro.matcher.internal.AnyTokenMatch
import org.codehaus.groovy.macro.matcher.internal.ConstraintPredicate
import org.codehaus.groovy.syntax.Token
@@ -28,7 +27,6 @@ import org.codehaus.groovy.syntax.Token
/**
* Represents constraints in AST pattern matching.
*
- * @author Cedric Champeau
* @since 2.5.0
*/
@CompileStatic
@@ -39,5 +37,4 @@ class MatchingConstraints {
final Set<String> placeholders
final ConstraintPredicate<Token> tokenPredicate
final ConstraintPredicate<TreeContext> eventually
-
}
[5/6] groovy git commit: Add a test to verify that changes to
generating hashCode() for instances with null fields and properties and
EqualsAndHashCodeASTTransformation have no impact on the value returned
Posted by pa...@apache.org.
Add a test to verify that changes to generating hashCode() for instances with null fields and properties and EqualsAndHashCodeASTTransformation have no impact on the value returned
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7a78809d
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7a78809d
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7a78809d
Branch: refs/heads/GROOVY_2_5_X
Commit: 7a78809da1ddf7371af18d1506eae2bdce1c7287
Parents: f30dc32
Author: Marcin Erdmann <er...@gmail.com>
Authored: Sun Nov 12 10:26:39 2017 +0000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Nov 17 22:01:08 2017 +1000
----------------------------------------------------------------------
.../transform/CanonicalComponentsTransformTest.groovy | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/7a78809d/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy b/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
index 6450f8e..6457315 100644
--- a/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
@@ -761,6 +761,18 @@ class CanonicalComponentsTransformTest extends GroovyShellTestCase {
assert d1 == d2
"""
}
+
+ void testHashCodeForInstanceWithNullPropertyAndField() {
+ new GroovyShell().evaluate """
+ import groovy.transform.*
+ @EqualsAndHashCode(includeFields = true)
+ class FieldAndPropertyIncludedInHashCode {
+ private String field
+ String property
+ }
+ assert new FieldAndPropertyIncludedInHashCode().hashCode() == 442087
+ """
+ }
}
@TupleConstructor
[4/6] groovy git commit: Add a benchmark for hashCode() generated
using @EqualsAndHashCode when instance on which hashCode() is called has null
fields and properties
Posted by pa...@apache.org.
Add a benchmark for hashCode() generated using @EqualsAndHashCode when instance on which hashCode() is called has null fields and properties
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/f30dc325
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f30dc325
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f30dc325
Branch: refs/heads/GROOVY_2_5_X
Commit: f30dc32560141c2c9b0f97fe25ac76321e7a3395
Parents: 1588a1f
Author: Marcin Erdmann <er...@gmail.com>
Authored: Sun Nov 12 10:25:03 2017 +0000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Nov 17 22:01:07 2017 +1000
----------------------------------------------------------------------
.../groovy/bench/GeneratedHashCodeBench.java | 43 ++++++++++++++++++++
.../groovy/bench/GeneratedHashCode.groovy | 30 ++++++++++++++
2 files changed, 73 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/f30dc325/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java
----------------------------------------------------------------------
diff --git a/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java b/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java
new file mode 100644
index 0000000..0ba4909
--- /dev/null
+++ b/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.groovy.bench;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Warmup;
+
+import java.util.concurrent.TimeUnit;
+
+@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
+@Fork(3)
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+public class GeneratedHashCodeBench {
+
+ @Benchmark
+ public int generated_hashcode_on_instance_with_null_properties() {
+ return new GeneratedHashCode().hashCode();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/f30dc325/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy
----------------------------------------------------------------------
diff --git a/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy b/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy
new file mode 100644
index 0000000..e67cd50
--- /dev/null
+++ b/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.groovy.bench
+
+import groovy.transform.EqualsAndHashCode
+
+@EqualsAndHashCode(includeFields = true)
+class GeneratedHashCode {
+
+ private String field
+ String property
+
+}
[3/6] groovy git commit: Fix Groovy dependency in performance tests
to be the same as the one used by Gradle so that jmh benchmarks using Groovy
don't fail
Posted by pa...@apache.org.
Fix Groovy dependency in performance tests to be the same as the one used by Gradle so that jmh benchmarks using Groovy don't fail
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1588a1fe
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1588a1fe
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1588a1fe
Branch: refs/heads/GROOVY_2_5_X
Commit: 1588a1fe5aa7035cb49b627c1bb3ad46023a1b6e
Parents: 34345fe
Author: Marcin Erdmann <er...@gmail.com>
Authored: Sun Nov 12 10:23:26 2017 +0000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Nov 17 22:01:04 2017 +1000
----------------------------------------------------------------------
subprojects/performance/build.gradle | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/1588a1fe/subprojects/performance/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/performance/build.gradle b/subprojects/performance/build.gradle
index 01c5688..118ddb0 100644
--- a/subprojects/performance/build.gradle
+++ b/subprojects/performance/build.gradle
@@ -25,7 +25,7 @@ configurations {
}
dependencies {
- testCompile 'org.codehaus.groovy:groovy-all:2.4.4'
+ testCompile 'org.codehaus.groovy:groovy-all:2.4.12'
stats 'org.apache.commons:commons-math3:3.6'
}
@@ -60,7 +60,7 @@ task performanceTests {
}
}
-['1.8.9', '2.0.8', '2.1.9', '2.2.2', '2.3.10', '2.3.11', '2.4.4', 'current'].each { version ->
+['1.8.9', '2.0.8', '2.1.9', '2.2.2', '2.3.10', '2.3.11', '2.4.12', 'current'].each { version ->
def t = task "performanceTestGroovy${version.replace('.', '_')}"(type: JavaExec) {
dependsOn compileTestJava
def groovyConf = configurations.detachedConfiguration(