Skip to content
3 changes: 3 additions & 0 deletions src/hotspot/share/jvmci/jvmciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ class ExceptionTranslation: public StackObj {
ResourceMark rm;
jlong buffer = (jlong) NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(THREAD, jbyte, buffer_size);
if (buffer == 0L) {
JVMCI_event_1("error translating exception: translation buffer allocation failed");
decode(THREAD, vmSupport, -1, 0L);
return;
}
Expand All @@ -403,13 +404,15 @@ class ExceptionTranslation: public StackObj {
// Cannot get name of exception thrown by `encode` as that involves
// calling into libjvmci which in turn can raise another exception.
_from_env->clear_pending_exception();
JVMCI_event_1("error translating exception: unknown error");
decode(THREAD, vmSupport, -3, 0L);
return;
} else if (HAS_PENDING_EXCEPTION) {
Handle throwable = Handle(THREAD, PENDING_EXCEPTION);
Symbol *ex_name = throwable->klass()->name();
CLEAR_PENDING_EXCEPTION;
if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
JVMCI_event_1("error translating exception: OutOfMemoryError");
decode(THREAD, vmSupport, -2, 0L);
} else {
char* char_buffer = (char*) buffer + 4;
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/jdk/internal/vm/VMSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static void decodeAndThrowThrowable(int format, long buffer, boolean inJV
String context = String.format("while encoding an exception to translate it %s the JVM heap",
inJVMHeap ? "to" : "from");
if (format == -1) {
throw new InternalError("native errorOrBuffer could not be allocated " + context);
throw new InternalError("native buffer could not be allocated " + context);
}
if (format == -2L) {
throw new OutOfMemoryError("OutOfMemoryError occurred " + context);
Expand Down