Skip to content

Commit

Permalink
8330578: The VM creates instance of abstract class VirtualMachineError
Browse files Browse the repository at this point in the history
Reviewed-by: iklam, dlong, jwaters, dholmes
  • Loading branch information
coleenp committed Apr 23, 2024
1 parent 3bd6982 commit fcb4a8b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/cds/heapShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/verifier.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
}
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/memory/universe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class BuiltinException {

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();
Expand All @@ -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(); }

Expand Down Expand Up @@ -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() {
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/memory/universe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down

1 comment on commit fcb4a8b

@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.