Skip to content

Commit

Permalink
correct merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
markro49 committed Jan 6, 2024
1 parent 0e785d6 commit 92ac96e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 58 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<tags>
<tag>TODO</tag>
<tag>NOPMD</tag>
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/org/apache/bcel/classfile/ConstantPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,8 @@ public <T extends Constant> T getConstant(final int index, final Class<T> 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;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/apache/bcel/classfile/StackMapType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
41 changes: 0 additions & 41 deletions src/test/java/org/apache/bcel/classfile/UtilityTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -173,44 +172,4 @@ public void testSignatureToStringWithGenerics() throws Exception {
assertEquals("<K extends Object, V extends Object> extends Object",
Utility.signatureToString("<K:Ljava/lang/Object;V:Ljava/lang/Object;>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("<init>", 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.<init> ()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);
}
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/apache/bcel/generic/JavaHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class JavaHome {

private static Stream<Path> find(final Path start, final int maxDepth, final BiPredicate<Path, BasicFileAttributes> 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();
}

Expand Down

0 comments on commit 92ac96e

Please sign in to comment.