Skip to content
Permalink
Browse files
8256726: Zero: print proper message in ArrayIndexOutOfBoundException
Reviewed-by: dholmes, sgehwolf
  • Loading branch information
shipilev committed Nov 29, 2020
1 parent f4c15a9 commit 87f37aa278f72a5f28b198cb0a208431f22d44b5
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp
@@ -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"

@@ -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); \
}

1 comment on commit 87f37aa

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 87f37aa Nov 29, 2020

Please sign in to comment.