From 433bcba33953095adf6a11f39408e66432be6243 Mon Sep 17 00:00:00 2001 From: Yeregorix Date: Wed, 11 Oct 2023 22:51:54 +0200 Subject: [PATCH 1/2] Fix random mixin members not getting remapped due to concurrency issues --- .../extension/mixin/MixinExtension.java | 13 ++++++------- .../mixin/hard/HardTargetMixinClassVisitor.java | 5 +++-- .../mixin/hard/HardTargetMixinFieldVisitor.java | 5 +++-- .../mixin/hard/HardTargetMixinMethodVisitor.java | 5 +++-- .../hard/annotation/AccessorAnnotationVisitor.java | 4 ++-- .../annotation/ImplementsAnnotationVisitor.java | 2 +- .../hard/annotation/InvokerAnnotationVisitor.java | 4 ++-- .../hard/annotation/OverwriteAnnotationVisitor.java | 4 ++-- .../hard/annotation/ShadowAnnotationVisitor.java | 4 ++-- 9 files changed, 24 insertions(+), 22 deletions(-) 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..1b6e4f67 100644 --- a/src/main/java/net/fabricmc/tinyremapper/extension/mixin/MixinExtension.java +++ b/src/main/java/net/fabricmc/tinyremapper/extension/mixin/MixinExtension.java @@ -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..2b63adf5 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 @@ -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..a1e0f1fd 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 @@ -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..8ddafdd8 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 @@ -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..5ceaee29 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 @@ -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..1321ad00 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 @@ -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..10502b88 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 @@ -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..6126a881 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 @@ -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..10124a86 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 @@ -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); From 35dcb710c17bc7093069505c7d066d162734e2d6 Mon Sep 17 00:00:00 2001 From: Yeregorix Date: Thu, 12 Oct 2023 21:06:06 +0200 Subject: [PATCH 2/2] spotlessApply --- .../fabricmc/tinyremapper/extension/mixin/MixinExtension.java | 2 +- .../extension/mixin/hard/HardTargetMixinClassVisitor.java | 2 +- .../extension/mixin/hard/HardTargetMixinFieldVisitor.java | 2 +- .../extension/mixin/hard/HardTargetMixinMethodVisitor.java | 2 +- .../mixin/hard/annotation/AccessorAnnotationVisitor.java | 2 +- .../mixin/hard/annotation/ImplementsAnnotationVisitor.java | 2 +- .../mixin/hard/annotation/InvokerAnnotationVisitor.java | 2 +- .../mixin/hard/annotation/OverwriteAnnotationVisitor.java | 2 +- .../mixin/hard/annotation/ShadowAnnotationVisitor.java | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) 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 1b6e4f67..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 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 2b63adf5..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 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 a1e0f1fd..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 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 8ddafdd8..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 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 5ceaee29..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 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 1321ad00..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 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 10502b88..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 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 6126a881..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 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 10124a86..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