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 // Test that VerifyError is thrown if dup2_x1 tries to replace the filler slot 26 // of a category 2 value. 27 // The stack map is long,top,null,null. The verifier should reject dup2_x1's 28 // (form1) attempt to turn the stack map into long,top,null,null,null,null 29 public class dup2_x1 version 51:0 { 30 public static Method run:"()V" stack 6 locals 0 { 31 lconst_0; 32 aconst_null; 33 aconst_null; 34 dup2_x1; 35 return; 36 } 37 } 38 39 40 public class dup2_x2 version 51:0 { 41 public static Method run:"()V" stack 6 locals 0 { 42 iconst_0; 43 lconst_0; 44 aconst_null; 45 46 stack_frame_type full; 47 stack_map int, bogus, bogus, null; 48 locals_map; 49 50 dup2_x2; 51 return; 52 } 53 } 54 55 56 // Test that VerifyError is thrown if dup2_x2 tries to replace the filler slot 57 // of a category 2 value. 58 // The stack map is long,top,null,null,null. The verifier should reject dup2_x2's 59 // (form 1) attempt to turn the stack map into long,top,null,null,null,top,null. 60 public class dup2_x2_long_refs version 51:0 { 61 public static Method run:"()V" stack 6 locals 0 { 62 lconst_0; 63 aconst_null; 64 aconst_null; 65 aconst_null; 66 dup2_x2; 67 return; 68 } 69 } 70 71 72 // Test that VerifyError is thrown when dup2 is used to remove the upper 73 // half of a category 2 type. 74 public class dup2longtop version 51:0 { 75 public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 { 76 lconst_0; 77 iconst_0; 78 dup2; 79 return; 80 } 81 } 82 83 84 // Test that VerifyError is thrown when dup2 is used to remove top 85 // because top may be the upper half of a category 2 type. 86 public class dup2toptop version 51:0 { 87 public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 { 88 // here we have {long, top, null} 89 // EXECUTION: we have {long, null} 90 lconst_0; 91 aconst_null; 92 93 stack_frame_type full; 94 stack_map bogus, bogus, null; 95 locals_map bogus; 96 97 // VERIFIER: use form1 of dup2 - {top, top, null} -> {top, top, null, top, null} 98 // EXECUTION: have {long, null} - no applicable form of dup2 for such type state by JVMS ch. 6 99 dup2; 100 101 return; 102 } 103 } 104 105 106 // Test that VerifyError is thrown if dup_x1 tries to replace the filler slot 107 // of a category 2 value. 108 public class dup_x1 version 51:0 { 109 public static Method run:"()V" stack 6 locals 0 { 110 lconst_0; 111 aconst_null; 112 dup_x1; 113 return; 114 } 115 } 116 117 118 // Test that VerifyError is thrown when pop2 is used to remove top 119 // because top may be the upper half of a category 2 type. 120 public class pop2longtop version 51:0 121 { 122 123 public Method regular:"()V" stack 6 locals 6 124 { 125 lconst_0; 126 iconst_0; 127 stack_frame_type full; 128 stack_map long, bogus; 129 locals_map; 130 pop2; 131 return; 132 } 133 } // end Class pop2longtop 134 135 136 137 // Test that VerifyError is thrown when pop2 is used to remove top, top 138 // because either top may be the upper half of a category 2 type. 139 public class pop2toptop version 51:0 140 { 141 142 public Method regular:"()V" stack 6 locals 6 143 { 144 iconst_0; 145 iconst_0; 146 stack_frame_type full; 147 stack_map bogus, bogus; 148 locals_map; 149 pop2; 150 return; 151 } 152 } // end Class pop2toptop 153 154 155 156 // Test that VerifyError is thrown when pop is used to remove top 157 // because top may be the upper half of a category 2 type. 158 public class poptop version 51:0 159 { 160 161 public Method regular:"()V" stack 2 locals 1 162 { 163 iconst_0; 164 stack_frame_type full; 165 stack_map bogus; 166 pop; 167 return; 168 } 169 } // end Class poptop 170 171 172 173 // Test that VerifyError is thrown when pop is used to remove top, top 174 // because either top may be the upper half of a category 2 type. 175 public class poptoptop version 51:0 176 { 177 178 public Method regular:"()V" stack 2 locals 1 179 { 180 iconst_0; 181 iconst_0; 182 stack_frame_type full; 183 stack_map bogus, bogus; 184 pop; 185 return; 186 } 187 } // end Class poptoptop 188 189 190 191 // Test that VerifyError is thrown when swap is used to swap int, top 192 // because top may be the lower half of a category 2 type. 193 public class swapinttop version 51:0 194 { 195 196 public Method regular:"()V" stack 6 locals 6 197 { 198 iconst_0; 199 iconst_0; 200 stack_frame_type full; 201 stack_map int, bogus; 202 locals_map; 203 swap; 204 return; 205 } 206 } // end Class swapinttop 207 208 209 210 // Test that VerifyError is thrown when swap is used to swap top, int 211 // because top may be the upper half of a category 2 type. 212 public class swaptopint version 51:0 213 { 214 215 public Method regular:"()V" stack 6 locals 6 216 { 217 iconst_0; 218 iconst_0; 219 stack_frame_type full; 220 stack_map bogus, int; 221 locals_map; 222 swap; 223 return; 224 } 225 } // end Class swaptopint 226 227 228 229 // Test that VerifyError is thrown when swap is used to swap top, top 230 // because either top may be the upper half of a category 2 type. 231 public class swaptoptop version 51:0 232 { 233 234 public Method regular:"()V" stack 6 locals 6 235 { 236 iconst_0; 237 iconst_0; 238 stack_frame_type full; 239 stack_map bogus, bogus; 240 locals_map; 241 swap; 242 return; 243 } 244 } // end Class swaptoptop