--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilerConfigurationFactory.java 2017-09-12 22:24:33.536127353 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilerConfigurationFactory.java 2017-09-12 22:24:33.402121315 -0700 @@ -29,7 +29,6 @@ import java.util.List; import java.util.stream.Collectors; -import org.graalvm.compiler.debug.Assertions; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.options.Option; import org.graalvm.compiler.options.OptionKey; @@ -73,7 +72,6 @@ protected CompilerConfigurationFactory(String name, int autoSelectionPriority) { this.name = name; this.autoSelectionPriority = autoSelectionPriority; - assert checkAndAddNewFactory(this); } public abstract CompilerConfiguration createCompilerConfiguration(); @@ -127,18 +125,18 @@ } /** - * List used to assert uniqueness of {@link #name} and {@link #autoSelectionPriority} across all - * {@link CompilerConfigurationFactory} instances. + * Asserts uniqueness of {@link #name} and {@link #autoSelectionPriority} for {@code factory} in + * {@code factories}. */ - private static final List factories = Assertions.assertionsEnabled() ? new ArrayList<>() : null; - - private static boolean checkAndAddNewFactory(CompilerConfigurationFactory factory) { + private static boolean checkUnique(CompilerConfigurationFactory factory, List factories) { for (CompilerConfigurationFactory other : factories) { - assert !other.name.equals(factory.name) : factory.getClass().getName() + " cannot have the same selector as " + other.getClass().getName() + ": " + factory.name; - assert other.autoSelectionPriority != factory.autoSelectionPriority : factory.getClass().getName() + " cannot have the same auto-selection priority as " + other.getClass().getName() + - ": " + factory.autoSelectionPriority; + if (other != factory) { + assert !other.name.equals(factory.name) : factory.getClass().getName() + " cannot have the same selector as " + other.getClass().getName() + ": " + factory.name; + assert other.autoSelectionPriority != factory.autoSelectionPriority : factory.getClass().getName() + " cannot have the same auto-selection priority as " + + other.getClass().getName() + + ": " + factory.autoSelectionPriority; + } } - factories.add(factory); return true; } @@ -148,6 +146,7 @@ private static List getAllCandidates() { List candidates = new ArrayList<>(); for (CompilerConfigurationFactory candidate : GraalServices.load(CompilerConfigurationFactory.class)) { + assert checkUnique(candidate, candidates); candidates.add(candidate); } Collections.sort(candidates);