From 3f9f0665f6cc290e4f31651b23d3ad7241444dd1 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 11 May 2016 12:03:46 -0400 Subject: [PATCH] 8155981: Bolster bytecode verification Reviewed-by: acorn, jdn --- hotspot/src/share/vm/classfile/verifier.cpp | 28 ++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 58200d11e03..c0976d55d4b 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -2377,9 +2377,17 @@ bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) { case Bytecodes::_ifnonnull: target = bcs.dest(); if (visited_branches->contains(bci)) { - if (bci_stack->is_empty()) return true; - // Pop a bytecode starting offset and scan from there. - bcs.set_start(bci_stack->pop()); + if (bci_stack->is_empty()) { + if (handler_stack->is_empty()) { + return true; + } else { + // Parse the catch handlers for try blocks containing athrow. + bcs.set_start(handler_stack->pop()); + } + } else { + // Pop a bytecode starting offset and scan from there. + bcs.set_start(bci_stack->pop()); + } } else { if (target > bci) { // forward branch if (target >= code_length) return false; @@ -2402,9 +2410,17 @@ bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) { case Bytecodes::_goto_w: target = (opcode == Bytecodes::_goto ? bcs.dest() : bcs.dest_w()); if (visited_branches->contains(bci)) { - if (bci_stack->is_empty()) return true; - // Been here before, pop new starting offset from stack. - bcs.set_start(bci_stack->pop()); + if (bci_stack->is_empty()) { + if (handler_stack->is_empty()) { + return true; + } else { + // Parse the catch handlers for try blocks containing athrow. + bcs.set_start(handler_stack->pop()); + } + } else { + // Been here before, pop new starting offset from stack. + bcs.set_start(bci_stack->pop()); + } } else { if (target >= code_length) return false; // Continue scanning from the target onward.