diff --git a/gradle.properties b/gradle.properties index 57019429..e4e180e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,5 +4,5 @@ packaging=jar description=Mixin url=https://www.spongepowered.org organization=SpongePowered -buildVersion=0.6.14 +buildVersion=0.6.15 buildType=SNAPSHOT diff --git a/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java b/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java index aafa5569..0dd93ed2 100644 --- a/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java +++ b/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java @@ -62,7 +62,7 @@ public abstract class MixinBootstrap { /** * Subsystem version */ - public static final String VERSION = "0.6.14"; + public static final String VERSION = "0.6.15"; // Consts private static final String LAUNCH_PACKAGE = "org.spongepowered.asm.launch."; diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/ModifyConstant.java b/src/main/java/org/spongepowered/asm/mixin/injection/ModifyConstant.java index 5ca5eb65..8b4ff503 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/ModifyConstant.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/ModifyConstant.java @@ -77,13 +77,13 @@ public @interface ModifyConstant { public Slice slice() default @Slice; /** - * Discriminator for the constant to match (injection point), if not + * Discriminator for the constant(s) to match (injection points), if not * specified then all constants matching the annotated handler's return type * are matched * * @return the constant discriminator */ - public Constant constant() default @Constant; + public Constant[] constant() default {}; /** * By default, the annotation processor will attempt to locate an diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java b/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java index c2f2701d..0440abde 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java @@ -84,6 +84,11 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC * Method slice descriptors parsed from the annotation */ protected final MethodSlices slices; + + /** + * The key into the annotation which contains the injection points + */ + protected final String atKey; /** * Injection points parsed from @@ -134,9 +139,14 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC * @param annotation Annotation to parse */ protected InjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) { + this(mixin, method, annotation, "at"); + } + + protected InjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation, String atKey) { super(mixin, method, annotation); this.isStatic = Bytecode.methodIsStatic(method); this.slices = MethodSlices.parse(this); + this.atKey = atKey; this.readAnnotation(); } @@ -176,9 +186,9 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC } protected List readInjectionPoints(String type) { - List ats = Annotations.getValue(this.annotation, "at", false); + List ats = Annotations.getValue(this.annotation, this.atKey, false); if (ats == null) { - throw new InvalidInjectionException(this, type + " annotation on " + this.method.name + " is missing 'at' value(s)"); + throw new InvalidInjectionException(this, type + " annotation on " + this.method.name + " is missing '" + this.atKey + "' value(s)"); } return ats; } diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/struct/ModifyConstantInjectionInfo.java b/src/main/java/org/spongepowered/asm/mixin/injection/struct/ModifyConstantInjectionInfo.java index 7ed60388..1b6617da 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/struct/ModifyConstantInjectionInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/struct/ModifyConstantInjectionInfo.java @@ -24,7 +24,6 @@ */ package org.spongepowered.asm.mixin.injection.struct; -import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -49,6 +48,7 @@ import org.spongepowered.asm.util.Bytecode; import org.spongepowered.asm.util.Annotations; import org.spongepowered.asm.util.Constants; +import com.google.common.collect.ImmutableList; import com.google.common.primitives.Ints; /** @@ -215,15 +215,20 @@ public class ModifyConstantInjectionInfo extends InjectionInfo { } + private static final String CONSTANT_ANNOTATION_CLASS = Constant.class.getName().replace('.', '/'); + public ModifyConstantInjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) { - super(mixin, method, annotation); + super(mixin, method, annotation, "constant"); } @Override protected List readInjectionPoints(String type) { - AnnotationNode constantAnnotation = Annotations.getValue(this.annotation, "constant"); - List ats = new ArrayList(); - ats.add(constantAnnotation); + List ats = super.readInjectionPoints(type); + if (ats.isEmpty()) { + AnnotationNode c = new AnnotationNode(ModifyConstantInjectionInfo.CONSTANT_ANNOTATION_CLASS); + c.visit("log", Boolean.TRUE); + ats = ImmutableList.of(c); + } return ats; }