groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cchamp...@apache.org
Subject groovy git commit: Fix reproducibility of builds
Date Tue, 14 Nov 2017 09:01:54 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X fc9ac3fd9 -> 626152491


Fix reproducibility of builds

Calling `getAllDeclaredMethods` introduced non-determinism, by not always returning the list
of methods
in the same order. This causes caching issues in Gradle build cache, since the same sources
do not always
produce the same output. This was caused by the use of `HashMap` instead of `LinkedHashMap`.


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/62615249
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/62615249
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/62615249

Branch: refs/heads/GROOVY_2_4_X
Commit: 62615249161b233b1827d5950671d3a83007cd9f
Parents: fc9ac3f
Author: Cedric Champeau <cchampeau@apache.org>
Authored: Tue Nov 14 09:59:51 2017 +0100
Committer: Cedric Champeau <cchampeau@apache.org>
Committed: Tue Nov 14 09:59:51 2017 +0100

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/ast/ClassNode.java | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/62615249/src/main/org/codehaus/groovy/ast/ClassNode.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/ClassNode.java b/src/main/org/codehaus/groovy/ast/ClassNode.java
index 8891324..5acb9e6 100644
--- a/src/main/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/org/codehaus/groovy/ast/ClassNode.java
@@ -39,8 +39,8 @@ import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumMap;
-import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -119,7 +119,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
 
         public void put(Object key, MethodNode value) {
             if (map == null) {
-                 map = new HashMap<Object, List<MethodNode>>();
+                 map = new LinkedHashMap<Object, List<MethodNode>>();
             }
             if (map.containsKey(key)) {
                 get(key).add(value);
@@ -448,7 +448,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
         if (parent != null) {
             result = parent.getDeclaredMethodsMap();
         } else {
-            result = new HashMap<String, MethodNode>();
+            result = new LinkedHashMap<String, MethodNode>();
         }
         ClassNodeUtils.addInterfaceMethods(this, result);
 
@@ -535,7 +535,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
         if (r.fields == null)
             r.fields = new LinkedList<FieldNode> ();
         if (r.fieldIndex == null)
-            r.fieldIndex = new HashMap<String,FieldNode> ();
+            r.fieldIndex = new LinkedHashMap<String,FieldNode> ();
         r.fields.add(node);
         r.fieldIndex.put(node.getName(), node);
     }
@@ -547,7 +547,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
         if (r.fields == null)
             r.fields = new LinkedList<FieldNode> ();
         if (r.fieldIndex == null)
-            r.fieldIndex = new HashMap<String,FieldNode> ();
+            r.fieldIndex = new LinkedHashMap<String,FieldNode> ();
         r.fields.addFirst(node);
         r.fieldIndex.put(node.getName(), node);
     }
@@ -747,7 +747,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
         if (!redirect().lazyInitDone) redirect().lazyClassInit();
         ClassNode r = redirect ();
         if (r.fieldIndex == null)
-            r.fieldIndex = new HashMap<String,FieldNode> ();
+            r.fieldIndex = new LinkedHashMap<String,FieldNode> ();
         return r.fieldIndex.get(name);
     }
 
@@ -1461,7 +1461,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
     public void renameField(String oldName, String newName) {
         ClassNode r = redirect ();
         if (r.fieldIndex == null)
-            r.fieldIndex = new HashMap<String,FieldNode> ();
+            r.fieldIndex = new LinkedHashMap<String,FieldNode> ();
         final Map<String,FieldNode> index = r.fieldIndex;
         index.put(newName, index.remove(oldName));
     }
@@ -1469,7 +1469,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
     public void removeField(String oldName) {
         ClassNode r = redirect ();
         if (r.fieldIndex == null)
-            r.fieldIndex = new HashMap<String,FieldNode> ();
+            r.fieldIndex = new LinkedHashMap<String,FieldNode> ();
         final Map<String,FieldNode> index = r.fieldIndex;
         r.fields.remove(index.get(oldName));
         index.remove(oldName);
@@ -1490,7 +1490,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
         if(transformInstances == null){
             transformInstances = new EnumMap<CompilePhase, Map<Class <? extends
ASTTransformation>, Set<ASTNode>>>(CompilePhase.class);
             for (CompilePhase phase : CompilePhase.values()) {
-                transformInstances.put(phase, new HashMap<Class <? extends ASTTransformation>,
Set<ASTNode>>());
+                transformInstances.put(phase, new LinkedHashMap<Class <? extends ASTTransformation>,
Set<ASTNode>>());
             }
         }
         return transformInstances;


Mime
View raw message