Skip to content

Commit

Permalink
test: unknown case
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 committed Aug 9, 2024
1 parent 4b288e5 commit 7166d75
Show file tree
Hide file tree
Showing 11 changed files with 602 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -209,6 +210,47 @@ void shouldShowNoDifferenceInBytecode() throws IOException {
assertThat(rootOperations).size().isEqualTo(0);
}
}

@Nested
class DiffComp {
@Disabled(
"This test is disabled because I have to check why gumtree gives so many changes even though the bytecode should be equivalent.")
@Test
void shouldShowNoDifferenceInBytecode_1() throws IOException {
// arrange
Path oldClass = EQ.resolve("DiffComp")
.resolve("82141")
.resolve("openjdk-17.0.1")
.resolve("TapeInputStream.class");
Path newClass = EQ.resolve("DiffComp")
.resolve("82141")
.resolve("ecj-3.28.0_openjdk-11.0.19")
.resolve("TapeInputStream.class");
DiffImpl diff = getDiff(oldClass, newClass);

// assert
List<Action> rootOperations = diff.getRootOperations();
assertThat(rootOperations).size().isEqualTo(1);
}

@Disabled("Unclear why there is a difference.")
@Test
void shouldShowNoDifferenceInBytecode_2() throws IOException {
Path oldClass = EQ.resolve("DiffComp")
.resolve("82138")
.resolve("openjdk-17.0.1")
.resolve("DumpArchiveUtil.class");
Path newClass = EQ.resolve("DiffComp")
.resolve("82138")
.resolve("ecj-3.28.0_openjdk-11.0.19")
.resolve("DumpArchiveUtil.class");
DiffImpl diff = getDiff(oldClass, newClass);

// assert
List<Action> rootOperations = diff.getRootOperations();
assertThat(rootOperations).size().isEqualTo(1);
}
}
}

private static DiffImpl getDiff(Path oldClass, Path newClass) throws IOException {
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/EQ/DiffComp/82138/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Unclear what is happening.
Both diff are bad for a known equivalent bytecode.
396 changes: 396 additions & 0 deletions src/test/resources/EQ/DiffComp/82138/diffoscope.diff

Large diffs are not rendered by default.

Binary file not shown.
27 changes: 27 additions & 0 deletions src/test/resources/EQ/DiffComp/82138/gumtree.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[===
insert-node
---
IRETURN [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 18, ===
move-tree
---
ILOAD_2: IntType [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 11, ===
move-tree
---
SIPUSH [0,0]
ShortType: 256 [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 11, ===
move-tree
---
ICONST_0 [0,0]
IntType: 0 [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 17]
Binary file not shown.
2 changes: 2 additions & 0 deletions src/test/resources/EQ/DiffComp/82141/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Unclear what is happening here.
Diffoscope shows some spurious diff but gumtree is also failing in this case.
45 changes: 45 additions & 0 deletions src/test/resources/EQ/DiffComp/82141/diffoscope.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--- openjdk-17.0.1/TapeInputStream.class
+++ ecj-3.28.0_openjdk-11.0.19/TapeInputStream.class
├── procyon -ec {}
│ @@ -123,36 +123,37 @@
│ int length = h >> 4 & 0xFFFFFFF;
│ final byte[] compBuffer = this.readRange(length);
│ this.bytesRead += length;
│ if (!decompress) {
│ Arrays.fill(this.blockBuffer, (byte)0);
│ }
│ else {
│ - switch (TapeInputStream.TapeInputStream$1.$SwitchMap$org$apache$commons$compress$archivers$dump$DumpArchiveConstants$COMPRESSION_TYPE[DumpArchiveConstants.COMPRESSION_TYPE.find(flags & 0x3).ordinal()]) {
│ - case 1: {
│ + switch (DumpArchiveConstants.COMPRESSION_TYPE.find(flags & 0x3)) {
│ + case ZLIB: {
│ final Inflater inflator = new Inflater();
│ try {
│ inflator.setInput(compBuffer, 0, compBuffer.length);
│ length = inflator.inflate(this.blockBuffer);
│ if (length != this.blockSize) {
│ throw new ShortFileException();
│ }
│ }
│ catch (final DataFormatException e) {
│ throw new DumpArchiveException("Bad data", (Throwable)e);
│ }
│ finally {
│ inflator.end();
│ }
│ + inflator.end();
│ break;
│ }
│ - case 2: {
│ + case BZLIB: {
│ throw new UnsupportedCompressionAlgorithmException("BZLIB2");
│ }
│ - case 3: {
│ + case LZO: {
│ throw new UnsupportedCompressionAlgorithmException("LZO");
│ }
│ default: {
│ throw new UnsupportedCompressionAlgorithmException();
│ }
│ }
│ }
Binary file not shown.
88 changes: 88 additions & 0 deletions src/test/resources/EQ/DiffComp/82141/gumtree.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[===
update-node
---
METHOD_INVOKED_RETURN_TYPE: ()V [0,0]
replace ()V by (Ljava/lang/String;)V, ===
delete-node
---
GETSTATIC [0,0]
===, ===
delete-node
---
INVOKEVIRTUAL [0,0]
===, ===
insert-node
---
java.lang.classfile.FieldModel [0,0]
to
root [0,5945]
at 9, ===
insert-node
---
java.lang.classfile.MethodModel [0,0]
to
root [0,5945]
at 23, ===
insert-node
---
INVOKESTATIC [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 82, ===
move-tree
---
ILOAD_3: IntType [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 58, ===
move-tree
---
ILOAD: IntType [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 58, ===
move-tree
---
INVOKEVIRTUAL [0,0]
METHOD_OWNER: java/util/zip/Inflater [0,0]
METHOD_INVOKED_NAME: end [0,0]
METHOD_INVOKED_RETURN_TYPE: ()V [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 116, ===
move-tree
---
ALOAD: ReferenceType [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 118, ===
move-tree
---
INVOKEVIRTUAL [0,0]
METHOD_OWNER: java/util/zip/Inflater [0,0]
METHOD_INVOKED_NAME: end [0,0]
METHOD_INVOKED_RETURN_TYPE: ()V [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 118, ===
move-tree
---
INVOKESPECIAL [0,0]
METHOD_OWNER: java/lang/StringBuilder [0,0]
METHOD_INVOKED_NAME: <init> [0,0]
METHOD_INVOKED_RETURN_TYPE: ()V [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 10, ===
move-tree
---
LLOAD_1: LongType [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 51, ===
move-tree
---
LLOAD_3: LongType [0,0]
to
java.lang.classfile.CodeModel: CodeModel [0,0]
at 51]
Binary file not shown.

0 comments on commit 7166d75

Please sign in to comment.