8330578: The VM creates instance of abstract class VirtualMachineError

Reviewed-by: iklam, dlong, jwaters, dholmes
This commit is contained in:
Coleen Phillimore 2024-04-23 11:31:11 +00:00
parent 3bd6982ec3
commit fcb4a8ba26
7 changed files with 17 additions and 16 deletions

View File

@ -1395,7 +1395,7 @@ void HeapShared::check_default_subgraph_classes() {
name == vmSymbols::java_lang_String() ||
name == vmSymbols::java_lang_ArithmeticException() ||
name == vmSymbols::java_lang_NullPointerException() ||
name == vmSymbols::java_lang_VirtualMachineError() ||
name == vmSymbols::java_lang_InternalError() ||
name == vmSymbols::object_array_signature() ||
name == vmSymbols::byte_array_signature() ||
name == vmSymbols::char_array_signature(),

View File

@ -2009,9 +2009,9 @@ Method* SystemDictionary::find_method_handle_intrinsic(vmIntrinsicID iid,
}
}
// Throw VirtualMachineError or the pending exception in the JavaThread
// Throw OOM or the pending exception in the JavaThread
if (throw_error && !HAS_PENDING_EXCEPTION) {
THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(),
THROW_MSG_NULL(vmSymbols::java_lang_OutOfMemoryError(),
"Out of space in CodeCache for method handle intrinsic");
}
return nullptr;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -255,7 +255,7 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) {
// or one of it's superclasses, we're in trouble and are going
// to infinitely recurse when we try to initialize the exception.
// So bail out here by throwing the preallocated VM error.
THROW_OOP_(Universe::virtual_machine_error_instance(), false);
THROW_OOP_(Universe::internal_error_instance(), false);
}
kls = kls->super();
}

View File

@ -229,7 +229,7 @@ public:
static BuiltinException _null_ptr_exception;
static BuiltinException _arithmetic_exception;
static BuiltinException _virtual_machine_error;
static BuiltinException _internal_error;
objArrayOop Universe::the_empty_class_array () {
return (objArrayOop)_the_empty_class_array.resolve();
@ -246,7 +246,7 @@ oop Universe::the_min_jint_string() { return _the_min_jint_string.
oop Universe::null_ptr_exception_instance() { return _null_ptr_exception.instance(); }
oop Universe::arithmetic_exception_instance() { return _arithmetic_exception.instance(); }
oop Universe::virtual_machine_error_instance() { return _virtual_machine_error.instance(); }
oop Universe::internal_error_instance() { return _internal_error.instance(); }
oop Universe::the_null_sentinel() { return _the_null_sentinel.resolve(); }
@ -302,7 +302,7 @@ void Universe::set_archived_basic_type_mirror_index(BasicType t, int index) {
void Universe::archive_exception_instances() {
_null_ptr_exception.store_in_cds();
_arithmetic_exception.store_in_cds();
_virtual_machine_error.store_in_cds();
_internal_error.store_in_cds();
}
void Universe::load_archived_object_instances() {
@ -318,7 +318,7 @@ void Universe::load_archived_object_instances() {
_null_ptr_exception.load_from_cds();
_arithmetic_exception.load_from_cds();
_virtual_machine_error.load_from_cds();
_internal_error.load_from_cds();
}
}
#endif
@ -334,7 +334,7 @@ void Universe::serialize(SerializeClosure* f) {
}
_null_ptr_exception.serialize(f);
_arithmetic_exception.serialize(f);
_virtual_machine_error.serialize(f);
_internal_error.serialize(f);
#endif
f->do_ptr(&_fillerArrayKlass);
@ -1092,13 +1092,13 @@ bool universe_post_init() {
_arithmetic_exception.init_if_empty(vmSymbols::java_lang_ArithmeticException(), CHECK_false);
// Virtual Machine Error for when we get into a situation we can't resolve
Klass* k = vmClasses::VirtualMachineError_klass();
Klass* k = vmClasses::InternalError_klass();
bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false);
if (!linked) {
tty->print_cr("Unable to link/verify VirtualMachineError class");
tty->print_cr("Unable to link/verify InternalError class");
return false; // initialization failed
}
_virtual_machine_error.init_if_empty(vmSymbols::java_lang_VirtualMachineError(), CHECK_false);
_internal_error.init_if_empty(vmSymbols::java_lang_InternalError(), CHECK_false);
Handle msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
java_lang_Throwable::set_message(Universe::arithmetic_exception_instance(), msg());

View File

@ -229,8 +229,8 @@ class Universe: AllStatic {
static oop null_ptr_exception_instance();
static oop arithmetic_exception_instance();
static oop virtual_machine_error_instance();
static oop vm_exception() { return virtual_machine_error_instance(); }
static oop internal_error_instance();
static oop vm_exception() { return internal_error_instance(); }
static Array<Klass*>* the_array_interfaces_array() { return _the_array_interfaces_array; }
static uintx the_array_interfaces_bitmap() { return _the_array_interfaces_bitmap; }

View File

@ -1509,6 +1509,7 @@ instanceOop InstanceKlass::register_finalizer(instanceOop i, TRAPS) {
}
instanceOop InstanceKlass::allocate_instance(TRAPS) {
assert(!is_abstract() && !is_interface(), "Should not create this object");
size_t size = size_helper(); // Query before forming handle.
return (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
}

View File

@ -1276,7 +1276,7 @@ address Method::make_adapters(const methodHandle& mh, TRAPS) {
// Java exception object.
vm_exit_during_initialization("Out of space in CodeCache for adapters");
} else {
THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters");
THROW_MSG_NULL(vmSymbols::java_lang_OutOfMemoryError(), "Out of space in CodeCache for adapters");
}
}