Commit 6359986e authored by Eric Bruneton's avatar Eric Bruneton

Make the tests pass on Java 11.

parent 9314ae71
Pipeline #6648 passed with stage
in 9 minutes and 49 seconds
......@@ -125,6 +125,7 @@ public abstract class AsmTest {
JDK11_ALL_STRUCTURES_NESTED("jdk11.AllStructures$Nested");
private final String name;
private byte[] bytes;
PrecompiledClass(final String name) {
this.name = name;
......@@ -189,7 +190,10 @@ public abstract class AsmTest {
* @return the content of this class.
*/
public byte[] getBytes() {
return AsmTest.getBytes(name);
if (bytes == null) {
bytes = AsmTest.getBytes(name);
}
return bytes.clone();
}
@Override
......
......@@ -37,7 +37,7 @@ package jdk11;
* @author Eric Bruneton
*/
super public class AllInstructions
version 55:65535
version 55:0
{
......
// class version 55.65535 (-65481)
// class version 55.0 (55)
// access flags 0x21
public class jdk11/AllInstructions {
......
......@@ -42,6 +42,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.params.ParameterizedTest;
......@@ -418,7 +420,8 @@ public class ClassReaderTest extends AsmTest implements Opcodes {
|| invalidClass == InvalidClass.INVALID_CONSTANT_POOL_REFERENCE
|| invalidClass == InvalidClass.INVALID_BYTECODE_OFFSET) {
Exception exception = assertThrows(ArrayIndexOutOfBoundsException.class, accept);
assertTrue(Integer.valueOf(exception.getMessage()) > 0);
Matcher matcher = Pattern.compile("\\d+").matcher(exception.getMessage());
assertTrue(matcher.find() && Integer.valueOf(matcher.group()) > 0);
} else {
assertThrows(IllegalArgumentException.class, accept);
}
......@@ -545,7 +548,11 @@ public class ClassReaderTest extends AsmTest implements Opcodes {
@Test
public void testAccept_previewClass() {
ClassReader classReader = new ClassReader(PrecompiledClass.JDK11_ALL_INSTRUCTIONS.getBytes());
byte[] classFile = PrecompiledClass.JDK11_ALL_INSTRUCTIONS.getBytes();
// Set the minor version to 65535.
classFile[4] = (byte) 0xFF;
classFile[5] = (byte) 0xFF;
ClassReader classReader = new ClassReader(classFile);
AtomicInteger classVersion = new AtomicInteger(0);
ClassVisitor readVersionVisitor =
new ClassVisitor(Opcodes.ASM7) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment