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:05:21 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 786f0f229 -> 8e7596d92


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/8e7596d9
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8e7596d9
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8e7596d9

Branch: refs/heads/GROOVY_2_5_X
Commit: 8e7596d92df595234d0b74944f85a39002e4032c
Parents: 786f0f2
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:03:48 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/groovy/blob/8e7596d9/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 9e96535..d3b70f1 100644
--- a/src/main/org/codehaus/groovy/ast/ClassNode.java
+++ b/src/main/org/codehaus/groovy/ast/ClassNode.java
@@ -20,7 +20,10 @@ package org.codehaus.groovy.ast;
 
 import org.apache.groovy.ast.tools.ClassNodeUtils;
 import org.codehaus.groovy.GroovyBugError;
-import org.codehaus.groovy.ast.expr.*;
+import org.codehaus.groovy.ast.expr.BinaryExpression;
+import org.codehaus.groovy.ast.expr.Expression;
+import org.codehaus.groovy.ast.expr.FieldExpression;
+import org.codehaus.groovy.ast.expr.TupleExpression;
 import org.codehaus.groovy.ast.stmt.BlockStatement;
 import org.codehaus.groovy.ast.stmt.ExpressionStatement;
 import org.codehaus.groovy.ast.stmt.Statement;
@@ -35,8 +38,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;
@@ -115,7 +118,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);
@@ -533,7 +536,7 @@ public class ClassNode extends AnnotatedNode implements Opcodes {
         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);
@@ -1436,7 +1439,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));
     }
@@ -1444,7 +1447,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);
@@ -1465,7 +1468,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