Fri, 09 Jan 2015 15:50:22 +0000
8067429: java.lang.VerifyError: Inconsistent stackmap frames at branch target
Summary: bitset for alive variables contains info about variables out of range
Reviewed-by: mcimadamore
Contributed-by: srikanth.adayapalam@oracle.com
src/share/classes/com/sun/tools/javac/jvm/Gen.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/BranchToFewerDefines.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Sep 06 03:21:27 2019 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Jan 09 15:50:22 2015 +0000 1.3 @@ -1222,9 +1222,10 @@ 1.4 code.resolve(c.jumpTrue(), startpc); 1.5 code.resolve(c.falseJumps); 1.6 } 1.7 - code.resolve(loopEnv.info.exit); 1.8 - if (loopEnv.info.exit != null) { 1.9 - loopEnv.info.exit.state.defined.excludeFrom(code.nextreg); 1.10 + Chain exit = loopEnv.info.exit; 1.11 + if (exit != null) { 1.12 + code.resolve(exit); 1.13 + exit.state.defined.excludeFrom(code.nextreg); 1.14 } 1.15 } 1.16 1.17 @@ -1235,7 +1236,11 @@ 1.18 public void visitLabelled(JCLabeledStatement tree) { 1.19 Env<GenContext> localEnv = env.dup(tree, new GenContext()); 1.20 genStat(tree.body, localEnv, CRT_STATEMENT); 1.21 - code.resolve(localEnv.info.exit); 1.22 + Chain exit = localEnv.info.exit; 1.23 + if (exit != null) { 1.24 + code.resolve(exit); 1.25 + exit.state.defined.excludeFrom(code.nextreg); 1.26 + } 1.27 } 1.28 1.29 public void visitSwitch(JCSwitch tree) { 1.30 @@ -1344,7 +1349,11 @@ 1.31 } 1.32 1.33 // Resolve all breaks. 1.34 - code.resolve(switchEnv.info.exit); 1.35 + Chain exit = switchEnv.info.exit; 1.36 + if (exit != null) { 1.37 + code.resolve(exit); 1.38 + exit.state.defined.excludeFrom(code.nextreg); 1.39 + } 1.40 1.41 // If we have not set the default offset, we do so now. 1.42 if (code.get4(tableBase) == -1) {
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/BranchToFewerDefines.java Fri Jan 09 15:50:22 2015 +0000 2.3 @@ -0,0 +1,111 @@ 2.4 +/* 2.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test 2.29 + * @bug 8067429 2.30 + * @summary java.lang.VerifyError: Inconsistent stackmap frames at branch target 2.31 + * @author srikanth 2.32 + * 2.33 + * @compile BranchToFewerDefines.java 2.34 + * @run main BranchToFewerDefines 2.35 + */ 2.36 + 2.37 +public class BranchToFewerDefines { 2.38 + public static void main(String[] args) { 2.39 + } 2.40 + private void problematicMethod(int p) { 2.41 + switch (p) { 2.42 + case 3: 2.43 + long n; 2.44 + while (true) { 2.45 + if (false) { 2.46 + break; 2.47 + } 2.48 + } 2.49 + break; 2.50 + case 2: 2.51 + loop: while (true) { 2.52 + while (true) { 2.53 + int i = 4; 2.54 + if (p != 16) { 2.55 + return; 2.56 + } 2.57 + break loop; 2.58 + } 2.59 + } 2.60 + break; 2.61 + default: 2.62 + while (true) { 2.63 + if (false) { 2.64 + break; 2.65 + } 2.66 + } 2.67 + break; 2.68 + } 2.69 + long b; 2.70 + if (p != 7) { 2.71 + switch (p) { 2.72 + case 1: 2.73 + long a = 17; 2.74 + break; 2.75 + case 2: 2.76 + break; 2.77 + default: 2.78 + break; 2.79 + } 2.80 + } 2.81 + } 2.82 + private void problematicMethod2(int p) { 2.83 + switch (p) { 2.84 + case 3: 2.85 + long n; 2.86 + { 2.87 + int i = 4; 2.88 + break; 2.89 + } 2.90 + case 2: 2.91 + { 2.92 + int i = 4; 2.93 + break; 2.94 + } 2.95 + default: 2.96 + { 2.97 + int i = 4; 2.98 + break; 2.99 + } 2.100 + } 2.101 + long b; 2.102 + if (p != 7) { 2.103 + switch (p) { 2.104 + case 1: 2.105 + long a = 17; 2.106 + break; 2.107 + case 2: 2.108 + break; 2.109 + default: 2.110 + break; 2.111 + } 2.112 + } 2.113 + } 2.114 +}