From f18d8f8adf8c7c0b5b64dfe7b9fa5ab26afda228 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Tue, 17 Sep 2019 13:48:44 +0100 Subject: [PATCH 1/3] Ensure CHECKCAST is added for arrays as well as objects, fixes #358 --- .../asm/mixin/injection/callback/CallbackInjector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java b/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java index 8db18ef5..16edfdd8 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/callback/CallbackInjector.java @@ -746,7 +746,7 @@ public class CallbackInjector extends Injector { String accessor = CallbackInfoReturnable.getReturnAccessor(callback.target.returnType); String descriptor = CallbackInfoReturnable.getReturnDescriptor(callback.target.returnType); callback.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, this.callbackInfoClass, accessor, descriptor, false)); - if (callback.target.returnType.getSort() == Type.OBJECT) { + if (callback.target.returnType.getSort() >= Type.ARRAY) { callback.add(new TypeInsnNode(Opcodes.CHECKCAST, callback.target.returnType.getInternalName())); } callback.add(new InsnNode(callback.target.returnType.getOpcode(Opcodes.IRETURN))); From d460bd58e61b00379b98d76c7c36e473b087eb99 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Tue, 17 Sep 2019 13:49:53 +0100 Subject: [PATCH 2/3] Don't visit a synthetic inner class with itself, fixes #359 --- .../mixin/transformer/MixinPostProcessor.java | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPostProcessor.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPostProcessor.java index 8f3632d0..4e80f822 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPostProcessor.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPostProcessor.java @@ -36,6 +36,7 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; @@ -148,33 +149,19 @@ class MixinPostProcessor implements MixinConfig.IListener { * new home in the target class */ private void processSyntheticInner(ClassNode classNode) { - ClassVisitor visibilityVisitor = new ClassVisitor(Bytecode.ASM_API_VERSION, classNode) { - - @Override - public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { - super.visit(version, access | Opcodes.ACC_PUBLIC, name, signature, superName, interfaces); - } - - - @Override - public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { - if ((access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) == 0) { - access |= Opcodes.ACC_PUBLIC; - } - return super.visitField(access, name, desc, signature, value); - } - - @Override - public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - if ((access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) == 0) { - access |= Opcodes.ACC_PUBLIC; - } - return super.visitMethod(access, name, desc, signature, exceptions); - } - - }; + classNode.access |= Opcodes.ACC_PUBLIC; - classNode.accept(visibilityVisitor); + for (FieldNode field : classNode.fields) { + if ((field.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) == 0) { + field.access |= Opcodes.ACC_PUBLIC; + } + } + + for (MethodNode method : classNode.methods) { + if ((method.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) == 0) { + method.access |= Opcodes.ACC_PUBLIC; + } + } } private boolean processAccessor(ClassNode classNode, MixinInfo mixin) { From d28607b86a3241d4314ef8cfa96880fce68da764 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Tue, 17 Sep 2019 13:50:55 +0100 Subject: [PATCH 3/3] Remove unused compilation unit --- .../asm/launch/IClassProcessNominator.java | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/modlauncher/java/org/spongepowered/asm/launch/IClassProcessNominator.java diff --git a/src/modlauncher/java/org/spongepowered/asm/launch/IClassProcessNominator.java b/src/modlauncher/java/org/spongepowered/asm/launch/IClassProcessNominator.java deleted file mode 100644 index 97a7c2d2..00000000 --- a/src/modlauncher/java/org/spongepowered/asm/launch/IClassProcessNominator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of Mixin, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -//package org.spongepowered.asm.launch; -// -//import org.objectweb.asm.Type; -// -///** -// * Callback for nominating whether the mixin pipeline needs to operate on a -// * class -// */ -//@FunctionalInterface -//public interface IClassProcessNominator { -// -// /** -// * Notify that a class has begun to travel through the transformer chain -// * -// * @param classType Class info -// * @param isEmpty True if the class needs to be synthesized -// * @return True if the class should be processed -// */ -// public abstract boolean onBeginProcessing(Type classType, boolean isEmpty); -// -//}