groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cchamp...@apache.org
Subject groovy git commit: Use `LinkedHashMap` instead of `HashMap`
Date Tue, 14 Nov 2017 09:06:15 GMT
Repository: groovy
Updated Branches:
  refs/heads/master e87ba5a29 -> 48f13d652


Use `LinkedHashMap` instead of `HashMap`

Using `HashMap` leads to non-reproducible build outputs, meaning that the same source can
produce
different bytecode (typically order of methods are different).


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

Branch: refs/heads/master
Commit: 48f13d65273b91901055a0ee093d7dbc387cdab9
Parents: e87ba5a
Author: Cedric Champeau <cchampeau@apache.org>
Authored: Tue Nov 14 10:03:48 2017 +0100
Committer: Cedric Champeau <cchampeau@apache.org>
Committed: Tue Nov 14 10:05:52 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/groovy/blob/48f13d65/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 3e677b4..d9e5d2d 100644
--- a/src/main/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/org/codehaus/groovy/ast/ClassNode.java
@@ -40,8 +40,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;
@@ -121,7 +121,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder
 
         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);
@@ -544,7 +544,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder
         if (r.fields == null)
             r.fields = new LinkedList<>();
         if (r.fieldIndex == null)
-            r.fieldIndex = new HashMap<>();
+            r.fieldIndex = new LinkedHashMap<>();
 
         if (isFirst)
             r.fields.addFirst(node);
@@ -1447,7 +1447,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder
     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));
     }
@@ -1455,7 +1455,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder
     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);
@@ -1476,7 +1476,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder
         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