/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* @test Test7116786
* @summary verify that VerifyError messages are as expected
* @library testcases.jar
*/
/**
* This class contains information regarding when a VerifyError is thrown
* in the verifier. Most of the data is informational-only, and can be
* used to track down where and why VerifyErrors are thrown. As such it
* is possible the information may go out-of-date.
*
* The only fields used for the purpose of testing is the 'caseName' and
* the 'message'. The 'caseName' corresponds to a classfile which exhibits
* the VerifyError, and the 'message' is a regular expression which we expect
* to match the verify error message. If the 'message' doesn't match what
* we expect, it warrents investigation to see if we are still triggering
* the VerifyError that we expect. It could simply just be that the message
* changed, which is fine.
*
* Some cases are not testable, either because the code is probably unreachable
* or the test classfile would be too onerous to create. These cases are
* marked with 'testable' == false, and the test runner will skip them.
*/
class Case {
this.description = description;
}
}
/**
* These are the locations in the source code where VerifyErrors are thrown
* as of today, 2012/07/18. These may change as the verification code is
* modified, which is ok. This test is trying to provide coverage for all
* VerifyErrors (just to make sure there are no crashes) and it's probably
* not necessary to update it every time the VM changes.
*/
class VerifyErrorCases {
"stack underflow",
"Operand stack underflow"),
"stack pop not assignable to expected",
"Bad type on operand stack"),
"local index out-of-bounds",
"Local variable table overflow"),
"local not assignable to expected",
"Bad local variable type"),
"local index out-of-bounds [type2]",
"local not assignabled to expected [type2]",
"Bad local variable type"),
"local second-word not assignabled to expected",
"Bad local variable type"),
"local index out-of-bounds",
"Local variable table overflow"),
"local index out-of-bounds [type2]",
"Local variable table overflow"),
"stack overflow",
"Operand stack overflow"),
"stack overflow [type2]",
"Operand stack overflow"),
"stack underflow",
"Operand stack underflow"),
"stackmap offset beyond code size",
"StackMapTable error: bad offset"),
"no stackmap frame at expected location",
"Expecting a stackmap frame at branch target "),
"no stackmap frame at jump location or bad jump",
"Inconsistent stackmap frames at branch target "),
"backward jump with uninit",
"Uninitialized object exists on backward branch "),
/* Unreachable: wide instructions verified during bytecode analysis */
"bad op in wide instruction",
"Bad wide instruction"),
"TOS not X array",
"Bad type on operand stack in iaload"),
"TOS not X array",
"Bad type on operand stack in baload"),
"TOS not X array",
"Bad type on operand stack in caload"),
"TOS not X array",
"Bad type on operand stack in saload"),
"TOS not X array",
"Bad type on operand stack in laload"),
"TOS not X array",
"Bad type on operand stack in faload"),
"TOS not X array",
"Bad type on operand stack in daload"),
"TOS not X array",
"Bad type on operand stack in aaload"),
"TOS not int array",
"Bad type on operand stack in iastore"),
"TOS not byte array",
"Bad type on operand stack in bastore"),
"TOS not char array",
"Bad type on operand stack in castore"),
"TOS not short array",
"Bad type on operand stack in sastore"),
"TOS not long array",
"Bad type on operand stack in lastore"),
"TOS not float array",
"Bad type on operand stack in fastore"),
"TOS not double array",
"Bad type on operand stack in dastore"),
"TOS not object array",
"Bad type on operand stack in aastore"),
/* Unreachable: In order to hit this case, we would need a
* category2_1st at TOS which is not possible. */
"TOS is category2_1st (would split)",
"Bad type on operand stack in pop2"),
/* Unreachable: In order to hit this case, we would need a
* category2_1st at stack depth 2 with category_1 on TOS which is not
* possible. */
"TOS-1 is category2_1st (would split)",
"Bad type on operand stack in dup_x2"),
/* Unreachable: In order to hit this case, we would need a
* category2_1st at TOS which is not possible. */
"TOS-1 is category2_1st (would split)",
"Bad type on operand stack in dup2"),
/* Unreachable: In order to hit this case, we would need a
* category2_1st at TOS which is not possible. */
"TOS-1 is category2_1st (would split)",
"Bad type on operand stack in dup2_x1"),
/* Unreachable: In order to hit this case, we would need a
* category2_1st at TOS which is not possible. */
"TOS-1 is category2_1st (would split)",
"Bad type on operand stack in dup2_x2"),
/* Unreachable: In order to hit this case, we would need a
* category2_1st at stack depth 3 with either 2 category_1 or 1
* category_2 on TOS, which is not possible. */
"TOS-3 is category2_1st (would split)",
"Bad type on operand stack in dup2_x2"),
"return type of method is not void",
"Method expects a return value"),
"return with uninitialized this ",
"Constructor must call super() or this() before return"),
"cp index not a class type",
"Illegal new instruction"),
"TOS is not an array",
"Bad type on operand stack in arraylength"),
"CP index does not refer to array type",
"Illegal constant pool index in multianewarray instruction"),
"Bad dimension (<1) or does not match CP signature",
"Illegal dimension in multianewarray instruction: "),
"Unrecognized bytecode",
"Bad instruction: "),
"control flow falls off method",
"Control flow falls through code end"),
"illegal bytecode via RawBytecodeStream (breakpoint)",
"Bad instruction"),
"illegal bytecode via RawBytecodeStream (other illegal)",
"Bad instruction"),
"verify_exception_handler_table",
"catch_type is not throwable",
"Catch type is not a subclass of Throwable in " +
"exception handler "),
"missing a stack map frame @ target location (mid table)",
"Expecting a stack map frame"),
"stack map does not match?",
"Instruction type does not match stack map"),
"missing a stack map frame @ target location (end of table)",
"Expecting a stack map frame"),
"verify_exception_handler_targets",
"stackmap mismatch at exception handler",
"Stack map does not match the one at exception handler "),
"constant pool index is out-of-bounds",
"Illegal constant pool index "),
"constant pool entry is not expected type",
"Illegal type at constant pool entry "),
"constant pool entry is not an object type",
"Illegal type at constant pool entry "),
/* Unreachable: verify_cp_type gates this case */
"invalid constant pool index in ldc",
"Invalid index in ldc"),
"bad switch padding",
"Nonzero padding byte in lookswitch or tableswitch"),
"tableswitch low is greater than high",
"low must be less than or equal to high in tableswitch"),
/* Unreachable on 64-bit? Only way to get here is to overflow
* the 'keys' variable which can't happen on 64-bit since we're dealing
* with 32-bit values. Perhaps reachable on 32-bit but the
* triggering class would be quite large */
"high - low + 1 < 0 (overflow?)",
"too many keys in tableswitch"),
/* Would have to create a 16G classfile to trip this. Possible but
* not reasonable to do in a test. */
"lookupswitch keys < 0",
"number of keys in lookupswitch less than 0"),
"lookupswitch keys out-of-order",
"Bad lookupswitch instruction"),
/* Unreachable: Class file parser verifies Fieldref contents */
"referenced class is not an CP object",
"Expecting reference to class in class "),
"TOS not assignable to field type in putfield",
"Bad type on operand stack in putfield"),
"TOS not assignable to class when accessing protected field",
"Bad access to protected data in getfield"),
"Uninit_this is not of the current type or it's supertype",
"Bad <init> method call"),
/* Unreachable: Stack map parsing ensures valid type and new
* instructions have a valid BCI. */
"Uninit type with bad new instruction index",
"Expecting new instruction"),
"calling other class's <init> method",
"Call to wrong <init> method"),
"Calling protected <init> and type unassignable from current",
"Bad access to protected <init> method"),
"TOS is not an uninitialized (or Uninit_this) type",
"Bad operand type when invoking <init>"),
"Arg count in instruction doesn't match signature",
"Inconsistent args count operand in invokeinterface"),
"Non-zero pad in invokeinterface",
"Fourth operand byte of invokeinterface must be zero"),
"Non-zero pad in invokedynamic",
"Third and fourth operand bytes of " +
"invokedynamic must be zero"),
"Non-invokespecial trying to invoke a '<' method",
"Illegal call to internal method"),
"invokespecial and current unassignable from referenced type",
"Bad invokespecial instruction: current class isn't " +
"assignable to reference class."),
"TOS not assignable to current when calling protected method",
"Bad access to protected data in invokevirtual"),
/* Unreachable: class file parser enforces void signature */
"<init> method is not void return",
"Return type must be void in <init> method"),
"newarray type invalid",
"Illegal newarray instruction"),
"void return from method which has a return value",
"Method expects a return value"),
"TOS type does not match signature",
"Bad return type"),
"stack map does not match (flags)",
"Instruction type does not match stack map")
};
}
public class Test7116786 {
if (c.isTestable()) {
try {
throw new RuntimeException(
"++ FAIL: No verify error encountered");
} catch (VerifyError ve) {
// We're not seeing the message we expect. Could be
// that we've gotten the wrong VerifyError case, or
// maybe the message changed.
"Message does not match what was expected: " +
message);
continue;
}
throw new RuntimeException("FAIL: No details found");
}
}
} else {
}
}
}
}