test/runtime/stackMapCheck/StackMapCheck.java

Wed, 25 Mar 2015 08:16:48 -0400

author
hseigel
date
Wed, 25 Mar 2015 08:16:48 -0400
changeset 7666
6b65121b3258
permissions
-rw-r--r--

7127066: Class verifier accepts an invalid class file
Summary: For *store bytecodes, compare incoming, not outgoing, type state with exception handlers' stack maps.
Reviewed-by: acorn, dholmes

hseigel@7666 1 /*
hseigel@7666 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hseigel@7666 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hseigel@7666 4 *
hseigel@7666 5 * This code is free software; you can redistribute it and/or modify it
hseigel@7666 6 * under the terms of the GNU General Public License version 2 only, as
hseigel@7666 7 * published by the Free Software Foundation.
hseigel@7666 8 *
hseigel@7666 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hseigel@7666 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hseigel@7666 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hseigel@7666 12 * version 2 for more details (a copy is included in the LICENSE file that
hseigel@7666 13 * accompanied this code).
hseigel@7666 14 *
hseigel@7666 15 * You should have received a copy of the GNU General Public License version
hseigel@7666 16 * 2 along with this work; if not, write to the Free Software Foundation,
hseigel@7666 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hseigel@7666 18 *
hseigel@7666 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hseigel@7666 20 * or visit www.oracle.com if you need additional information or have any
hseigel@7666 21 * questions.
hseigel@7666 22 *
hseigel@7666 23 */
hseigel@7666 24
hseigel@7666 25 /*
hseigel@7666 26 * @test
hseigel@7666 27 * @bug 7127066
hseigel@7666 28 * @summary Class verifier accepts an invalid class file
hseigel@7666 29 * @compile BadMap.jasm
hseigel@7666 30 * @compile BadMapDstore.jasm
hseigel@7666 31 * @compile BadMapIstore.jasm
hseigel@7666 32 * @run main/othervm -Xverify:all StackMapCheck
hseigel@7666 33 */
hseigel@7666 34
hseigel@7666 35 public class StackMapCheck {
hseigel@7666 36 public static void main(String args[]) throws Throwable {
hseigel@7666 37
hseigel@7666 38 System.out.println("Regression test for bug 7127066");
hseigel@7666 39 try {
hseigel@7666 40 Class newClass = Class.forName("BadMap");
hseigel@7666 41 throw new RuntimeException(
hseigel@7666 42 "StackMapCheck failed, BadMap did not throw VerifyError");
hseigel@7666 43 } catch (java.lang.VerifyError e) {
hseigel@7666 44 System.out.println("BadMap passed, VerifyError was thrown");
hseigel@7666 45 }
hseigel@7666 46
hseigel@7666 47 try {
hseigel@7666 48 Class newClass = Class.forName("BadMapDstore");
hseigel@7666 49 throw new RuntimeException(
hseigel@7666 50 "StackMapCheck failed, BadMapDstore did not throw VerifyError");
hseigel@7666 51 } catch (java.lang.VerifyError e) {
hseigel@7666 52 System.out.println("BadMapDstore passed, VerifyError was thrown");
hseigel@7666 53 }
hseigel@7666 54
hseigel@7666 55 try {
hseigel@7666 56 Class newClass = Class.forName("BadMapIstore");
hseigel@7666 57 throw new RuntimeException(
hseigel@7666 58 "StackMapCheck failed, BadMapIstore did not throw VerifyError");
hseigel@7666 59 } catch (java.lang.VerifyError e) {
hseigel@7666 60 System.out.println("BadMapIstore passed, VerifyError was thrown");
hseigel@7666 61 }
hseigel@7666 62 }
hseigel@7666 63 }

mercurial