diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java index cdd821f07..8343ecbc6 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/GregorMutater.java @@ -19,14 +19,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; +import java.util.stream.Collectors; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; @@ -46,13 +46,13 @@ public class GregorMutater implements Mutater { private final Map computeCache = new HashMap<>(); private final Predicate filter; private final ClassByteArraySource byteSource; - private final Set mutators = new HashSet<>(); + private final List mutators; public GregorMutater(final ClassByteArraySource byteSource, final Predicate filter, final Collection mutators) { this.filter = filter; - this.mutators.addAll(mutators); + this.mutators = orderAndDeDuplicate(mutators); this.byteSource = byteSource; } @@ -134,4 +134,13 @@ private static Predicate isGeneratedEnumMethod() { return MethodInfo::isGeneratedEnumMethod; } + private List orderAndDeDuplicate(Collection mutators) { + // deduplication is based on object identity, so dubious that this adds any value + // however left in place for now to replicate HashSet behaviour + return mutators.stream() + .distinct() + .sorted(Comparator.comparing(MethodMutatorFactory::getGloballyUniqueId)) + .collect(Collectors.toList()); + } + } diff --git a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java index a84a6ea65..7b5cc8233 100644 --- a/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java +++ b/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/MutatingClassVisitor.java @@ -14,9 +14,7 @@ */ package org.pitest.mutationtest.engine.gregor; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.List; import java.util.function.Predicate; import org.objectweb.asm.ClassVisitor; @@ -32,15 +30,15 @@ class MutatingClassVisitor extends ClassVisitor { private final Predicate filter; private final ClassContext context; - private final Set methodMutators = new HashSet<>(); + private final List methodMutators; MutatingClassVisitor(final ClassVisitor delegateClassVisitor, final ClassContext context, final Predicate filter, - final Collection mutators) { + final List mutators) { super(ASMVersion.ASM_VERSION, delegateClassVisitor); this.context = context; this.filter = filter; - this.methodMutators.addAll(mutators); + this.methodMutators = mutators; } @Override