Skip to content

Commit

Permalink
0.7.11 - Fix handling of maxShiftBy and set hard limit to 5, fixes Sp…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mumfrey committed Jun 20, 2018
1 parent 81a22a4 commit c08fb6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ packaging=jar
description=Mixin
url=https://www.spongepowered.org
organization=SpongePowered
buildVersion=0.7.10
buildVersion=0.7.11
buildType=SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import org.spongepowered.asm.service.MixinService;

/**
* Bootstaps the mixin subsystem. This class acts as a bridge between the mixin
* Bootstraps the mixin subsystem. This class acts as a bridge between the mixin
* subsystem and the tweaker or coremod which is boostrapping it. Without this
* class, a coremod may cause classload of MixinEnvironment in the
* LaunchClassLoader before we have a chance to exclude it. By placing the main
* bootstap logic here we avoid the need for consumers to add the classloader
* bootstrap logic here we avoid the need for consumers to add the classloader
* exclusion themselves.
*
* <p>In development, where (because of the classloader environment at dev time)
Expand All @@ -51,7 +51,7 @@
* its constructor and that would be the end of the story. However we also need
* to register the additional tweaker for environment to detect the transition
* from pre-init to default and we cannot do this within the tweaker constructor
* witout triggering a ConcurrentModificationException in the tweaker list. To
* without triggering a ConcurrentModificationException in the tweaker list. To
* work around this we register the secondary tweaker from within the mixin
* tweaker's acceptOptions method instead.</p>
*/
Expand All @@ -60,7 +60,7 @@ public abstract class MixinBootstrap {
/**
* Subsystem version
*/
public static final String VERSION = "0.7.10";
public static final String VERSION = "0.7.11";

/**
* Log all the things
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,9 @@ enum ShiftByViolationBehaviour {
public static final int DEFAULT_ALLOWED_SHIFT_BY = 0;

/**
* Hard limit on the value of {@link At#by} which triggers warning/error
* (based on environment)
* Hard limit on the value of {@link At#by} which triggers error
*/
public static final int MAX_ALLOWED_SHIFT_BY = 0;
public static final int MAX_ALLOWED_SHIFT_BY = 5;

/**
* Available injection point types
Expand Down Expand Up @@ -665,6 +664,8 @@ private static void validateByValue(IMixinContext context, MethodNode method, An
return;
}

String limitBreached = "the maximum allowed value: ";
String advice = "Increase the value of maxShiftBy to suppress this warning.";
int allowed = InjectionPoint.DEFAULT_ALLOWED_SHIFT_BY;
if (context instanceof MixinTargetContext) {
allowed = ((MixinTargetContext)context).getMaxShiftByValue();
Expand All @@ -674,11 +675,17 @@ private static void validateByValue(IMixinContext context, MethodNode method, An
return;
}

String message = String.format("@%s(%s) Shift.BY=%d on %s::%s exceeds the maximum allowed value %d.", Bytecode.getSimpleName(parent), point,
by, context, method.name, allowed);
if (by > InjectionPoint.MAX_ALLOWED_SHIFT_BY) {
limitBreached = "MAX_ALLOWED_SHIFT_BY=";
advice = "You must use an alternate query or a custom injection point.";
allowed = InjectionPoint.MAX_ALLOWED_SHIFT_BY;
}

String message = String.format("@%s(%s) Shift.BY=%d on %s::%s exceeds %s%d. %s", Bytecode.getSimpleName(parent), point,
by, context, method.name, limitBreached, allowed, advice);

if (err == ShiftByViolationBehaviour.WARN) {
LogManager.getLogger("mixin").warn("{} Increase the value of maxShiftBy to suppress this warning.", message);
if (err == ShiftByViolationBehaviour.WARN && allowed < InjectionPoint.MAX_ALLOWED_SHIFT_BY) {
LogManager.getLogger("mixin").warn(message);
return;
}

Expand Down

0 comments on commit c08fb6b

Please sign in to comment.