Commit e14cdbdf authored by Eric Bruneton's avatar Eric Bruneton

Check the code quality with PMD

parent 19735cbf
...@@ -263,8 +263,7 @@ public class Analyzer<V extends Value> implements Opcodes { ...@@ -263,8 +263,7 @@ public class Analyzer<V extends Value> implements Opcodes {
List<TryCatchBlockNode> insnHandlers = handlers[insnIndex]; List<TryCatchBlockNode> insnHandlers = handlers[insnIndex];
if (insnHandlers != null) { if (insnHandlers != null) {
for (int i = 0; i < insnHandlers.size(); ++i) { for (TryCatchBlockNode tryCatchBlock : insnHandlers) {
TryCatchBlockNode tryCatchBlock = insnHandlers.get(i);
Type catchType; Type catchType;
if (tryCatchBlock.type == null) { if (tryCatchBlock.type == null) {
catchType = Type.getObjectType("java/lang/Throwable"); catchType = Type.getObjectType("java/lang/Throwable");
...@@ -348,8 +347,7 @@ public class Analyzer<V extends Value> implements Opcodes { ...@@ -348,8 +347,7 @@ public class Analyzer<V extends Value> implements Opcodes {
// Push the exception handler successors of currentInsn onto instructionIndicesToProcess. // Push the exception handler successors of currentInsn onto instructionIndicesToProcess.
List<TryCatchBlockNode> insnHandlers = handlers[currentInsnIndex]; List<TryCatchBlockNode> insnHandlers = handlers[currentInsnIndex];
if (insnHandlers != null) { if (insnHandlers != null) {
for (int i = 0; i < insnHandlers.size(); ++i) { for (TryCatchBlockNode tryCatchBlock : insnHandlers) {
TryCatchBlockNode tryCatchBlock = insnHandlers.get(i);
instructionIndicesToProcess.add(insnList.indexOf(tryCatchBlock.handler)); instructionIndicesToProcess.add(insnList.indexOf(tryCatchBlock.handler));
} }
} }
...@@ -393,12 +391,12 @@ public class Analyzer<V extends Value> implements Opcodes { ...@@ -393,12 +391,12 @@ public class Analyzer<V extends Value> implements Opcodes {
currentLocal++; currentLocal++;
} }
Type[] argumentTypes = Type.getArgumentTypes(method.desc); Type[] argumentTypes = Type.getArgumentTypes(method.desc);
for (int i = 0; i < argumentTypes.length; ++i) { for (Type argumentType : argumentTypes) {
frame.setLocal( frame.setLocal(
currentLocal, currentLocal,
interpreter.newParameterValue(isInstanceMethod, currentLocal, argumentTypes[i])); interpreter.newParameterValue(isInstanceMethod, currentLocal, argumentType));
currentLocal++; currentLocal++;
if (argumentTypes[i].getSize() == 2) { if (argumentType.getSize() == 2) {
frame.setLocal(currentLocal, interpreter.newEmptyValue(currentLocal)); frame.setLocal(currentLocal, interpreter.newEmptyValue(currentLocal));
currentLocal++; currentLocal++;
} }
......
...@@ -80,6 +80,7 @@ public class BasicValue implements Value { ...@@ -80,6 +80,7 @@ public class BasicValue implements Value {
return type; return type;
} }
@Override
public int getSize() { public int getSize() {
return type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1; return type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1;
} }
......
...@@ -375,9 +375,9 @@ public class BasicVerifier extends BasicInterpreter { ...@@ -375,9 +375,9 @@ public class BasicVerifier extends BasicInterpreter {
throws AnalyzerException { throws AnalyzerException {
int opcode = insn.getOpcode(); int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) { if (opcode == MULTIANEWARRAY) {
for (int i = 0; i < values.size(); ++i) { for (BasicValue value : values) {
if (!BasicValue.INT_VALUE.equals(values.get(i))) { if (!BasicValue.INT_VALUE.equals(value)) {
throw new AnalyzerException(insn, null, BasicValue.INT_VALUE, values.get(i)); throw new AnalyzerException(insn, null, BasicValue.INT_VALUE, value);
} }
} }
} else { } else {
......
...@@ -79,13 +79,13 @@ public class Frame<V extends Value> { ...@@ -79,13 +79,13 @@ public class Frame<V extends Value> {
} }
/** /**
* Constructs a copy of the given. * Constructs a copy of the given Frame.
* *
* @param frame a frame. * @param frame a frame.
*/ */
public Frame(final Frame<? extends V> frame) { public Frame(final Frame<? extends V> frame) {
this(frame.numLocals, frame.values.length - frame.numLocals); this(frame.numLocals, frame.values.length - frame.numLocals);
init(frame); init(frame); // NOPMD(ConstructorCallsOverridableMethod): can't fix for backward compatibility.
} }
/** /**
......
...@@ -291,7 +291,7 @@ public class SimpleVerifier extends BasicVerifier { ...@@ -291,7 +291,7 @@ public class SimpleVerifier extends BasicVerifier {
* @return whether 'type' corresponds to an interface. * @return whether 'type' corresponds to an interface.
*/ */
protected boolean isInterface(final Type type) { protected boolean isInterface(final Type type) {
if (currentClass != null && type.equals(currentClass)) { if (currentClass != null && currentClass.equals(type)) {
return isInterface; return isInterface;
} }
return getClass(type).isInterface(); return getClass(type).isInterface();
...@@ -306,7 +306,7 @@ public class SimpleVerifier extends BasicVerifier { ...@@ -306,7 +306,7 @@ public class SimpleVerifier extends BasicVerifier {
* @return the type corresponding to the super class of 'type'. * @return the type corresponding to the super class of 'type'.
*/ */
protected Type getSuperClass(final Type type) { protected Type getSuperClass(final Type type) {
if (currentClass != null && type.equals(currentClass)) { if (currentClass != null && currentClass.equals(type)) {
return currentSuperClass; return currentSuperClass;
} }
Class<?> superClass = getClass(type).getSuperclass(); Class<?> superClass = getClass(type).getSuperclass();
...@@ -329,7 +329,7 @@ public class SimpleVerifier extends BasicVerifier { ...@@ -329,7 +329,7 @@ public class SimpleVerifier extends BasicVerifier {
if (type1.equals(type2)) { if (type1.equals(type2)) {
return true; return true;
} }
if (currentClass != null && type1.equals(currentClass)) { if (currentClass != null && currentClass.equals(type1)) {
if (getSuperClass(type2) == null) { if (getSuperClass(type2) == null) {
return false; return false;
} else { } else {
...@@ -339,13 +339,12 @@ public class SimpleVerifier extends BasicVerifier { ...@@ -339,13 +339,12 @@ public class SimpleVerifier extends BasicVerifier {
return isAssignableFrom(type1, getSuperClass(type2)); return isAssignableFrom(type1, getSuperClass(type2));
} }
} }
if (currentClass != null && type2.equals(currentClass)) { if (currentClass != null && currentClass.equals(type2)) {
if (isAssignableFrom(type1, currentSuperClass)) { if (isAssignableFrom(type1, currentSuperClass)) {
return true; return true;
} }
if (currentClassInterfaces != null) { if (currentClassInterfaces != null) {
for (int i = 0; i < currentClassInterfaces.size(); ++i) { for (Type currentClassInterface : currentClassInterfaces) {
Type currentClassInterface = currentClassInterfaces.get(i);
if (isAssignableFrom(type1, currentClassInterface)) { if (isAssignableFrom(type1, currentClassInterface)) {
return true; return true;
} }
......
...@@ -168,10 +168,12 @@ final class SmallSet<T> extends AbstractSet<T> { ...@@ -168,10 +168,12 @@ final class SmallSet<T> extends AbstractSet<T> {
this.secondElement = secondElement; this.secondElement = secondElement;
} }
@Override
public boolean hasNext() { public boolean hasNext() {
return firstElement != null; return firstElement != null;
} }
@Override
public T next() { public T next() {
if (firstElement == null) { if (firstElement == null) {
throw new NoSuchElementException(); throw new NoSuchElementException();
......
...@@ -95,6 +95,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod ...@@ -95,6 +95,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
break; break;
default: default:
size = 1; size = 1;
break;
} }
return new SourceValue(size, insn); return new SourceValue(size, insn);
} }
...@@ -123,6 +124,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod ...@@ -123,6 +124,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
break; break;
default: default:
size = 1; size = 1;
break;
} }
return new SourceValue(size, insn); return new SourceValue(size, insn);
} }
...@@ -154,6 +156,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod ...@@ -154,6 +156,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
break; break;
default: default:
size = 1; size = 1;
break;
} }
return new SourceValue(size, insn); return new SourceValue(size, insn);
} }
......
...@@ -98,6 +98,7 @@ public class SourceValue implements Value { ...@@ -98,6 +98,7 @@ public class SourceValue implements Value {
* @return the size of this value, in 32 bits words. This size is 1 for byte, boolean, char, * @return the size of this value, in 32 bits words. This size is 1 for byte, boolean, char,
* short, int, float, object and array types, and 2 for long and double. * short, int, float, object and array types, and 2 for long and double.
*/ */
@Override
public int getSize() { public int getSize() {
return size; return size;
} }
......
...@@ -846,10 +846,10 @@ public class AnalyzerTest { ...@@ -846,10 +846,10 @@ public class AnalyzerTest {
Frame<BasicValue>[] frames = analyzer.analyze("C", this); Frame<BasicValue>[] frames = analyzer.analyze("C", this);
int actualMaxStack = 0; int actualMaxStack = 0;
int actualMaxLocals = 0; int actualMaxLocals = 0;
for (int i = 0; i < frames.length; ++i) { for (Frame<BasicValue> frame : frames) {
if (frames[i] != null) { if (frame != null) {
actualMaxStack = Math.max(actualMaxStack, frames[i].getStackSize()); actualMaxStack = Math.max(actualMaxStack, frame.getStackSize());
actualMaxLocals = Math.max(actualMaxLocals, frames[i].getLocals()); actualMaxLocals = Math.max(actualMaxLocals, frame.getLocals());
} }
} }
assertEquals(maxStack, actualMaxStack, "maxStack"); assertEquals(maxStack, actualMaxStack, "maxStack");
......
...@@ -33,8 +33,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; ...@@ -33,8 +33,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
...@@ -67,7 +68,7 @@ public class BasicInterpreterTest extends AsmTest { ...@@ -67,7 +68,7 @@ public class BasicInterpreterTest extends AsmTest {
public void testMergeWithJsrReachableFromTwoDifferentPaths() public void testMergeWithJsrReachableFromTwoDifferentPaths()
throws IOException, AnalyzerException { throws IOException, AnalyzerException {
ClassReader classReader = ClassReader classReader =
new ClassReader(new FileInputStream("src/test/resources/Issue316204.class")); new ClassReader(Files.newInputStream(Paths.get("src/test/resources/Issue316204.class")));
ClassNode classNode = new ClassNode(); ClassNode classNode = new ClassNode();
classReader.accept(classNode, 0); classReader.accept(classNode, 0);
Analyzer<BasicValue> analyzer = new Analyzer<>(new BasicInterpreter()); Analyzer<BasicValue> analyzer = new Analyzer<>(new BasicInterpreter());
......
...@@ -71,9 +71,9 @@ public class SimpleVerifierTest extends AsmTest implements Opcodes { ...@@ -71,9 +71,9 @@ public class SimpleVerifierTest extends AsmTest implements Opcodes {
methodNode.visitMaxs(10, 10); methodNode.visitMaxs(10, 10);
anaylzer.analyze("C", methodNode); anaylzer.analyze("C", methodNode);
Frame<?>[] frames = anaylzer.getFrames(); Frame<?>[] frames = anaylzer.getFrames();
for (int i = 0; i < frames.length; ++i) { for (Frame<?> frame : frames) {
if (frames[i] != null) { if (frame != null) {
frames[i].toString(); frame.toString();
} }
} }
anaylzer.getHandlers(0); anaylzer.getHandlers(0);
......
...@@ -46,10 +46,10 @@ public class ValueTest { ...@@ -46,10 +46,10 @@ public class ValueTest {
@Test @Test
public void testBasicValue() { public void testBasicValue() {
assertTrue(BasicValue.UNINITIALIZED_VALUE.equals(new BasicValue(null))); assertEquals(new BasicValue(null), BasicValue.UNINITIALIZED_VALUE);
assertTrue(BasicValue.INT_VALUE.equals(new BasicValue(Type.INT_TYPE))); assertEquals(new BasicValue(Type.INT_TYPE), BasicValue.INT_VALUE);
assertTrue(BasicValue.INT_VALUE.equals(BasicValue.INT_VALUE)); assertEquals(BasicValue.INT_VALUE, BasicValue.INT_VALUE);
assertFalse(BasicValue.INT_VALUE.equals(new Object())); assertNotEquals(new Object(), BasicValue.INT_VALUE);
assertTrue(BasicValue.REFERENCE_VALUE.isReference()); assertTrue(BasicValue.REFERENCE_VALUE.isReference());
assertTrue(new BasicValue(Type.getObjectType("[I")).isReference()); assertTrue(new BasicValue(Type.getObjectType("[I")).isReference());
...@@ -69,10 +69,10 @@ public class ValueTest { ...@@ -69,10 +69,10 @@ public class ValueTest {
public void testSourceValue() { public void testSourceValue() {
assertEquals(2, new SourceValue(2).getSize()); assertEquals(2, new SourceValue(2).getSize());
assertTrue(new SourceValue(1).equals(new SourceValue(1))); assertEquals(new SourceValue(1), new SourceValue(1));
assertFalse(new SourceValue(1).equals(new SourceValue(1, new InsnNode(Opcodes.NOP)))); assertNotEquals(new SourceValue(1), new SourceValue(1, new InsnNode(Opcodes.NOP)));
assertFalse(new SourceValue(1).equals(new SourceValue(2))); assertNotEquals(new SourceValue(1), new SourceValue(2));
assertFalse(new SourceValue(1).equals(null)); assertNotEquals(new SourceValue(1), null);
assertEquals(0, new SourceValue(1).hashCode()); assertEquals(0, new SourceValue(1).hashCode());
assertNotEquals(0, new SourceValue(1, new InsnNode(Opcodes.NOP)).hashCode()); assertNotEquals(0, new SourceValue(1, new InsnNode(Opcodes.NOP)).hashCode());
......
...@@ -554,8 +554,8 @@ public class AnalyzerAdapter extends MethodVisitor { ...@@ -554,8 +554,8 @@ public class AnalyzerAdapter extends MethodVisitor {
if (firstDescriptorChar == '(') { if (firstDescriptorChar == '(') {
int numSlots = 0; int numSlots = 0;
Type[] types = Type.getArgumentTypes(descriptor); Type[] types = Type.getArgumentTypes(descriptor);
for (int i = 0; i < types.length; ++i) { for (Type type : types) {
numSlots += types[i].getSize(); numSlots += type.getSize();
} }
pop(numSlots); pop(numSlots);
} else if (firstDescriptorChar == 'J' || firstDescriptorChar == 'D') { } else if (firstDescriptorChar == 'J' || firstDescriptorChar == 'D') {
......
...@@ -425,6 +425,7 @@ public class GeneratorAdapter extends LocalVariablesSorter { ...@@ -425,6 +425,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
break; break;
default: default:
mv.visitLdcInsn(value); mv.visitLdcInsn(value);
break;
} }
} }
} }
...@@ -915,6 +916,7 @@ public class GeneratorAdapter extends LocalVariablesSorter { ...@@ -915,6 +916,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
break; break;
default: default:
unboxMethod = null; unboxMethod = null;
break;
} }
if (unboxMethod == null) { if (unboxMethod == null) {
checkCast(type); checkCast(type);
......
...@@ -162,8 +162,7 @@ public class Method { ...@@ -162,8 +162,7 @@ public class Method {
} }
stringBuilder.append(argumentDescriptor); stringBuilder.append(argumentDescriptor);
} while (currentArgumentEndIndex != -1); } while (currentArgumentEndIndex != -1);
stringBuilder.append(')'); stringBuilder.append(')').append(getDescriptorInternal(returnType, defaultPackage));
stringBuilder.append(getDescriptorInternal(returnType, defaultPackage));
return new Method(methodName, stringBuilder.toString()); return new Method(methodName, stringBuilder.toString());
} }
......
...@@ -451,8 +451,7 @@ public class SerialVersionUIDAdder extends ClassVisitor { ...@@ -451,8 +451,7 @@ public class SerialVersionUIDAdder extends ClassVisitor {
final DataOutput dataOutputStream, final DataOutput dataOutputStream,
final boolean dotted) final boolean dotted)
throws IOException { throws IOException {
int size = itemCollection.size(); Item[] items = itemCollection.toArray(new Item[0]);
Item[] items = itemCollection.toArray(new Item[size]);
Arrays.sort( Arrays.sort(
items, items,
new Comparator<Item>() { new Comparator<Item>() {
......
...@@ -95,6 +95,7 @@ public class TryCatchBlockSorter extends MethodNode { ...@@ -95,6 +95,7 @@ public class TryCatchBlockSorter extends MethodNode {
tryCatchBlocks, tryCatchBlocks,
new Comparator<TryCatchBlockNode>() { new Comparator<TryCatchBlockNode>() {
@Override
public int compare( public int compare(
final TryCatchBlockNode tryCatchBlockNode1, final TryCatchBlockNode tryCatchBlockNode1,
final TryCatchBlockNode tryCatchBlockNode2) { final TryCatchBlockNode tryCatchBlockNode2) {
......
...@@ -417,6 +417,16 @@ public class AdviceAdapterTest extends AsmTest { ...@@ -417,6 +417,16 @@ public class AdviceAdapterTest extends AsmTest {
classWriter.visitField(Opcodes.ACC_STATIC, "f", "[[I", null, null); classWriter.visitField(Opcodes.ACC_STATIC, "f", "[[I", null, null);
MethodVisitor defaultConstructorVisitor =
classWriter.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
defaultConstructorVisitor.visitCode();
defaultConstructorVisitor.visitVarInsn(Opcodes.ALOAD, 0);
defaultConstructorVisitor.visitMethodInsn(
Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
defaultConstructorVisitor.visitInsn(Opcodes.RETURN);
defaultConstructorVisitor.visitMaxs(0, 0);
defaultConstructorVisitor.visitEnd();
String descriptor = "(I)V"; String descriptor = "(I)V";
MethodVisitor methodVisitor = MethodVisitor methodVisitor =
classWriter.visitMethod(Opcodes.ACC_PUBLIC, "<init>", descriptor, null, null); classWriter.visitMethod(Opcodes.ACC_PUBLIC, "<init>", descriptor, null, null);
......
...@@ -32,6 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; ...@@ -32,6 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.objectweb.asm.test.Assertions.assertThat; import static org.objectweb.asm.test.Assertions.assertThat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
...@@ -211,6 +212,8 @@ public class ClassRemapperTest extends AsmTest { ...@@ -211,6 +212,8 @@ public class ClassRemapperTest extends AsmTest {
static class UpperCaseRemapper extends Remapper { static class UpperCaseRemapper extends Remapper {
private static final Locale LOCALE = Locale.ENGLISH;
private final String internalClassName; private final String internalClassName;
private final String remappedInternalClassName; private final String remappedInternalClassName;
...@@ -219,7 +222,7 @@ public class ClassRemapperTest extends AsmTest { ...@@ -219,7 +222,7 @@ public class ClassRemapperTest extends AsmTest {
this.remappedInternalClassName = this.remappedInternalClassName =
internalClassName.equals("module-info") internalClassName.equals("module-info")
? internalClassName ? internalClassName
: internalClassName.toUpperCase(); : internalClassName.toUpperCase(LOCALE);
} }
String getRemappedClassName() { String getRemappedClassName() {
...@@ -245,17 +248,17 @@ public class ClassRemapperTest extends AsmTest { ...@@ -245,17 +248,17 @@ public class ClassRemapperTest extends AsmTest {
if (name.equals("<init>") || name.equals("<clinit>")) { if (name.equals("<init>") || name.equals("<clinit>")) {
return name; return name;
} }
return owner.equals(internalClassName) ? name.toUpperCase() : name; return owner.equals(internalClassName) ? name.toUpperCase(LOCALE) : name;
} }
@Override @Override
public String mapInvokeDynamicMethodName(final String name, final String descriptor) { public String mapInvokeDynamicMethodName(final String name, final String descriptor) {
return name.toUpperCase(); return name.toUpperCase(LOCALE);
} }
@Override @Override
public String mapFieldName(final String owner, final String name, final String descriptor) { public String mapFieldName(final String owner, final String name, final String descriptor) {
return owner.equals(internalClassName) ? name.toUpperCase() : name; return owner.equals(internalClassName) ? name.toUpperCase(LOCALE) : name;
} }
@Override @Override
......
...@@ -31,9 +31,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; ...@@ -31,9 +31,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.objectweb.asm.test.Assertions.assertThat; import static org.objectweb.asm.test.Assertions.assertThat;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
...@@ -137,7 +138,7 @@ public class LocalVariablesSorterTest extends AsmTest { ...@@ -137,7 +138,7 @@ public class LocalVariablesSorterTest extends AsmTest {
@Test @Test
public void testSortLocalVariablesAndInstantiate() throws FileNotFoundException, IOException { public void testSortLocalVariablesAndInstantiate() throws FileNotFoundException, IOException {
ClassReader classReader = ClassReader classReader =
new ClassReader(new FileInputStream("src/test/resources/Issue317586.class")); new ClassReader(Files.newInputStream(Paths.get("src/test/resources/Issue317586.class")));
ClassWriter classWriter = new ClassWriter(0); ClassWriter classWriter = new ClassWriter(0);
ClassVisitor classVisitor = ClassVisitor classVisitor =
new ClassVisitor(Opcodes.ASM7, classWriter) { new ClassVisitor(Opcodes.ASM7, classWriter) {
......
...@@ -29,9 +29,8 @@ package org.objectweb.asm.commons; ...@@ -29,9 +29,8 @@ package org.objectweb.asm.commons;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
...@@ -102,14 +101,14 @@ public class MethodTest { ...@@ -102,14 +101,14 @@ public class MethodTest {
@Test @Test
public void testEquals() { public void testEquals() {
assertFalse(new Method("name", "()V").equals(null)); assertNotEquals(new Method("name", "()V"), null);
assertFalse(new Method("name", "()V").equals(new Method("other", "()V"))); assertNotEquals(new Method("name", "()V"), new Method("other", "()V"));
assertFalse(new Method("name", "()V").equals(new Method("name", "(I)J"))); assertNotEquals(new Method("name", "()V"), new Method("name", "(I)J"));
assertTrue(new Method("name", "()V").equals(Method.getMethod("void name()"))); assertEquals(new Method("name", "()V"), Method.getMethod("void name()"));
} }
@Test @Test
public void testHashCode() { public void testHashCode() {
assertTrue(new Method("name", "()V").hashCode() != 0); assertNotEquals(0, new Method("name", "()V").hashCode());
} }
} }
...@@ -34,7 +34,9 @@ import java.io.Serializable; ...@@ -34,7 +34,9 @@ import java.io.Serializable;
* *
* @author Eric Bruneton * @author Eric Bruneton
*/ */
class SerialVersionAnonymousInnerClass implements Serializable { class SerialVersionAnonymousInnerClass implements Serializable { // NOPMD(MissingSerialVersionUID)
// No serial version UID on purpose, to test SerialVersionUIDAdder.
public static final SerialVersionAnonymousInnerClass anonymousInnerClass = public static final SerialVersionAnonymousInnerClass anonymousInnerClass =
new SerialVersionAnonymousInnerClass() {}; new SerialVersionAnonymousInnerClass() {};
......
...@@ -34,11 +34,14 @@ import java.io.Serializable; ...@@ -34,11 +34,14 @@ import java.io.Serializable;
* *
* @author Eric Bruneton * @author Eric Bruneton
*/