From e9b479035a2896a6eb27fba6e7f595e791ea45bb Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 19 Jun 2024 23:35:24 +0100 Subject: [PATCH] Enable checkstyle --- build.gradle | 10 +- checkstyle.xml | 9 +- .../spongepowered/asm/mixin/FabricUtil.java | 19 +++ .../injection/callback/CallbackInjector.java | 4 +- .../injection/invoke/util/InvokeUtil.java | 5 +- .../injection/struct/InjectionNodes.java | 3 +- .../asm/mixin/transformer/ClassInfo.java | 6 +- .../asm/mixin/transformer/MethodMapper.java | 34 ++--- .../transformer/MixinApplicatorStandard.java | 4 +- .../asm/mixin/transformer/MixinConfig.java | 3 +- .../asm/mixin/transformer/MixinInfo.java | 3 +- .../transformer/MixinInheritanceTracker.java | 124 ++++++++++-------- .../MixinPreProcessorInterface.java | 2 +- .../MixinPreProcessorStandard.java | 14 +- .../asm/mixin/transformer/MixinProcessor.java | 4 +- .../asm/service/MixinService.java | 4 +- .../spongepowered/asm/util/CompareUtil.java | 45 ------- .../spongepowered/asm/util/JavaVersion.java | 32 ++--- .../org/spongepowered/asm/util/Locals.java | 5 +- .../spongepowered/asm/util/VersionNumber.java | 2 +- 20 files changed, 158 insertions(+), 174 deletions(-) delete mode 100644 src/main/java/org/spongepowered/asm/util/CompareUtil.java diff --git a/build.gradle b/build.gradle index ba391cc02..141b8076e 100644 --- a/build.gradle +++ b/build.gradle @@ -81,12 +81,12 @@ repositories { sourceSets { legacy { ext.languageVersion = 8 - ext.compatibility = '1.6' + ext.compatibility = '1.8' } main { compileClasspath += legacy.output ext.languageVersion = 8 - ext.compatibility = '1.6' + ext.compatibility = '1.8' } ap { compileClasspath += main.output @@ -96,13 +96,13 @@ sourceSets { fernflower { compileClasspath += main.output ext.languageVersion = 8 - ext.compatibility = '1.6' + ext.compatibility = '1.8' ext.modularityExcluded = true } agent { compileClasspath += main.output ext.languageVersion = 8 - ext.compatibility = '1.6' + ext.compatibility = '1.8' } bridge { compileClasspath += main.output @@ -322,7 +322,7 @@ checkstyle { "year" : project.inceptionYear ] configFile = file("checkstyle.xml") - toolVersion = '8.44' + toolVersion = '10.17.0' } // Source compiler configuration diff --git a/checkstyle.xml b/checkstyle.xml index 1109c4ac6..48e5470cc 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -9,7 +9,7 @@ Description: none --> - + @@ -131,13 +131,6 @@ - - - - - - - diff --git a/src/main/java/org/spongepowered/asm/mixin/FabricUtil.java b/src/main/java/org/spongepowered/asm/mixin/FabricUtil.java index d4ff75303..f68c3ed3f 100644 --- a/src/main/java/org/spongepowered/asm/mixin/FabricUtil.java +++ b/src/main/java/org/spongepowered/asm/mixin/FabricUtil.java @@ -33,9 +33,25 @@ public final class FabricUtil { public static final String KEY_COMPATIBILITY = "fabric-compat"; // fabric mixin version compatibility boundaries, (major * 1000 + minor) * 1000 + patch + + /** + * Fabric compatibility version 0.9.2 + */ public static final int COMPATIBILITY_0_9_2 = 9002; // 0.9.2+mixin.0.8.2 incompatible local variable handling + + /** + * Fabric compatibility version 0.10.0 + */ public static final int COMPATIBILITY_0_10_0 = 10000; // 0.10.0+mixin.0.8.4 + + /** + * Fabric compatibility version 0.14.0 + */ public static final int COMPATIBILITY_0_14_0 = 14000; // 0.14.0+mixin.0.8.6 + + /** + * Latest compatibility version + */ public static final int COMPATIBILITY_LATEST = COMPATIBILITY_0_14_0; public static String getModId(IMixinConfig config) { @@ -65,4 +81,7 @@ private static T getDecoration(IMixinConfig config, String key, T defaultVal return defaultValue; } } + + private FabricUtil() { + } } 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 0687a66b1..9494ee9f5 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 @@ -570,7 +570,9 @@ private void inject(final Callback callback) { } } this.invokeCallback(callback, callbackMethod); - if (callback.usesCallbackInfo) this.injectCancellationCode(callback); + if (callback.usesCallbackInfo) { + this.injectCancellationCode(callback); + } callback.inject(); this.info.notifyInjected(callback.target); diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java b/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java index 8e874ed60..a57279b0e 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/invoke/util/InvokeUtil.java @@ -32,7 +32,7 @@ import java.util.Arrays; -public class InvokeUtil { +public final class InvokeUtil { public static Type[] getOriginalArgs(InjectionNode node) { return Type.getArgumentTypes(((MethodInsnNode) node.getOriginalTarget()).desc); } @@ -47,4 +47,7 @@ public static Type[] getCurrentArgs(InjectionNode node) { } return currentArgs; } + + private InvokeUtil() { + } } diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionNodes.java b/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionNodes.java index e21756004..86bacb2f0 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionNodes.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionNodes.java @@ -30,7 +30,6 @@ import org.objectweb.asm.tree.AbstractInsnNode; import org.spongepowered.asm.util.Bytecode; -import org.spongepowered.asm.util.CompareUtil; /** * Used to keep track of instruction nodes in a {@link Target} method which are @@ -198,7 +197,7 @@ public V getDecoration(String key) { */ @Override public int compareTo(InjectionNode other) { - return other == null ? Integer.MAX_VALUE : CompareUtil.compare(this.hashCode(), other.hashCode()); + return other == null ? Integer.MAX_VALUE : Integer.compare(this.hashCode(), other.hashCode()); } /* (non-Javadoc) diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java b/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java index 538198cda..c718286a0 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java @@ -232,7 +232,11 @@ public static class FrameData { * Frame local size */ public final int size; - public final int rawSize; // Fabric non-adjusted frame size for legacy support + + /** + * Fabric: non-adjusted frame size for legacy support + */ + public final int rawSize; FrameData(int index, int type, int locals, int size) { this.index = index; diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MethodMapper.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MethodMapper.java index 5c83b5be0..8cbb9d08b 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MethodMapper.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MethodMapper.java @@ -122,11 +122,11 @@ public String getHandlerName(MixinInfo mixin, MixinMethodNode method) { String mod = MethodMapper.getMixinSourceId(mixin, ""); String methodName = method.name; if (!mod.isEmpty()) { - //It's common for mods to prefix their own handlers, let's account for that happening - if (methodName.startsWith(mod) && methodName.length() > mod.length() + 1 && Chars.contains(new char[] {'_', '$'}, methodName.charAt(mod.length()))) { - methodName = methodName.substring(mod.length() + 1); - } - mod += '$'; + //It's common for mods to prefix their own handlers, let's account for that happening + if (methodName.startsWith(mod) && methodName.length() > mod.length() + 1 && Chars.contains(new char[] {'_', '$'}, methodName.charAt(mod.length()))) { + methodName = methodName.substring(mod.length() + 1); + } + mod += '$'; } String methodUID = MethodMapper.getMethodUID(methodName, method.desc, !method.isSurrogate()); return String.format("%s$%s%s$%s%s", prefix, classUID, methodUID, mod, methodName); @@ -145,18 +145,18 @@ public String getUniqueName(MixinInfo mixin, MethodNode method, String sessionId String uniqueIndex = Integer.toHexString(this.nextUniqueMethodIndex++); String methodName = method.name; if (method instanceof MethodNodeEx) { - String mod = MethodMapper.getMixinSourceId(mixin, ""); - if (!mod.isEmpty()) { - //It's rarer for mods to prefix their @Unique methods, but let's account for it anyway - if (methodName.startsWith(mod) && methodName.length() > mod.length() + 1 && Chars.contains(new char[] {'_', '$'}, methodName.charAt(mod.length()))) { - methodName = methodName.substring(mod.length() + 1); - } - if (preservePrefix) { - methodName += '$' + mod; - } else { - methodName = mod + '$' + methodName; - } - } + String mod = MethodMapper.getMixinSourceId(mixin, ""); + if (!mod.isEmpty()) { + //It's rarer for mods to prefix their @Unique methods, but let's account for it anyway + if (methodName.startsWith(mod) && methodName.length() > mod.length() + 1 && Chars.contains(new char[] {'_', '$'}, methodName.charAt(mod.length()))) { + methodName = methodName.substring(mod.length() + 1); + } + if (preservePrefix) { + methodName += '$' + mod; + } else { + methodName = mod + '$' + methodName; + } + } } String pattern = preservePrefix ? "%2$s_$md$%1$s$%3$s" : "md%s$%s$%s"; return String.format(pattern, sessionId.substring(30), methodName, uniqueIndex); diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinApplicatorStandard.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinApplicatorStandard.java index 679899269..2bf01716c 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinApplicatorStandard.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinApplicatorStandard.java @@ -781,7 +781,7 @@ protected final void checkConstraints(MixinTargetContext mixin, MethodNode metho /** * Finds a method in the target class - * @param searchFor + * @param searchFor The method node to search for * * @return Target method matching searchFor, or null if not found */ @@ -797,7 +797,7 @@ protected final MethodNode findTargetMethod(MethodNode searchFor) { /** * Finds a field in the target class - * @param searchFor + * @param searchFor The field node to search for * * @return Target field matching searchFor, or null if not found */ diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinConfig.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinConfig.java index ee91220b4..d3a550f5e 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinConfig.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinConfig.java @@ -59,7 +59,6 @@ import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException; import org.spongepowered.asm.service.IMixinService; import org.spongepowered.asm.service.MixinService; -import org.spongepowered.asm.util.CompareUtil; import org.spongepowered.asm.util.VersionNumber; import com.google.common.base.Strings; @@ -1374,7 +1373,7 @@ public int compareTo(MixinConfig other) { return 0; } if (other.priority == this.priority) { - return CompareUtil.compare(this.order, other.order); + return Integer.compare(this.order, other.order); } else { return (this.priority < other.priority) ? -1 : 1; } 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 ce87922d2..0a445e8c7 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java @@ -73,7 +73,6 @@ import org.spongepowered.asm.util.LanguageFeatures; import org.spongepowered.asm.util.asm.ASM; import org.spongepowered.asm.util.asm.MethodNodeEx; -import org.spongepowered.asm.util.CompareUtil; import org.spongepowered.asm.util.perf.Profiler; import org.spongepowered.asm.util.perf.Profiler.Section; @@ -1342,7 +1341,7 @@ public int compareTo(MixinInfo other) { return 0; } if (other.priority == this.priority) { - return CompareUtil.compare(this.order, other.order); + return Integer.compare(this.order, other.order); } else { return (this.priority < other.priority) ? -1 : 1; } diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInheritanceTracker.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInheritanceTracker.java index e76e20125..e6e26ca66 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInheritanceTracker.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInheritanceTracker.java @@ -38,62 +38,70 @@ import org.spongepowered.asm.util.Bytecode; public enum MixinInheritanceTracker implements IListener { - INSTANCE; - - @Override - public void onPrepare(MixinInfo mixin) { - } - - @Override - public void onInit(MixinInfo mixin) { - ClassInfo mixinInfo = mixin.getClassInfo(); - assert mixinInfo.isMixin(); //The mixin should certainly be a mixin - - for (ClassInfo superType = mixinInfo.getSuperClass(); superType != null && superType.isMixin(); superType = superType.getSuperClass()) { - List children = parentMixins.get(superType.getName()); - - if (children == null) { - parentMixins.put(superType.getName(), children = new ArrayList()); - } - - children.add(mixin); - } - } - - public List findOverrides(ClassInfo owner, String name, String desc) { - return findOverrides(owner.getName(), name, desc); - } - - public List findOverrides(String owner, String name, String desc) { - List children = parentMixins.get(owner); - if (children == null) return Collections.emptyList(); - - List out = new ArrayList(children.size()); - - for (MixinInfo child : children) { - ClassNode node = child.getClassNode(ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); - - MethodNode method = Bytecode.findMethod(node, name, desc); - if (method == null || Bytecode.isStatic(method)) continue; - - switch (Bytecode.getVisibility(method)) { - case PRIVATE: - break; - - case PACKAGE: - int ownerSplit = owner.lastIndexOf('/'); - int childSplit = node.name.lastIndexOf('/'); - //There is a reasonable chance mixins are in the same package, so it is viable that a package private method is overridden - if (ownerSplit != childSplit || (ownerSplit > 0 && !owner.regionMatches(0, node.name, 0, ownerSplit + 1))) break; - - default: - out.add(method); - break; - } - } - - return out.isEmpty() ? Collections.emptyList() : out; - } - - private final Map> parentMixins = new HashMap>(); + INSTANCE; + + @Override + public void onPrepare(MixinInfo mixin) { + } + + @Override + public void onInit(MixinInfo mixin) { + ClassInfo mixinInfo = mixin.getClassInfo(); + assert mixinInfo.isMixin(); //The mixin should certainly be a mixin + + for (ClassInfo superType = mixinInfo.getSuperClass(); superType != null && superType.isMixin(); superType = superType.getSuperClass()) { + List children = parentMixins.get(superType.getName()); + + if (children == null) { + parentMixins.put(superType.getName(), children = new ArrayList()); + } + + children.add(mixin); + } + } + + public List findOverrides(ClassInfo owner, String name, String desc) { + return findOverrides(owner.getName(), name, desc); + } + + public List findOverrides(String owner, String name, String desc) { + List children = parentMixins.get(owner); + if (children == null) { + return Collections.emptyList(); + } + + List out = new ArrayList(children.size()); + + for (MixinInfo child : children) { + ClassNode node = child.getClassNode(ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); + + MethodNode method = Bytecode.findMethod(node, name, desc); + if (method == null || Bytecode.isStatic(method)) { + continue; + } + + switch (Bytecode.getVisibility(method)) { + case PRIVATE: + break; + + case PACKAGE: + int ownerSplit = owner.lastIndexOf('/'); + int childSplit = node.name.lastIndexOf('/'); + //There is a reasonable chance mixins are in the same package, so it is viable that a package private method is overridden + if (ownerSplit != childSplit || (ownerSplit > 0 && !owner.regionMatches(0, node.name, 0, ownerSplit + 1))) { + break; + } + + out.add(method); + break; + default: + out.add(method); + break; + } + } + + return out.isEmpty() ? Collections.emptyList() : out; + } + + private final Map> parentMixins = new HashMap>(); } \ No newline at end of file diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorInterface.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorInterface.java index 55c493d95..a01aa57fd 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorInterface.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorInterface.java @@ -140,7 +140,7 @@ protected boolean validateField(MixinTargetContext context, FieldNode field, Ann //Making a field non-final will result in verification crashes, so @Mutable is always a mistake if (Annotations.getVisible(field, Mutable.class) != null) { - throw new InvalidInterfaceMixinException(this.mixin, String.format("@Shadow field %s.%s is marked as mutable. This is not allowed.", + throw new InvalidInterfaceMixinException(this.mixin, String.format("@Shadow field %s.%s is marked as mutable. This is not allowed.", this.mixin, field.name)); } diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorStandard.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorStandard.java index 8b5b53132..5be4f8f22 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorStandard.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinPreProcessorStandard.java @@ -649,13 +649,13 @@ protected void attachFields(MixinTargetContext context) { iter.remove(); continue; } else if (!Bytecode.compareFlags(mixinField, target, Opcodes.ACC_STATIC)) { - if (isShadow) { - throw new InvalidMixinException(this.mixin, String.format("STATIC modifier of @Shadow field %s in %s does not match the target", - mixinField.name, this.mixin)); - } else { - throw new InvalidMixinException(this.mixin, String.format("Field %s in %s conflicts with %sstatic field in the target (%s)", - mixinField.name, mixin, Bytecode.isStatic(target) ? "" : "non-", context.getTarget())); - } + if (isShadow) { + throw new InvalidMixinException(this.mixin, String.format("STATIC modifier of @Shadow field %s in %s does not match the target", + mixinField.name, this.mixin)); + } else { + throw new InvalidMixinException(this.mixin, String.format("Field %s in %s conflicts with %sstatic field in the target (%s)", + mixinField.name, mixin, Bytecode.isStatic(target) ? "" : "non-", context.getTarget())); + } } if (!Bytecode.compareFlags(mixinField, target, Opcodes.ACC_STATIC)) { 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 d67cc10be..2cfa27c33 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinProcessor.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinProcessor.java @@ -543,7 +543,7 @@ public void onInit(MixinInfo mixin) { this.handleMixinPrepareError(config, ex, environment); } catch (Exception ex) { String message = ex.getMessage(); - MixinProcessor.logger.error("Error encountered whilst initialising mixin config '" + config.getName() + "' from mod '"+org.spongepowered.asm.mixin.FabricUtil.getModId(config)+"': " + message, ex); + MixinProcessor.logger.error("Error encountered whilst initialising mixin config '" + config.getName() + "' from mod '" + org.spongepowered.asm.mixin.FabricUtil.getModId(config) + "': " + message, ex); } } @@ -570,7 +570,7 @@ public void onInit(MixinInfo mixin) { this.handleMixinPrepareError(config, ex, environment); } catch (Exception ex) { String message = ex.getMessage(); - MixinProcessor.logger.error("Error encountered during mixin config postInit step '" + config.getName() + "' from mod '"+org.spongepowered.asm.mixin.FabricUtil.getModId(config)+ "': " + message, ex); + MixinProcessor.logger.error("Error encountered during mixin config postInit step '" + config.getName() + "' from mod '" + org.spongepowered.asm.mixin.FabricUtil.getModId(config) + "': " + message, ex); } } diff --git a/src/main/java/org/spongepowered/asm/service/MixinService.java b/src/main/java/org/spongepowered/asm/service/MixinService.java index d4a752e2d..6c54333ae 100644 --- a/src/main/java/org/spongepowered/asm/service/MixinService.java +++ b/src/main/java/org/spongepowered/asm/service/MixinService.java @@ -221,7 +221,9 @@ private IMixinService initService() { if (serviceCls != null) { try { IMixinService service = (IMixinService) Class.forName(serviceCls).getConstructor().newInstance(); - if (!service.isValid()) throw new RuntimeException("invalid service "+serviceCls+" configured via system property"); + if (!service.isValid()) { + throw new RuntimeException("invalid service " + serviceCls + " configured via system property"); + } return service; } catch (ReflectiveOperationException e) { diff --git a/src/main/java/org/spongepowered/asm/util/CompareUtil.java b/src/main/java/org/spongepowered/asm/util/CompareUtil.java deleted file mode 100644 index 7b1be4f95..000000000 --- a/src/main/java/org/spongepowered/asm/util/CompareUtil.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.util; - -/** - * Comparison helpers. - */ -public final class CompareUtil { - private CompareUtil() { - - } - - /** - * Officially added in Java 7. - */ - public static int compare(int a, int b) { - return ((a < b) ? -1 : ((a == b) ? 0 : 1)); - } - - public static int compare(long a, long b) { - return ((a < b) ? -1 : ((a == b) ? 0 : 1)); - } -} diff --git a/src/main/java/org/spongepowered/asm/util/JavaVersion.java b/src/main/java/org/spongepowered/asm/util/JavaVersion.java index c95c93302..9382f27b3 100644 --- a/src/main/java/org/spongepowered/asm/util/JavaVersion.java +++ b/src/main/java/org/spongepowered/asm/util/JavaVersion.java @@ -97,25 +97,25 @@ public abstract class JavaVersion { */ public static final double JAVA_18 = 18.0; - /** - * Version number for Java 19 - */ - public static final double JAVA_19 = 19.0; + /** + * Version number for Java 19 + */ + public static final double JAVA_19 = 19.0; - /** - * Version number for Java 20 - */ - public static final double JAVA_20 = 20.0; + /** + * Version number for Java 20 + */ + public static final double JAVA_20 = 20.0; - /** - * Version number for Java 21 - */ - public static final double JAVA_21 = 21.0; + /** + * Version number for Java 21 + */ + public static final double JAVA_21 = 21.0; - /** - * Version number for Java 22 - */ - public static final double JAVA_22 = 22.0; + /** + * Version number for Java 22 + */ + public static final double JAVA_22 = 22.0; private static double current = 0.0; diff --git a/src/main/java/org/spongepowered/asm/util/Locals.java b/src/main/java/org/spongepowered/asm/util/Locals.java index 4f62ce352..0fcc960c1 100644 --- a/src/main/java/org/spongepowered/asm/util/Locals.java +++ b/src/main/java/org/spongepowered/asm/util/Locals.java @@ -328,6 +328,7 @@ public static void loadLocals(Type[] locals, InsnList insns, int pos, int limit) * bear in mind that if the specified node is itself a STORE opcode, * then we will be looking at the state of the locals PRIOR to its * invocation + * @param fabricCompatibility Fabric compatibility level * @return A sparse array containing a view (hopefully) of the locals at the * specified location */ @@ -335,7 +336,7 @@ public static LocalVariableNode[] getLocalsAt(ClassNode classNode, MethodNode me if (fabricCompatibility >= org.spongepowered.asm.mixin.FabricUtil.COMPATIBILITY_0_10_0) { return Locals.getLocalsAt(classNode, method, node, Settings.DEFAULT); } else { - return getLocalsAt_0_9_2(classNode, method, node); + return getLocalsAt092(classNode, method, node); } } @@ -580,7 +581,7 @@ public static LocalVariableNode[] getLocalsAt(ClassNode classNode, MethodNode me return frame; } - private static LocalVariableNode[] getLocalsAt_0_9_2(ClassNode classNode, MethodNode method, AbstractInsnNode node) { + private static LocalVariableNode[] getLocalsAt092(ClassNode classNode, MethodNode method, AbstractInsnNode node) { for (int i = 0; i < 3 && (node instanceof LabelNode || node instanceof LineNumberNode); i++) { node = Locals.nextNode(method.instructions, node); } diff --git a/src/main/java/org/spongepowered/asm/util/VersionNumber.java b/src/main/java/org/spongepowered/asm/util/VersionNumber.java index d764dd36b..ff9e8b06e 100644 --- a/src/main/java/org/spongepowered/asm/util/VersionNumber.java +++ b/src/main/java/org/spongepowered/asm/util/VersionNumber.java @@ -141,7 +141,7 @@ public int compareTo(VersionNumber other) { if (other == null) { return 1; } - return CompareUtil.compare(this.value, other.value); + return Long.compare(this.value, other.value); } /* (non-Javadoc)