diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/MixinExtension.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/MixinExtension.java index 148dde2c..8801d785 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/MixinExtension.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/MixinExtension.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -18,12 +18,12 @@ package net.fabricmc.tinyremapper.extension.mixin; -import java.util.ArrayList; +import java.util.Collection; import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.Consumer; import org.objectweb.asm.ClassVisitor; @@ -43,7 +43,7 @@ */ public class MixinExtension implements TinyRemapper.Extension { private final Logger logger; - private final Map>> tasks; + private final Map>> tasks; private final Set targets; public enum AnnotationTarget { @@ -76,7 +76,7 @@ public MixinExtension(Set targets) { public MixinExtension(Set targets, Logger.Level logLevel) { this.logger = new Logger(logLevel); - this.tasks = new HashMap<>(); + this.tasks = new ConcurrentHashMap<>(); this.targets = targets; } @@ -95,8 +95,7 @@ public void attach(Builder builder) { * Hard-target: Shadow, Overwrite, Accessor, Invoker, Implements. */ private ClassVisitor analyzeVisitor(int mrjVersion, String className, ClassVisitor next) { - tasks.putIfAbsent(mrjVersion, new ArrayList<>()); - return new HardTargetMixinClassVisitor(tasks.get(mrjVersion), next); + return new HardTargetMixinClassVisitor(tasks.computeIfAbsent(mrjVersion, k -> new ConcurrentLinkedQueue<>()), next); } private void stateProcessor(TrEnvironment environment) { diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinClassVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinClassVisitor.java index ec6fcf6d..32eecb27 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinClassVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinClassVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -19,6 +19,7 @@ package net.fabricmc.tinyremapper.extension.mixin.hard; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -41,7 +42,7 @@ import net.fabricmc.tinyremapper.extension.mixin.hard.data.SoftInterface; public class HardTargetMixinClassVisitor extends ClassVisitor { - private final List> tasks; + private final Collection> tasks; private MxClass _class; // @Mixin @@ -51,7 +52,7 @@ public class HardTargetMixinClassVisitor extends ClassVisitor { // @Implements private final List interfaces = new ArrayList<>(); - public HardTargetMixinClassVisitor(List> tasks, ClassVisitor delegate) { + public HardTargetMixinClassVisitor(Collection> tasks, ClassVisitor delegate) { super(Constant.ASM_VERSION, delegate); this.tasks = Objects.requireNonNull(tasks); } diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinFieldVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinFieldVisitor.java index 7dc266f2..296df0d8 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinFieldVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinFieldVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -18,6 +18,7 @@ package net.fabricmc.tinyremapper.extension.mixin.hard; +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.function.Consumer; @@ -32,13 +33,13 @@ import net.fabricmc.tinyremapper.extension.mixin.hard.annotation.ShadowAnnotationVisitor; class HardTargetMixinFieldVisitor extends FieldVisitor { - private final List> tasks; + private final Collection> tasks; private final MxMember field; private final boolean remap; private final List targets; - HardTargetMixinFieldVisitor(List> tasks, FieldVisitor delegate, MxMember field, + HardTargetMixinFieldVisitor(Collection> tasks, FieldVisitor delegate, MxMember field, boolean remap, List targets) { super(Constant.ASM_VERSION, delegate); this.tasks = Objects.requireNonNull(tasks); diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinMethodVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinMethodVisitor.java index aabba17e..9ed05551 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinMethodVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/HardTargetMixinMethodVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -18,6 +18,7 @@ package net.fabricmc.tinyremapper.extension.mixin.hard; +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.function.Consumer; @@ -35,13 +36,13 @@ import net.fabricmc.tinyremapper.extension.mixin.hard.annotation.ShadowAnnotationVisitor; class HardTargetMixinMethodVisitor extends MethodVisitor { - private final List> data; + private final Collection> data; private final MxMember method; private final boolean remap; private final List targets; - HardTargetMixinMethodVisitor(List> data, MethodVisitor delegate, MxMember method, boolean remap, List targets) { + HardTargetMixinMethodVisitor(Collection> data, MethodVisitor delegate, MxMember method, boolean remap, List targets) { super(Constant.ASM_VERSION, delegate); this.data = Objects.requireNonNull(data); this.method = Objects.requireNonNull(method); diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/AccessorAnnotationVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/AccessorAnnotationVisitor.java index 6b38b2dc..eafeb2ca 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/AccessorAnnotationVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/AccessorAnnotationVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -42,14 +42,14 @@ * do not lower the first character of the remaining part. */ public class AccessorAnnotationVisitor extends AnnotationVisitor { - private final List> tasks; + private final Collection> tasks; private final MxMember method; private final List targets; private boolean remap; private boolean isSoftTarget; - public AccessorAnnotationVisitor(List> tasks, AnnotationVisitor delegate, MxMember method, boolean remap, List targets) { + public AccessorAnnotationVisitor(Collection> tasks, AnnotationVisitor delegate, MxMember method, boolean remap, List targets) { super(Constant.ASM_VERSION, delegate); this.tasks = Objects.requireNonNull(tasks); diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ImplementsAnnotationVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ImplementsAnnotationVisitor.java index 7b385d3c..a76492e0 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ImplementsAnnotationVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ImplementsAnnotationVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -81,7 +81,7 @@ public AnnotationVisitor visitAnnotation(String name, String descriptor) { } } - public static void visitMethod(List> tasks, MxMember method, List interfaces) { + public static void visitMethod(Collection> tasks, MxMember method, List interfaces) { tasks.add(data -> new SoftImplementsMappable(data, method, interfaces).result()); } diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/InvokerAnnotationVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/InvokerAnnotationVisitor.java index 9357ec37..5841f564 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/InvokerAnnotationVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/InvokerAnnotationVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -40,14 +40,14 @@ * do not lower the first character of the remaining part. */ public class InvokerAnnotationVisitor extends AnnotationVisitor { - private final List> tasks; + private final Collection> tasks; private final MxMember method; private final List targets; private boolean remap; private boolean isSoftTarget; - public InvokerAnnotationVisitor(List> tasks, AnnotationVisitor delegate, MxMember method, boolean remap, List targets) { + public InvokerAnnotationVisitor(Collection> tasks, AnnotationVisitor delegate, MxMember method, boolean remap, List targets) { super(Constant.ASM_VERSION, delegate); this.tasks = Objects.requireNonNull(tasks); diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/OverwriteAnnotationVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/OverwriteAnnotationVisitor.java index 6b1c5e76..17916c9c 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/OverwriteAnnotationVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/OverwriteAnnotationVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -38,13 +38,13 @@ * an error message will show up and the behaviour is undefined. */ public class OverwriteAnnotationVisitor extends AnnotationVisitor { - private final List> tasks; + private final Collection> tasks; private final MxMember method; private final List targets; private boolean remap; - public OverwriteAnnotationVisitor(List> tasks, AnnotationVisitor delegate, MxMember method, boolean remap, List targets) { + public OverwriteAnnotationVisitor(Collection> tasks, AnnotationVisitor delegate, MxMember method, boolean remap, List targets) { super(Constant.ASM_VERSION, delegate); this.tasks = Objects.requireNonNull(tasks); diff --git a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ShadowAnnotationVisitor.java b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ShadowAnnotationVisitor.java index ad8f7c3f..53c18154 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ShadowAnnotationVisitor.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/hard/annotation/ShadowAnnotationVisitor.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, 2018, Player, asie - * Copyright (c) 2021, FabricMC + * Copyright (c) 2021, 2023, FabricMC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -40,14 +40,14 @@ * If a prefix is detected, will only attempt to match the prefix-stripped name. */ public class ShadowAnnotationVisitor extends AnnotationVisitor { - private final List> tasks; + private final Collection> tasks; private final MxMember member; private final List targets; private boolean remap; private String prefix; - public ShadowAnnotationVisitor(List> tasks, AnnotationVisitor delegate, MxMember member, boolean remap, List targets) { + public ShadowAnnotationVisitor(Collection> tasks, AnnotationVisitor delegate, MxMember member, boolean remap, List targets) { super(Constant.ASM_VERSION, delegate); this.tasks = Objects.requireNonNull(tasks); this.member = Objects.requireNonNull(member);