diff --git a/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java b/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java index 742b7a9a..0ca05f93 100644 --- a/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java +++ b/src/main/java/org/spongepowered/asm/mixin/MixinEnvironment.java @@ -357,6 +357,15 @@ public final class MixinEnvironment implements ITokenProvider { */ REFMAP_REMAP_SOURCE_ENV(Option.ENVIRONMENT, Inherit.INDEPENDENT, "refMapRemappingEnv", "searge"), + /** + * When mixin.env.remapRefMap is enabled and a refmap is + * available for a mixin config, certain injection points are allowed to + * fail over to a "permissive" match which ignores the member descriptor + * in the refmap. To disable this behaviour, set this property to + * false. + */ + REFMAP_REMAP_ALLOW_PERMISSIVE(Option.ENVIRONMENT, Inherit.INDEPENDENT, "allowPermissiveMatch", true, "true"), + /** * Globally ignore the "required" attribute of all configurations */ diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/points/BeforeInvoke.java b/src/main/java/org/spongepowered/asm/mixin/injection/points/BeforeInvoke.java index 2d785cba..a46988c4 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/points/BeforeInvoke.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/points/BeforeInvoke.java @@ -38,6 +38,7 @@ import org.spongepowered.asm.mixin.injection.InjectionPoint; import org.spongepowered.asm.mixin.injection.InjectionPoint.AtCode; import org.spongepowered.asm.mixin.injection.struct.InjectionPointData; import org.spongepowered.asm.mixin.injection.struct.MemberInfo; +import org.spongepowered.asm.mixin.refmap.IMixinContext; /** *
This injection point searches for INVOKEVIRTUAL, INVOKESTATIC and
@@ -67,8 +68,26 @@ import org.spongepowered.asm.mixin.injection.struct.MemberInfo;
*/
@AtCode("INVOKE")
public class BeforeInvoke extends InjectionPoint {
+
+ /**
+ * Member search type, the PERMISSIVE search is only used when
+ * refmap remapping is enabled.
+ */
+ public enum SearchType {
+
+ STRICT,
+ PERMISSIVE
+
+ }
- protected final MemberInfo target, permissiveTarget;
+ protected final MemberInfo target;
+
+ /**
+ * This option enables a fallback "permissive" search to occur if initial
+ * search fails if and only if the {@link Option#REFMAP_REMAP} option is
+ * enabled and the context mixin's parent config has a valid refmap.
+ */
+ protected final boolean allowPermissive;
/**
* This strategy can be used to identify a particular invocation if the same
@@ -81,14 +100,22 @@ public class BeforeInvoke extends InjectionPoint {
* Class name (description) for debug logging
*/
protected final String className;
+
+ /**
+ *
+ */
+ protected final IMixinContext context;
+
+ /**
+ * Logger reference
+ */
+ protected final Logger logger = LogManager.getLogger("mixin");
/**
* True to turn on strategy debugging to the console
*/
private boolean log = false;
- private final Logger logger = LogManager.getLogger("mixin");
-
public BeforeInvoke(InjectionPointData data) {
super(data);
@@ -96,7 +123,9 @@ public class BeforeInvoke extends InjectionPoint {
this.ordinal = data.getOrdinal();
this.log = data.get("log", false);
this.className = this.getClassName();
- this.permissiveTarget = data.getContext().getOption(Option.REFMAP_REMAP) ? this.target.transform(null) : null;
+ this.context = data.getContext();
+ this.allowPermissive = this.context.getOption(Option.REFMAP_REMAP) && this.context.getOption(Option.REFMAP_REMAP_ALLOW_PERMISSIVE)
+ && !this.context.getReferenceMapper().isDefault();
}
private String getClassName() {
@@ -124,19 +153,23 @@ public class BeforeInvoke extends InjectionPoint {
public boolean find(String desc, InsnList insns, Collection