diff --git a/pom.xml b/pom.xml index 0c738b0965..7359e6fa74 100644 --- a/pom.xml +++ b/pom.xml @@ -399,10 +399,10 @@ - org.codehaus.mojo - taglist-maven-plugin - 3.0.0 - + org.codehaus.mojo + taglist-maven-plugin + 3.0.0 + TODO NOPMD diff --git a/src/main/java/org/apache/bcel/classfile/ConstantPool.java b/src/main/java/org/apache/bcel/classfile/ConstantPool.java index d4d2416abe..e94f35dde5 100644 --- a/src/main/java/org/apache/bcel/classfile/ConstantPool.java +++ b/src/main/java/org/apache/bcel/classfile/ConstantPool.java @@ -317,13 +317,8 @@ public T getConstant(final int index, final Class castTo } // Previous check ensures this won't throw a ClassCastException final T c = castTo.cast(constantPool[index]); - if (c == null - // the 0th element is always null - && index != 0) { - final Constant prev = constantPool[index - 1]; - if (prev == null || prev.getTag() != Const.CONSTANT_Double && prev.getTag() != Const.CONSTANT_Long) { - throw new ClassFormatException("Constant pool at index " + index + " is null."); - } + if (c == null) { + throw new ClassFormatException("Constant pool at index " + index + " is null."); } return c; } diff --git a/src/main/java/org/apache/bcel/classfile/StackMapType.java b/src/main/java/org/apache/bcel/classfile/StackMapType.java index 81dbc162d2..6a60e204d1 100644 --- a/src/main/java/org/apache/bcel/classfile/StackMapType.java +++ b/src/main/java/org/apache/bcel/classfile/StackMapType.java @@ -33,8 +33,6 @@ public final class StackMapType implements Node, Cloneable { public static final StackMapType[] EMPTY_ARRAY = {}; // BCELifier code generator writes calls to constructor translating null to EMPTY_ARRAY - public static final StackMapType[] EMPTY_ARRAY = {}; // must be public because BCELifier code generator writes calls to it - private byte type; private int index = -1; // Index to CONSTANT_Class or offset private ConstantPool constantPool; diff --git a/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java b/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java index 6ecf0c2c43..3c154facb1 100644 --- a/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/ConstantPoolTestCase.java @@ -24,9 +24,6 @@ import java.io.IOException; -import java.io.IOException; -import java.util.stream.IntStream; - import org.apache.bcel.AbstractTestCase; import org.apache.bcel.Const; import org.apache.bcel.generic.ConstantPoolGen; diff --git a/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java b/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java index 357460ed53..8c3144b66e 100644 --- a/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java +++ b/src/test/java/org/apache/bcel/classfile/UtilityTestCase.java @@ -27,7 +27,6 @@ import org.apache.bcel.Const; import org.apache.bcel.Repository; import org.junit.jupiter.api.Test; -import java.util.Arrays; public class UtilityTestCase { @@ -173,44 +172,4 @@ public void testSignatureToStringWithGenerics() throws Exception { assertEquals(" extends Object", Utility.signatureToString("Ljava/lang/Object;"), "class signature"); } - - @Test - public void testCodeToString() throws Exception { - class CodeToString { - int[][] a = new int[0][0]; - - CodeToString() { - if (a instanceof int[][]) { - System.out.print(Arrays.asList(a).size()); - } - } - } - final JavaClass javaClass = Repository.lookupClass(CodeToString.class); - assertNotNull(javaClass); - for (final Method method : javaClass.getMethods()) { - assertEquals("", method.getName()); - final String code = method.getCode().toString(false); - assertTrue(code.contains("0: aload_0"), code); - assertTrue(code.contains("1: aload_1"), code); - assertTrue(code.contains("2: putfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.this$0 Lorg/apache/bcel/classfile/UtilityTestCase;"), code); - assertTrue(code.contains("5: aload_0"), code); - assertTrue(code.contains("6: invokespecial\tjava.lang.Object. ()V"), code); - assertTrue(code.contains("9: aload_0"), code); - assertTrue(code.contains("10: iconst_0"), code); - assertTrue(code.contains("11: iconst_0"), code); - assertTrue(code.contains("12: multianewarray\t<[[I>\t2"), code); - assertTrue(code.contains("16: putfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code); - assertTrue(code.contains("19: aload_0"), code); - assertTrue(code.contains("20: getfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code); - assertTrue(code.contains("23: instanceof\t<[[I>"), code); - assertTrue(code.contains("26: ifeq\t\t#47"), code); - assertTrue(code.contains("29: getstatic\t\tjava.lang.System.out Ljava/io/PrintStream;"), code); - assertTrue(code.contains("32: aload_0"), code); - assertTrue(code.contains("33: getfield\t\torg.apache.bcel.classfile.UtilityTestCase$1CodeToString.a [[I"), code); - assertTrue(code.contains("36: invokestatic\tjava.util.Arrays.asList ([Ljava/lang/Object;)Ljava/util/List;"), code); - assertTrue(code.contains("39: invokeinterface\tjava.util.List.size ()I1\t0"), code); - assertTrue(code.contains("44: invokevirtual\tjava.io.PrintStream.print (I)V"), code); - assertTrue(code.contains("47: return"), code); - } - } } diff --git a/src/test/java/org/apache/bcel/generic/JavaHome.java b/src/test/java/org/apache/bcel/generic/JavaHome.java index f23be5537a..e4d04d45ba 100644 --- a/src/test/java/org/apache/bcel/generic/JavaHome.java +++ b/src/test/java/org/apache/bcel/generic/JavaHome.java @@ -68,7 +68,7 @@ public class JavaHome { private static Stream find(final Path start, final int maxDepth, final BiPredicate matcher, final FileVisitOption... options) { - // TODO Apache Commons 2.14.0: Use FilesUncheck + // TODO Apache Commons 2.14.0: Use FilesUncheck return Files.exists(start) ? Uncheck.apply(Files::find, start, maxDepth, matcher, options) : Stream.empty(); }