Commit ba49829a authored by Eric Bruneton's avatar Eric Bruneton

Add more tests with invalid classes and a synthetic class using the swap instruction.

parent 9933fac0
Pipeline #471 passed with stage
in 10 minutes and 32 seconds
......@@ -110,6 +110,7 @@ public abstract class AsmTest {
JDK3_INNER_CLASS("jdk3.AllStructures$InnerClass"),
JDK3_LARGE_METHOD("jdk3.LargeMethod"),
JDK3_STACK_MAP_ATTRIBUTE("jdk3.StackMapAttribute"),
JDK3_SWAP("jdk3.Swap"),
JDK5_ALL_INSTRUCTIONS("jdk5.AllInstructions"),
JDK5_ALL_STRUCTURES("jdk5.AllStructures"),
JDK5_ANNOTATION("jdk5.AllStructures$InvisibleAnnotation"),
......@@ -190,13 +191,15 @@ public abstract class AsmTest {
INVALID_BYTECODE_OFFSET("invalid.InvalidBytecodeOffset"),
INVALID_CLASS_VERSION("invalid.InvalidClassVersion"),
INVALID_CONSTANT_POOL_INDEX("invalid.InvalidConstantPoolIndex"),
INVALID_CONSTANT_POOL_REFERENCE("invalid.InvalidConstantPoolReference"),
INVALID_CP_INFO_TAG("invalid.InvalidCpInfoTag"),
INVALID_ELEMENT_VALUE("invalid.InvalidElementValue"),
INVALID_INSN_TYPE_ANNOTATION_TARGET_TYPE("invalid.InvalidInsnTypeAnnotationTargetType"),
INVALID_OPCODE("invalid.InvalidOpcode"),
INVALID_STACK_MAP_FRAME_TYPE("invalid.InvalidStackMapFrameType"),
INVALID_TYPE_ANNOTATION_TARGET_TYPE("invalid.InvalidTypeAnnotationTargetType"),
INVALID_VERIFICATION_TYPE_INFO("invalid.InvalidVerificationTypeInfo");
INVALID_VERIFICATION_TYPE_INFO("invalid.InvalidVerificationTypeInfo"),
INVALID_WIDE_OPCODE("invalid.InvalidWideOpcode");
private final String name;
......
// ASM: a very small and fast Java bytecode manipulation framework
// Copyright (c) 2000-2011 INRIA, France Telecom
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holders nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
package invalid;
public class InvalidConstantPoolReference {}
// ASM: a very small and fast Java bytecode manipulation framework
// Copyright (c) 2000-2011 INRIA, France Telecom
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holders nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
package invalid;
public class InvalidWideOpcode {
public int m(int i) {
i += 1024;
return i;
}
}
......@@ -108,6 +108,7 @@ public class AsmTestTest extends AsmTest {
case JDK3_INNER_CLASS:
case JDK3_LARGE_METHOD:
case JDK3_STACK_MAP_ATTRIBUTE:
case JDK3_SWAP:
case JDK5_ALL_INSTRUCTIONS:
case JDK5_ALL_STRUCTURES:
case JDK5_ENUM:
......@@ -152,6 +153,7 @@ public class AsmTestTest extends AsmTest {
case JDK3_INNER_CLASS:
case JDK3_LARGE_METHOD:
case JDK3_STACK_MAP_ATTRIBUTE:
case JDK3_SWAP:
case JDK5_ALL_INSTRUCTIONS:
case JDK5_ALL_STRUCTURES:
case JDK5_ENUM:
......
......@@ -1454,10 +1454,25 @@ public class ClassReader {
currentOffset += 5;
break;
case Constants.WIDE:
if ((classFileBuffer[currentOffset + 1] & 0xFF) == Opcodes.IINC) {
currentOffset += 6;
} else {
currentOffset += 4;
switch (classFileBuffer[currentOffset + 1] & 0xFF) {
case Constants.ILOAD:
case Constants.FLOAD:
case Constants.ALOAD:
case Constants.LLOAD:
case Constants.DLOAD:
case Constants.ISTORE:
case Constants.FSTORE:
case Constants.ASTORE:
case Constants.LSTORE:
case Constants.DSTORE:
case Constants.RET:
currentOffset += 4;
break;
case Constants.IINC:
currentOffset += 6;
break;
default:
throw new IllegalArgumentException();
}
break;
case Constants.TABLESWITCH:
......
......@@ -307,6 +307,7 @@ public class ClassReaderTest extends AsmTest implements Opcodes {
} else {
ClassReader classReader = new ClassReader(invalidClass.getBytes());
if (invalidClass == InvalidClass.INVALID_CONSTANT_POOL_INDEX
|| invalidClass == InvalidClass.INVALID_CONSTANT_POOL_REFERENCE
|| invalidClass == InvalidClass.INVALID_BYTECODE_OFFSET) {
assertThrows(
ArrayIndexOutOfBoundsException.class,
......
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