1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 /*
  26  * @test
  27  * @bug 8149607
  28  * @summary Throw VerifyError when popping a stack element of TOP
  29  * @compile popDupSwapTests.jasm
  30  * @run main/othervm -Xverify:all PopDupTop
  31  */
  32 
  33 public class PopDupTop {
  34 
  35     public static void testClass(String class_name, String msg) throws Throwable {
  36         try {
  37             Class newClass = Class.forName(class_name);
  38             throw new RuntimeException("Expected VerifyError exception not thrown for " + msg);
  39         } catch (java.lang.VerifyError e) {
  40             if (!e.getMessage().contains("Bad type on operand stack")) {
  41                throw new RuntimeException(
  42                    "Unexpected VerifyError message for " + msg + ": " + e.getMessage());
  43             }
  44         }
  45     }
  46 
  47     public static void main(String args[]) throws Throwable {
  48         System.out.println("Regression test for bug 8149607");
  49 
  50         testClass("dup_x1", "dup_x1 of long,ref");
  51         testClass("dup2toptop", "dup2 of top,top");
  52         testClass("dup2longtop", "dup2 of long,top");
  53         testClass("dup2_x1", "dup2_x1 long,ref,ref");
  54         testClass("dup2_x2", "dup2_x2 top");
  55         testClass("dup2_x2_long_refs", "dup2_x2 long,ref,ref,ref");
  56         testClass("poptop", "pop of top");
  57         testClass("poptoptop", "pop of top,top");
  58         testClass("pop2toptop", "pop2 of top,top");
  59         testClass("pop2longtop", "pop2 of long,top");
  60         testClass("swaptoptop", "swap of top,top");
  61         testClass("swapinttop", "swap of int,top");
  62         testClass("swaptopint", "swap of top,int");
  63     }
  64 }