From 0b61bb7ee82a36141feb89ae772a2c6769a7beec Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Wed, 12 Apr 2023 13:15:19 +0200 Subject: [PATCH] simplify BytecodeVersionTest.verifyMagic --- .../java/org/jboss/jandex/test/BytecodeVersionTest.java | 9 +++------ .../java/org/jboss/jandex/maven/BytecodeVersionTest.java | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/core/src/test/java/org/jboss/jandex/test/BytecodeVersionTest.java b/core/src/test/java/org/jboss/jandex/test/BytecodeVersionTest.java index c1cb9d9c..21c57a4f 100644 --- a/core/src/test/java/org/jboss/jandex/test/BytecodeVersionTest.java +++ b/core/src/test/java/org/jboss/jandex/test/BytecodeVersionTest.java @@ -6,7 +6,6 @@ import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -30,11 +29,9 @@ public void verifyJava8() throws IOException { } private void verifyMagic(DataInputStream stream) throws IOException { - byte[] buf = new byte[4]; - - stream.readFully(buf); - if (buf[0] != (byte) 0xCA || buf[1] != (byte) 0xFE || buf[2] != (byte) 0xBA || buf[3] != (byte) 0xBE) { - fail("Invalid magic value: " + Arrays.toString(buf)); + int magic = stream.readInt(); + if (magic != 0xCA_FE_BA_BE) { + fail("Invalid magic value: " + Integer.toHexString(magic)); } } diff --git a/maven-plugin/src/test/java/org/jboss/jandex/maven/BytecodeVersionTest.java b/maven-plugin/src/test/java/org/jboss/jandex/maven/BytecodeVersionTest.java index dcad1d86..5e00869f 100644 --- a/maven-plugin/src/test/java/org/jboss/jandex/maven/BytecodeVersionTest.java +++ b/maven-plugin/src/test/java/org/jboss/jandex/maven/BytecodeVersionTest.java @@ -6,7 +6,6 @@ import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -30,11 +29,9 @@ public void verifyJava8() throws IOException { } private void verifyMagic(DataInputStream stream) throws IOException { - byte[] buf = new byte[4]; - - stream.readFully(buf); - if (buf[0] != (byte) 0xCA || buf[1] != (byte) 0xFE || buf[2] != (byte) 0xBA || buf[3] != (byte) 0xBE) { - fail("Invalid magic value: " + Arrays.toString(buf)); + int magic = stream.readInt(); + if (magic != 0xCA_FE_BA_BE) { + fail("Invalid magic value: " + Integer.toHexString(magic)); } }