--- old/src/hotspot/share/interpreter/bytecodeUtils.cpp 2019-09-17 11:07:25.454176000 +0200 +++ new/src/hotspot/share/interpreter/bytecodeUtils.cpp 2019-09-17 11:07:24.574158000 +0200 @@ -31,6 +31,7 @@ #include "runtime/signature.hpp" #include "runtime/safepointVerifiers.hpp" #include "utilities/events.hpp" +#include "utilities/ostream.hpp" class SimulatedOperandStack; class ExceptionMessageBuilder; @@ -211,11 +212,8 @@ void print_NPE_failed_action(outputStream *os, int bci); }; - -/* - * Prints the name of the method that is described at constant pool - * index cp_index in the constant pool of method 'method'. - */ +// Prints the name of the method that is described at constant pool +// index cp_index in the constant pool of method 'method'. static void print_method_name(outputStream *os, Method* method, int cp_index) { ConstantPool* cp = method->constants(); Symbol* klass = cp->klass_ref_at_noresolve(cp_index); @@ -227,10 +225,8 @@ os->print(")"); } -/* - * Prints the name of the field that is described at constant pool - * index cp_index in the constant pool of method 'method'. - */ +// Prints the name of the field that is described at constant pool +// index cp_index in the constant pool of method 'method'. static void print_field_and_class(outputStream *os, Method* method, int cp_index) { ConstantPool* cp = method->constants(); Symbol* klass = cp->klass_ref_at_noresolve(cp_index); @@ -238,10 +234,8 @@ os->print("%s.%s", klass->as_klass_external_name(), name->as_C_string()); } -/* - * Returns the name of the field that is described at constant pool - * index cp_index in the constant pool of method 'method'. - */ +// Returns the name of the field that is described at constant pool +// index cp_index in the constant pool of method 'method'. static char const* get_field_name(Method* method, int cp_index) { Symbol* name = method->constants()->name_ref_at(cp_index); return name->as_C_string(); @@ -388,8 +382,10 @@ ExceptionMessageBuilder::ExceptionMessageBuilder(Method* method, int bci) : _method(method), _nr_of_entries(0), _added_one(true), _all_processed(false) { - ConstMethod* const_method = method->constMethod(); + assert(bci >= 0, "BCI too low"); + assert(bci < get_size(), "BCI too large"); + ConstMethod* const_method = method->constMethod(); const int len = const_method->code_size(); _stacks = new GrowableArray (len+1); @@ -1358,6 +1354,7 @@ } // Analyse the bytecodes. + ResourceMark rm; ExceptionMessageBuilder emb(method, bci); // The slot of the operand stack that contains the null reference.