Skip to content

Commit

Permalink
8256726: Zero: print proper message in ArrayIndexOutOfBoundException
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, sgehwolf
  • Loading branch information
shipilev committed Nov 29, 2020
1 parent f4c15a9 commit 87f37aa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "runtime/orderAccess.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/threadCritical.hpp"
#include "utilities/debug.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/macros.hpp"

Expand Down Expand Up @@ -1369,10 +1370,15 @@ void BytecodeInterpreter::run(interpreterState istate) {
#define ARRAY_INTRO(arrayOff) \
arrayOop arrObj = (arrayOop)STACK_OBJECT(arrayOff); \
jint index = STACK_INT(arrayOff + 1); \
char message[jintAsStringSize]; \
const int add_len = 32; \
STATIC_ASSERT(add_len == strlen("Index out of bounds for length ")); \
/* Two integers, the additional message, and the null-terminator */ \
char message[2 * jintAsStringSize + add_len + 1]; \
CHECK_NULL(arrObj); \
if ((uint32_t)index >= (uint32_t)arrObj->length()) { \
sprintf(message, "%d", index); \
jio_snprintf(message, sizeof(message), \
"Index %d out of bounds for length %d", \
index, arrObj->length()); \
VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \
message); \
}
Expand Down

1 comment on commit 87f37aa

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.