From fcb4a8ba26fe1de596331b0a2f89c5c7c24e7f9e Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 23 Apr 2024 11:31:11 +0000 Subject: [PATCH] 8330578: The VM creates instance of abstract class VirtualMachineError Reviewed-by: iklam, dlong, jwaters, dholmes --- src/hotspot/share/cds/heapShared.cpp | 2 +- src/hotspot/share/classfile/systemDictionary.cpp | 4 ++-- src/hotspot/share/classfile/verifier.cpp | 4 ++-- src/hotspot/share/memory/universe.cpp | 16 ++++++++-------- src/hotspot/share/memory/universe.hpp | 4 ++-- src/hotspot/share/oops/instanceKlass.cpp | 1 + src/hotspot/share/oops/method.cpp | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index a9dd5de9f4a..202042e622e 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -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(), diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 71ede3d9e00..3a6c372cc50 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -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; diff --git a/src/hotspot/share/classfile/verifier.cpp b/src/hotspot/share/classfile/verifier.cpp index 743bd9d06ba..a66fbf645f5 100644 --- a/src/hotspot/share/classfile/verifier.cpp +++ b/src/hotspot/share/classfile/verifier.cpp @@ -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(); } diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index 237eac5017c..e640482aa04 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -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()); diff --git a/src/hotspot/share/memory/universe.hpp b/src/hotspot/share/memory/universe.hpp index 09e00bb24a0..19acbdc09b2 100644 --- a/src/hotspot/share/memory/universe.hpp +++ b/src/hotspot/share/memory/universe.hpp @@ -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* the_array_interfaces_array() { return _the_array_interfaces_array; } static uintx the_array_interfaces_bitmap() { return _the_array_interfaces_bitmap; } diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 0b5c9759310..0069f336e88 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -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); } diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp index d2e25feef40..f5c35abb683 100644 --- a/src/hotspot/share/oops/method.cpp +++ b/src/hotspot/share/oops/method.cpp @@ -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"); } }