Fix a bunch of small issues detected by using an intellij inspection

This commit is contained in:
Mumfrey committed 2017-09-08 18:36:57 +01:00
1 parent ec6fbf5f61
commit 3961a7cbf8
18 files changed
+33 -38

No files matched your search

@@ -422,7 +422,7 @@ public final class MixinEnvironment implements ITokenProvider {
/**
* This option is always <tt>false</tt>.
*/
ALWAYS_FALSE;
ALWAYS_FALSE
}
@@ -519,9 +519,8 @@ public class CallbackInjector extends Injector {
int position = callback.target.indexOf(callback.node);
List<String> expected = CallbackInjector.summariseLocals(this.methodNode.desc, callback.target.arguments.length + 1);
List<String> found = CallbackInjector.summariseLocals(callback.getDescriptorWithAllLocals(), callback.frameSize);
String message = String.format("LVT in %s has incompatible changes at opcode %d in callback %s.\nExpected: %s\n Found: %s",
return String.format("LVT in %s has incompatible changes at opcode %d in callback %s.\nExpected: %s\n Found: %s",
callback.target, position, this, expected, found);
return message;
}
/**
@@ -150,7 +150,7 @@ public class BeforeConstant extends InjectionPoint {
Boolean empty = Annotations.<Boolean>getValue(node, "nullValue", (Boolean)null);
this.ordinal = Annotations.<Integer>getValue(node, "ordinal", Integer.valueOf(-1));
this.nullValue = empty != null ? empty.booleanValue() : false;
this.nullValue = empty != null && empty.booleanValue();
this.intValue = Annotations.<Integer>getValue(node, "intValue", (Integer)null);
this.floatValue = Annotations.<Float>getValue(node, "floatValue", (Float)null);
this.longValue = Annotations.<Long>getValue(node, "longValue", (Long)null);
@@ -172,7 +172,7 @@ public class BeforeConstant extends InjectionPoint {
Boolean empty = strNullValue != null ? Boolean.parseBoolean(strNullValue) : null;
this.ordinal = data.getOrdinal();
this.nullValue = empty != null ? empty.booleanValue() : false;
this.nullValue = empty != null && empty.booleanValue();
this.intValue = Ints.tryParse(data.get("intValue", ""));
this.floatValue = Floats.tryParse(data.get("floatValue", ""));
this.longValue = Longs.tryParse(data.get("longValue", ""));
@@ -406,15 +406,15 @@ public class Target implements Comparable<Target>, Iterable<AbstractInsnNode> {
return this.callbackDescriptor;
}
String descriptor = this.callbackDescriptor.substring(0, this.callbackDescriptor.indexOf(')'));
StringBuilder descriptor = new StringBuilder(this.callbackDescriptor.substring(0, this.callbackDescriptor.indexOf(')')));
for (int l = startIndex; l < locals.length && extra > 0; l++) {
if (locals[l] != null) {
descriptor += locals[l].getDescriptor();
descriptor.append(locals[l].getDescriptor());
extra--;
}
}
return descriptor + ")V";
return descriptor.append(")V").toString();
}
@Override
@@ -71,7 +71,7 @@ public abstract class MemberRef {
@Override
public void setOpcode(int opcode) {
if ((opcode | Method.OPCODES) == 0) {
if ((opcode & Method.OPCODES) == 0) {
throw new IllegalArgumentException("Invalid opcode for method instruction: 0x" + Integer.toHexString(opcode));
}
@@ -142,7 +142,7 @@ public abstract class MemberRef {
@Override
public void setOpcode(int opcode) {
if ((opcode | Field.OPCODES) == 0) {
if ((opcode & Field.OPCODES) == 0) {
throw new IllegalArgumentException("Invalid opcode for field instruction: 0x" + Integer.toHexString(opcode));
}
@@ -1108,7 +1108,7 @@ public final class ClassInfo {
* @return Matched superclass or null if not found
*/
public ClassInfo findSuperClass(String superClass, Traversal traversal, boolean includeInterfaces) {
if (ClassInfo.OBJECT.name == superClass) {
if (ClassInfo.OBJECT.name.equals(superClass)) {
return null;
}
@@ -232,7 +232,7 @@ public final class InterfaceInfo {
throw new InvalidMixinException(mixin, String.format("@Interface annotation on %s is missing a required parameter", mixin));
}
return new InterfaceInfo(mixin, prefix, iface, unique != null ? unique.booleanValue() : false);
return new InterfaceInfo(mixin, prefix, iface, unique != null && unique.booleanValue());
}
@Override
@@ -933,7 +933,7 @@ class MixinApplicatorStandard {
if (Bytecode.hasFlag(mixinMethod, Opcodes.ACC_STATIC)
&& !Bytecode.hasFlag(mixinMethod, Opcodes.ACC_PRIVATE)
&& !Bytecode.hasFlag(mixinMethod, Opcodes.ACC_SYNTHETIC)
&& !(Annotations.getVisible(mixinMethod, Overwrite.class) != null)) {
&& Annotations.getVisible(mixinMethod, Overwrite.class) == null) {
throw new InvalidMixinException(mixin,
String.format("Mixin %s contains non-private static method %s", mixin, mixinMethod));
}
@@ -385,15 +385,15 @@ class TargetClassContext extends ClassContext implements ITargetClassContext {
AnnotationNode classDebugAnnotation = Annotations.getVisible(this.classNode, Debug.class);
if (classDebugAnnotation != null) {
this.forceExport = Boolean.TRUE.equals(Annotations.<String>getValue(classDebugAnnotation, "export"));
if (Boolean.TRUE.equals(Annotations.<String>getValue(classDebugAnnotation, "print"))) {
this.forceExport = Boolean.TRUE.equals(Annotations.<Boolean>getValue(classDebugAnnotation, "export"));
if (Boolean.TRUE.equals(Annotations.<Boolean>getValue(classDebugAnnotation, "print"))) {
Bytecode.textify(this.classNode, System.err);
}
}
for (MethodNode method : this.classNode.methods) {
AnnotationNode methodDebugAnnotation = Annotations.getVisible(method, Debug.class);
if (methodDebugAnnotation != null && Boolean.TRUE.equals(Annotations.<String>getValue(methodDebugAnnotation, "print"))) {
if (methodDebugAnnotation != null && Boolean.TRUE.equals(Annotations.<Boolean>getValue(methodDebugAnnotation, "print"))) {
Bytecode.textify(method, System.err);
}
}
@@ -36,7 +36,9 @@ import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.lib.tree.FieldNode;
import org.spongepowered.asm.lib.tree.MethodNode;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
/**
* Utility class for working with ASM annotations
@@ -302,7 +304,11 @@ public final class Annotations {
int foundNodes = nodes.size();
if (foundNodes > 1) {
throw new IllegalArgumentException("Conflicting annotations found: " + annotationClasses);
throw new IllegalArgumentException("Conflicting annotations found: " + Lists.transform(nodes, new Function<AnnotationNode, String>() {
@Override public String apply(AnnotationNode input) {
return input.desc;
}
}));
}
return foundNodes == 0 ? null : nodes.get(0);
@@ -639,7 +639,7 @@ public final class Bytecode {
} else if (arg instanceof Type) {
return arg.toString();
} else if (arg instanceof Class) {
return Type.getDescriptor((Class<?>)arg).toString();
return Type.getDescriptor((Class<?>)arg);
}
return arg == null ? "" : arg.toString();
}
@@ -127,7 +127,7 @@ public final class VersionNumber implements Comparable<VersionNumber>, Serializa
*/
@Override
public int hashCode() {
return (int)(this.value >> 32) ^ (int)(this.value & 0xFFFFFFFF);
return (int)(this.value >> 32) ^ (int)(this.value & 0xFFFFFFFFL);
}
/**
@@ -161,7 +161,7 @@ public final class VersionNumber implements Comparable<VersionNumber>, Serializa
* @param version Version number to parse
* @return Version number
*/
public static final VersionNumber parse(String version) {
public static VersionNumber parse(String version) {
return VersionNumber.parse(version, VersionNumber.NONE);
}