diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinCoprocessor.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinCoprocessor.java index 38354043..e044d2e0 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinCoprocessor.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinCoprocessor.java @@ -35,11 +35,10 @@ import org.spongepowered.asm.service.MixinService; * mixins. * *

Such tasks as {@link MixinCoprocessorAccessor making accessor mixins - * loadable (and transforming the accessors therein)}, {@link - * MixinCoprocessorSyntheticInner exposing synthetic inner classes to all - * consumers} and {@link MixinCoprocessorNestHost applying nest member - * attributes to nest hosts which may themselves not be mixin targets} are - * handled by different coprocessors.

+ * loadable (and transforming the accessors therein)}, and {@link + * MixinCoprocessorNestHost applying nest member attributes to nest hosts + * which may themselves not be mixin targets} are handled by different + * coprocessors.

* *

These classes were previously encapsulated in a single companion class * called MixinPostProcessor, but the mixture of responsibilities of diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinCoprocessorSyntheticInner.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinCoprocessorSyntheticInner.java deleted file mode 100644 index ee1f3030..00000000 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinCoprocessorSyntheticInner.java +++ /dev/null @@ -1,104 +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.mixin.transformer; - -import java.util.HashSet; -import java.util.Set; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.MethodNode; - -/** - * Coprocessor which handles synthetic inner classes in mixins. Since synthetic - * inner classes are usually just switch tables, it is reasonably safe to share - * them amongst all mixin targets. Therefore the class is simply transformed so - * that all members are public. - * - *

Nest based-access control could potentially be used where a mixin has a - * single target, and Java 11 or higher is in use, but at the moment it's more - * straightforward to just make everything public.

- */ -class MixinCoprocessorSyntheticInner extends MixinCoprocessor { - - /** - * Synthetic inner classes in mixins - */ - private final Set syntheticInnerClasses = new HashSet(); - - MixinCoprocessorSyntheticInner() { - } - - @Override - String getName() { - return "syntheticinner"; - } - - @Override - public void onInit(MixinInfo mixin) { - for (String innerClass : mixin.getSyntheticInnerClasses()) { - this.registerSyntheticInner(innerClass.replace('/', '.')); - } - } - - void registerSyntheticInner(String className) { - this.syntheticInnerClasses.add(className); - } - - @Override - public boolean couldTransform(String className) { - return this.syntheticInnerClasses.contains(className); - } - - /** - * "Pass through" a synthetic inner class. Transforms package-private - * members in the class into public so that they are accessible from their - * new home in the target class - */ - @Override - ProcessResult process(String className, ClassNode classNode) { - if (!this.syntheticInnerClasses.contains(className)) { - return ProcessResult.NONE; - } - - classNode.access |= Opcodes.ACC_PUBLIC; - - 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; - } - } - - return ProcessResult.PASSTHROUGH_TRANSFORMED; - } - -} diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java index 1740b096..a26ac474 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java @@ -224,14 +224,9 @@ class MixinInfo implements Comparable, IMixinInfo { * Interfaces soft-implemented using {@link Implements} */ protected final List softImplements = new ArrayList(); - - /** - * Synthetic inner classes - */ - protected final Set syntheticInnerClasses = new HashSet(); /** - * Non-synthetic inner classes + * Inner classes */ protected final Set innerClasses = new HashSet(); @@ -286,10 +281,6 @@ class MixinInfo implements Comparable, IMixinInfo { return this.softImplements; } - Set getSyntheticInnerClasses() { - return this.syntheticInnerClasses; - } - Set getInnerClasses() { return this.innerClasses; } @@ -420,20 +411,13 @@ class MixinInfo implements Comparable, IMixinInfo { } /** - * Read inner class definitions for the class and locate any synthetic - * inner classes so that we can add them to the passthrough set in our - * parent config. + * Read inner class definitions for the class and locate any of our inner classes. */ void readInnerClasses() { for (InnerClassNode inner : this.validationClassNode.innerClasses) { if ((inner.outerName != null && inner.outerName.equals(this.classInfo.getName())) || inner.name.startsWith(this.validationClassNode.name + "$")) { - boolean isStatic = (inner.access & Opcodes.ACC_STATIC) != 0; - boolean isSynthetic = (inner.access & Opcodes.ACC_SYNTHETIC) != 0; - - if (isStatic && isSynthetic) { - this.syntheticInnerClasses.add(inner.name); - } else if (!ClassInfo.isMixin(inner.name)) { + if (!ClassInfo.isMixin(inner.name)) { this.innerClasses.add(inner.name); } } @@ -466,7 +450,7 @@ class MixinInfo implements Comparable, IMixinInfo { */ @Override protected void validateChanges(SubType type, List targetClasses) { - if (!this.syntheticInnerClasses.equals(this.previous.syntheticInnerClasses)) { + if (!this.innerClasses.equals(this.previous.innerClasses)) { throw new MixinReloadException(MixinInfo.this, "Cannot change inner classes"); } if (!this.interfaces.equals(this.previous.interfaces)) { @@ -1237,16 +1221,9 @@ class MixinInfo implements Comparable, IMixinInfo { List getSoftImplements() { return Collections.unmodifiableList(this.getState().getSoftImplements()); } - - /** - * Get the synthetic inner classes for this mixin - */ - Set getSyntheticInnerClasses() { - return Collections.unmodifiableSet(this.getState().getSyntheticInnerClasses()); - } /** - * Get the user-defined inner classes for this mixin + * Get the inner classes for this mixin */ Set getInnerClasses() { return Collections.unmodifiableSet(this.getState().getInnerClasses()); diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinProcessor.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinProcessor.java index 82ef8821..1a2985a5 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinProcessor.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinProcessor.java @@ -226,7 +226,6 @@ class MixinProcessor { this.hotSwapper = hotSwapper; this.coprocessors.add(new MixinCoprocessorPassthrough()); - this.coprocessors.add(new MixinCoprocessorSyntheticInner()); this.coprocessors.add(new MixinCoprocessorAccessor(this.sessionId)); this.coprocessors.add(nestHostCoprocessor);