diff --git a/src/hotspot/share/classfile/classFileError.cpp b/src/hotspot/share/classfile/classFileError.cpp index 53c33b23285..4de5c288955 100644 --- a/src/hotspot/share/classfile/classFileError.cpp +++ b/src/hotspot/share/classfile/classFileError.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, 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 @@ -35,7 +35,7 @@ PRAGMA_DIAG_PUSH PRAGMA_FORMAT_NONLITERAL_IGNORED void ClassFileParser::classfile_parse_error(const char* msg, TRAPS) const { - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); ResourceMark rm(THREAD); Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), msg, _class_name->as_C_string()); @@ -44,7 +44,7 @@ void ClassFileParser::classfile_parse_error(const char* msg, TRAPS) const { void ClassFileParser::classfile_parse_error(const char* msg, int index, TRAPS) const { - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); ResourceMark rm(THREAD); Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), msg, index, _class_name->as_C_string()); @@ -53,7 +53,7 @@ void ClassFileParser::classfile_parse_error(const char* msg, void ClassFileParser::classfile_parse_error(const char* msg, const char* name, TRAPS) const { - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); ResourceMark rm(THREAD); Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), msg, name, _class_name->as_C_string()); @@ -63,7 +63,7 @@ void ClassFileParser::classfile_parse_error(const char* msg, int index, const char* name, TRAPS) const { - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); ResourceMark rm(THREAD); Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), msg, index, name, _class_name->as_C_string()); @@ -73,7 +73,7 @@ void ClassFileParser::classfile_parse_error(const char* msg, const char* name, const char* signature, TRAPS) const { - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); ResourceMark rm(THREAD); Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), msg, name, signature, _class_name->as_C_string()); @@ -82,7 +82,7 @@ void ClassFileParser::classfile_parse_error(const char* msg, void ClassFileParser::classfile_icce_error(const char* msg, const Klass* k, TRAPS) const { - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); ResourceMark rm(THREAD); Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IncompatibleClassChangeError(), msg, _class_name->as_klass_external_name(), k->external_name()); diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index e2a0ab7025c..8c26d28ef5b 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -155,8 +155,8 @@ void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const s ConstantPool* cp, const int length, TRAPS) { - assert(stream != NULL, "invariant"); - assert(cp != NULL, "invariant"); + assert(stream != nullptr, "invariant"); + assert(cp != nullptr, "invariant"); // Use a local copy of ClassFileStream. It helps the C++ compiler to optimize // this function (_current can be allocated in a register, with scalar @@ -318,7 +318,7 @@ void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const s cfs->guarantee_more(2, CHECK); // utf8_length u2 utf8_length = cfs->get_u2_fast(); const u1* utf8_buffer = cfs->current(); - assert(utf8_buffer != NULL, "null utf8 buffer"); + assert(utf8_buffer != nullptr, "null utf8 buffer"); // Got utf8 string, guarantee utf8_length+1 bytes, set stream position forward. cfs->guarantee_more(utf8_length+1, CHECK); // utf8 string, tag/access_flags cfs->skip_u1_fast(utf8_length); @@ -332,7 +332,7 @@ void ClassFileParser::parse_constant_pool_entries(const ClassFileStream* const s Symbol* const result = SymbolTable::lookup_only((const char*)utf8_buffer, utf8_length, hash); - if (result == NULL) { + if (result == nullptr) { names[names_count] = (const char*)utf8_buffer; lengths[names_count] = utf8_length; indices[names_count] = index; @@ -395,11 +395,11 @@ static inline bool valid_cp_range(int index, int length) { } static inline Symbol* check_symbol_at(const ConstantPool* cp, int index) { - assert(cp != NULL, "invariant"); + assert(cp != nullptr, "invariant"); if (valid_cp_range(index, cp->length()) && cp->tag_at(index).is_utf8()) { return cp->symbol_at(index); } - return NULL; + return nullptr; } #ifdef ASSERT @@ -423,8 +423,8 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream, ConstantPool* const cp, const int length, TRAPS) { - assert(cp != NULL, "invariant"); - assert(stream != NULL, "invariant"); + assert(cp != nullptr, "invariant"); + assert(stream != nullptr, "invariant"); // parsing constant pool entries parse_constant_pool_entries(stream, cp, length, CHECK); @@ -793,12 +793,12 @@ static void initialize_hashtable(NameSigHash** table) { // NOTE: caller should guarantee that GC doesn't happen during the life cycle // of table since we don't expect Symbol*'s to move. static bool put_after_lookup(const Symbol* name, const Symbol* sig, NameSigHash** table) { - assert(name != NULL, "name in constant pool is NULL"); + assert(name != nullptr, "name in constant pool is null"); // First lookup for duplicates int index = hash(name, sig); NameSigHash* entry = table[index]; - while (entry != NULL) { + while (entry != nullptr) { if (entry->_name == name && entry->_sig == sig) { return false; } @@ -823,15 +823,15 @@ void ClassFileParser::parse_interfaces(const ClassFileStream* const stream, ConstantPool* const cp, bool* const has_nonstatic_concrete_methods, TRAPS) { - assert(stream != NULL, "invariant"); - assert(cp != NULL, "invariant"); - assert(has_nonstatic_concrete_methods != NULL, "invariant"); + assert(stream != nullptr, "invariant"); + assert(cp != nullptr, "invariant"); + assert(has_nonstatic_concrete_methods != nullptr, "invariant"); if (itfs_len == 0) { _local_interfaces = Universe::the_empty_instance_klass_array(); } else { assert(itfs_len > 0, "only called for len>0"); - _local_interfaces = MetadataFactory::new_array(_loader_data, itfs_len, NULL, CHECK); + _local_interfaces = MetadataFactory::new_array(_loader_data, itfs_len, nullptr, CHECK); int index; for (index = 0; index < itfs_len; index++) { @@ -886,14 +886,14 @@ void ClassFileParser::parse_interfaces(const ClassFileStream* const stream, HASH_ROW_SIZE); initialize_hashtable(interface_names); bool dup = false; - const Symbol* name = NULL; + const Symbol* name = nullptr; { debug_only(NoSafepointVerifier nsv;) for (index = 0; index < itfs_len; index++) { const InstanceKlass* const k = _local_interfaces->at(index); name = k->name(); - // If no duplicates, add (name, NULL) in hashtable interface_names. - if (!put_after_lookup(name, NULL, interface_names)) { + // If no duplicates, add (name, nullptr) in hashtable interface_names. + if (!put_after_lookup(name, nullptr, interface_names)) { dup = true; break; } @@ -1028,8 +1028,8 @@ public: FieldAnnotationCollector(ClassLoaderData* loader_data) : AnnotationCollector(_in_field), _loader_data(loader_data), - _field_annotations(NULL), - _field_type_annotations(NULL) {} + _field_annotations(nullptr), + _field_type_annotations(nullptr) {} ~FieldAnnotationCollector(); void apply_to(FieldInfo* f); AnnotationArray* field_annotations() { return _field_annotations; } @@ -1061,7 +1061,7 @@ index += val; // Skip an annotation. Return >=limit if there is any problem. static int skip_annotation(const u1* buffer, int limit, int index) { - assert(buffer != NULL, "invariant"); + assert(buffer != nullptr, "invariant"); // annotation := atype:u2 do(nmem:u2) {member:u2 value} // value := switch (tag:u1) { ... } SAFE_ADD(index, limit, 4); // skip atype and read nmem @@ -1075,7 +1075,7 @@ static int skip_annotation(const u1* buffer, int limit, int index) { // Skip an annotation value. Return >=limit if there is any problem. static int skip_annotation_value(const u1* buffer, int limit, int index) { - assert(buffer != NULL, "invariant"); + assert(buffer != nullptr, "invariant"); // value := switch (tag:u1) { // case B, C, I, S, Z, D, F, J, c: con:u2; @@ -1128,10 +1128,10 @@ static void parse_annotations(const ConstantPool* const cp, ClassLoaderData* loader_data, const bool can_access_vm_annotations) { - assert(cp != NULL, "invariant"); - assert(buffer != NULL, "invariant"); - assert(coll != NULL, "invariant"); - assert(loader_data != NULL, "invariant"); + assert(cp != nullptr, "invariant"); + assert(buffer != nullptr, "invariant"); + assert(coll != nullptr, "invariant"); + assert(loader_data != nullptr, "invariant"); // annotations := do(nann:u2) {annotation} int index = 2; // read nann @@ -1162,12 +1162,12 @@ static void parse_annotations(const ConstantPool* const cp, const int atype = Bytes::get_Java_u2((address)abase + atype_off); const int count = Bytes::get_Java_u2((address)abase + count_off); const Symbol* const aname = check_symbol_at(cp, atype); - if (aname == NULL) break; // invalid annotation name - const Symbol* member = NULL; + if (aname == nullptr) break; // invalid annotation name + const Symbol* member = nullptr; if (count >= 1) { const int member_index = Bytes::get_Java_u2((address)abase + member_off); member = check_symbol_at(cp, member_index); - if (member == NULL) break; // invalid member name + if (member == nullptr) break; // invalid member name } // Here is where parsing particular annotations will take place. @@ -1212,23 +1212,23 @@ void ClassFileParser::parse_field_attributes(const ClassFileStream* const cfs, u2* const generic_signature_index_addr, ClassFileParser::FieldAnnotationCollector* parsed_annotations, TRAPS) { - assert(cfs != NULL, "invariant"); - assert(constantvalue_index_addr != NULL, "invariant"); - assert(is_synthetic_addr != NULL, "invariant"); - assert(generic_signature_index_addr != NULL, "invariant"); - assert(parsed_annotations != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); + assert(constantvalue_index_addr != nullptr, "invariant"); + assert(is_synthetic_addr != nullptr, "invariant"); + assert(generic_signature_index_addr != nullptr, "invariant"); + assert(parsed_annotations != nullptr, "invariant"); assert(attributes_count > 0, "attributes_count should be greater than 0"); u2 constantvalue_index = 0; u2 generic_signature_index = 0; bool is_synthetic = false; - const u1* runtime_visible_annotations = NULL; + const u1* runtime_visible_annotations = nullptr; int runtime_visible_annotations_length = 0; - const u1* runtime_invisible_annotations = NULL; + const u1* runtime_invisible_annotations = nullptr; int runtime_invisible_annotations_length = 0; - const u1* runtime_visible_type_annotations = NULL; + const u1* runtime_visible_type_annotations = nullptr; int runtime_visible_type_annotations_length = 0; - const u1* runtime_invisible_type_annotations = NULL; + const u1* runtime_invisible_type_annotations = nullptr; int runtime_invisible_type_annotations_length = 0; bool runtime_invisible_annotations_exists = false; bool runtime_invisible_type_annotations_exists = false; @@ -1289,14 +1289,14 @@ void ClassFileParser::parse_field_attributes(const ClassFileStream* const cfs, } generic_signature_index = parse_generic_signature_attribute(cfs, CHECK); } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) { - if (runtime_visible_annotations != NULL) { + if (runtime_visible_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleAnnotations attributes for field in class file %s", THREAD); return; } runtime_visible_annotations_length = attribute_length; runtime_visible_annotations = cfs->current(); - assert(runtime_visible_annotations != NULL, "null visible annotations"); + assert(runtime_visible_annotations != nullptr, "null visible annotations"); cfs->guarantee_more(runtime_visible_annotations_length, CHECK); parse_annotations(cp, runtime_visible_annotations, @@ -1315,18 +1315,18 @@ void ClassFileParser::parse_field_attributes(const ClassFileStream* const cfs, if (PreserveAllAnnotations) { runtime_invisible_annotations_length = attribute_length; runtime_invisible_annotations = cfs->current(); - assert(runtime_invisible_annotations != NULL, "null invisible annotations"); + assert(runtime_invisible_annotations != nullptr, "null invisible annotations"); } cfs->skip_u1(attribute_length, CHECK); } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) { - if (runtime_visible_type_annotations != NULL) { + if (runtime_visible_type_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleTypeAnnotations attributes for field in class file %s", THREAD); return; } runtime_visible_type_annotations_length = attribute_length; runtime_visible_type_annotations = cfs->current(); - assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); + assert(runtime_visible_type_annotations != nullptr, "null visible type annotations"); cfs->skip_u1(runtime_visible_type_annotations_length, CHECK); } else if (attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { if (runtime_invisible_type_annotations_exists) { @@ -1339,7 +1339,7 @@ void ClassFileParser::parse_field_attributes(const ClassFileStream* const cfs, if (PreserveAllAnnotations) { runtime_invisible_type_annotations_length = attribute_length; runtime_invisible_type_annotations = cfs->current(); - assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); + assert(runtime_invisible_type_annotations != nullptr, "null invisible type annotations"); } cfs->skip_u1(attribute_length, CHECK); } else { @@ -1466,14 +1466,14 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs, u2* const java_fields_count_ptr, TRAPS) { - assert(cfs != NULL, "invariant"); - assert(fac != NULL, "invariant"); - assert(cp != NULL, "invariant"); - assert(java_fields_count_ptr != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); + assert(fac != nullptr, "invariant"); + assert(cp != nullptr, "invariant"); + assert(java_fields_count_ptr != nullptr, "invariant"); - assert(NULL == _fields, "invariant"); - assert(NULL == _fields_annotations, "invariant"); - assert(NULL == _fields_type_annotations, "invariant"); + assert(nullptr == _fields, "invariant"); + assert(nullptr == _fields_annotations, "invariant"); + assert(nullptr == _fields_type_annotations, "invariant"); cfs->guarantee_more(2, CHECK); // length const u2 length = cfs->get_u2_fast(); @@ -1553,25 +1553,25 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs, &parsed_annotations, CHECK); - if (parsed_annotations.field_annotations() != NULL) { - if (_fields_annotations == NULL) { + if (parsed_annotations.field_annotations() != nullptr) { + if (_fields_annotations == nullptr) { _fields_annotations = MetadataFactory::new_array( - _loader_data, length, NULL, + _loader_data, length, nullptr, CHECK); } _fields_annotations->at_put(n, parsed_annotations.field_annotations()); - parsed_annotations.set_field_annotations(NULL); + parsed_annotations.set_field_annotations(nullptr); } - if (parsed_annotations.field_type_annotations() != NULL) { - if (_fields_type_annotations == NULL) { + if (parsed_annotations.field_type_annotations() != nullptr) { + if (_fields_type_annotations == nullptr) { _fields_type_annotations = MetadataFactory::new_array(_loader_data, length, - NULL, + nullptr, CHECK); } _fields_type_annotations->at_put(n, parsed_annotations.field_type_annotations()); - parsed_annotations.set_field_type_annotations(NULL); + parsed_annotations.set_field_type_annotations(nullptr); } if (is_synthetic) { @@ -1642,7 +1642,7 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs, } } - assert(NULL == _fields, "invariant"); + assert(nullptr == _fields, "invariant"); _fields = MetadataFactory::new_array(_loader_data, @@ -1671,8 +1671,8 @@ void ClassFileParser::parse_fields(const ClassFileStream* const cfs, THREAD, NameSigHash*, HASH_ROW_SIZE); initialize_hashtable(names_and_sigs); bool dup = false; - const Symbol* name = NULL; - const Symbol* sig = NULL; + const Symbol* name = nullptr; + const Symbol* sig = nullptr; { debug_only(NoSafepointVerifier nsv;) for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) { @@ -1697,10 +1697,10 @@ const ClassFileParser::unsafe_u2* ClassFileParser::parse_exception_table(const C u4 code_length, u4 exception_table_length, TRAPS) { - assert(cfs != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); const unsafe_u2* const exception_table_start = cfs->current(); - assert(exception_table_start != NULL, "null exception table"); + assert(exception_table_start != nullptr, "null exception table"); cfs->guarantee_more(8 * exception_table_length, CHECK_NULL); // start_pc, // end_pc, @@ -1749,7 +1749,7 @@ void ClassFileParser::parse_linenumber_table(u4 code_attribute_length, cfs->guarantee_more(length_in_bytes, CHECK); - if ((*write_stream) == NULL) { + if ((*write_stream) == nullptr) { if (length_in_bytes > fixed_buffer_size) { (*write_stream) = new CompressedLineNumberWriteStream(length_in_bytes); } else { @@ -1838,7 +1838,7 @@ const ClassFileParser::unsafe_u2* ClassFileParser::parse_localvariable_table(con } const unsafe_u2* const localvariable_table_start = cfs->current(); - assert(localvariable_table_start != NULL, "null local variable table"); + assert(localvariable_table_start != nullptr, "null local variable table"); if (!_need_verify) { cfs->skip_u2_fast(size); } else { @@ -1856,13 +1856,13 @@ const ClassFileParser::unsafe_u2* ClassFileParser::parse_localvariable_table(con classfile_parse_error( "Invalid start_pc %u in %s in class file %s", start_pc, tbl_name, THREAD); - return NULL; + return nullptr; } if (end_pc > code_length) { classfile_parse_error( "Invalid length %u in %s in class file %s", length, tbl_name, THREAD); - return NULL; + return nullptr; } const int cp_size = cp->length(); guarantee_property(valid_symbol_at(name_index), @@ -1897,20 +1897,20 @@ static const u1* parse_stackmap_table(const ClassFileStream* const cfs, u4 code_attribute_length, bool need_verify, TRAPS) { - assert(cfs != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); if (0 == code_attribute_length) { - return NULL; + return nullptr; } const u1* const stackmap_table_start = cfs->current(); - assert(stackmap_table_start != NULL, "null stackmap table"); + assert(stackmap_table_start != nullptr, "null stackmap table"); // check code_attribute_length first cfs->skip_u1(code_attribute_length, CHECK_NULL); if (!need_verify && !DumpSharedSpaces) { - return NULL; + return nullptr; } return stackmap_table_start; } @@ -1919,15 +1919,15 @@ const ClassFileParser::unsafe_u2* ClassFileParser::parse_checked_exceptions(cons u2* const checked_exceptions_length, u4 method_attribute_length, TRAPS) { - assert(cfs != NULL, "invariant"); - assert(checked_exceptions_length != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); + assert(checked_exceptions_length != nullptr, "invariant"); cfs->guarantee_more(2, CHECK_NULL); // checked_exceptions_length *checked_exceptions_length = cfs->get_u2_fast(); const unsigned int size = (*checked_exceptions_length) * sizeof(CheckedExceptionElement) / sizeof(u2); const unsafe_u2* const checked_exceptions_start = cfs->current(); - assert(checked_exceptions_start != NULL, "null checked exceptions"); + assert(checked_exceptions_start != nullptr, "null checked exceptions"); if (!_need_verify) { cfs->skip_u2_fast(size); } else { @@ -1956,8 +1956,8 @@ void ClassFileParser::throwIllegalSignature(const char* type, const Symbol* name, const Symbol* sig, TRAPS) const { - assert(name != NULL, "invariant"); - assert(sig != NULL, "invariant"); + assert(name != nullptr, "invariant"); + assert(sig != nullptr, "invariant"); ResourceMark rm(THREAD); Exceptions::fthrow(THREAD_AND_LOCATION, @@ -2096,7 +2096,7 @@ void MethodAnnotationCollector::apply_to(const methodHandle& m) { } void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) { - assert(ik != NULL, "invariant"); + assert(ik != nullptr, "invariant"); if (has_annotation(_jdk_internal_vm_annotation_Contended)) { ik->set_is_contended(is_contended()); } @@ -2172,7 +2172,7 @@ void ClassFileParser::copy_localvariable_table(const ConstMethod* cm, for (int idx = 0; idx < localvariable_type_table_length[tbl_no]; idx++) { copy_lvt_element(&cf_lvtt[idx], &lvtt_elem); LocalVariableTableElement** entry = table->get(lvtt_elem); - if (entry == NULL) { + if (entry == nullptr) { if (_need_verify) { classfile_parse_error("LVTT entry for '%s' in class file %s " "does not match any LVT entry", @@ -2237,7 +2237,7 @@ void ClassFileParser::copy_method_annotations(ConstMethod* cm, if (annotation_default_length > 0) { a = assemble_annotations(annotation_default, annotation_default_length, - NULL, + nullptr, 0, CHECK); cm->set_default_annotations(a); @@ -2267,9 +2267,9 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, const ConstantPool* cp, bool* const has_localvariable_table, TRAPS) { - assert(cfs != NULL, "invariant"); - assert(cp != NULL, "invariant"); - assert(has_localvariable_table != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); + assert(cp != nullptr, "invariant"); + assert(has_localvariable_table != nullptr, "invariant"); ResourceMark rm(THREAD); // Parse fixed parts: @@ -2302,7 +2302,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, flags &= JVM_ACC_STATIC | (_major_version <= JAVA_16_VERSION ? JVM_ACC_STRICT : 0); } else { classfile_parse_error("Method is not static in class file %s", THREAD); - return NULL; + return nullptr; } } else { verify_legal_method_modifiers(flags, is_interface, name, CHECK_NULL); @@ -2310,7 +2310,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, if (name == vmSymbols::object_initializer_name() && is_interface) { classfile_parse_error("Interface cannot have a method named , class file %s", THREAD); - return NULL; + return nullptr; } int args_size = -1; // only used when _need_verify is true @@ -2320,7 +2320,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, verify_legal_method_signature(name, signature, CHECK_NULL); if (args_size > MAX_ARGS_SIZE) { classfile_parse_error("Too many arguments in method signature in class file %s", THREAD); - return NULL; + return nullptr; } } @@ -2332,11 +2332,11 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, u4 code_length = 0; const u1* code_start = 0; u2 exception_table_length = 0; - const unsafe_u2* exception_table_start = NULL; // (potentially unaligned) pointer to array of u2 elements + const unsafe_u2* exception_table_start = nullptr; // (potentially unaligned) pointer to array of u2 elements Array* exception_handlers = Universe::the_empty_int_array(); u2 checked_exceptions_length = 0; - const unsafe_u2* checked_exceptions_start = NULL; // (potentially unaligned) pointer to array of u2 elements - CompressedLineNumberWriteStream* linenumber_table = NULL; + const unsafe_u2* checked_exceptions_start = nullptr; // (potentially unaligned) pointer to array of u2 elements + CompressedLineNumberWriteStream* linenumber_table = nullptr; int linenumber_table_length = 0; int total_lvt_length = 0; u2 lvt_cnt = 0; @@ -2344,37 +2344,37 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, bool lvt_allocated = false; u2 max_lvt_cnt = INITIAL_MAX_LVT_NUMBER; u2 max_lvtt_cnt = INITIAL_MAX_LVT_NUMBER; - u2* localvariable_table_length = NULL; - const unsafe_u2** localvariable_table_start = NULL; // (potentially unaligned) pointer to array of LVT attributes - u2* localvariable_type_table_length = NULL; - const unsafe_u2** localvariable_type_table_start = NULL; // (potentially unaligned) pointer to LVTT attributes + u2* localvariable_table_length = nullptr; + const unsafe_u2** localvariable_table_start = nullptr; // (potentially unaligned) pointer to array of LVT attributes + u2* localvariable_type_table_length = nullptr; + const unsafe_u2** localvariable_type_table_start = nullptr; // (potentially unaligned) pointer to LVTT attributes int method_parameters_length = -1; - const u1* method_parameters_data = NULL; + const u1* method_parameters_data = nullptr; bool method_parameters_seen = false; bool parsed_code_attribute = false; bool parsed_checked_exceptions_attribute = false; bool parsed_stackmap_attribute = false; // stackmap attribute - JDK1.5 - const u1* stackmap_data = NULL; + const u1* stackmap_data = nullptr; int stackmap_data_length = 0; u2 generic_signature_index = 0; MethodAnnotationCollector parsed_annotations; - const u1* runtime_visible_annotations = NULL; + const u1* runtime_visible_annotations = nullptr; int runtime_visible_annotations_length = 0; - const u1* runtime_invisible_annotations = NULL; + const u1* runtime_invisible_annotations = nullptr; int runtime_invisible_annotations_length = 0; - const u1* runtime_visible_parameter_annotations = NULL; + const u1* runtime_visible_parameter_annotations = nullptr; int runtime_visible_parameter_annotations_length = 0; - const u1* runtime_invisible_parameter_annotations = NULL; + const u1* runtime_invisible_parameter_annotations = nullptr; int runtime_invisible_parameter_annotations_length = 0; - const u1* runtime_visible_type_annotations = NULL; + const u1* runtime_visible_type_annotations = nullptr; int runtime_visible_type_annotations_length = 0; - const u1* runtime_invisible_type_annotations = NULL; + const u1* runtime_invisible_type_annotations = nullptr; int runtime_invisible_type_annotations_length = 0; bool runtime_invisible_annotations_exists = false; bool runtime_invisible_type_annotations_exists = false; bool runtime_invisible_parameter_annotations_exists = false; - const u1* annotation_default = NULL; + const u1* annotation_default = nullptr; int annotation_default_length = 0; // Parse code and exceptions attribute @@ -2400,7 +2400,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, if (parsed_code_attribute) { classfile_parse_error("Multiple Code attributes in class file %s", THREAD); - return NULL; + return nullptr; } parsed_code_attribute = true; @@ -2419,7 +2419,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, } // Code pointer code_start = cfs->current(); - assert(code_start != NULL, "null code start"); + assert(code_start != nullptr, "null code start"); cfs->guarantee_more(code_length, CHECK_NULL); cfs->skip_u1_fast(code_length); @@ -2533,7 +2533,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, // Stack map is only needed by the new verifier in JDK1.5. if (parsed_stackmap_attribute) { classfile_parse_error("Multiple StackMapTable attributes in class file %s", THREAD); - return NULL; + return nullptr; } stackmap_data = parse_stackmap_table(cfs, code_attribute_length, _need_verify, CHECK_NULL); stackmap_data_length = code_attribute_length; @@ -2554,7 +2554,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, if (parsed_checked_exceptions_attribute) { classfile_parse_error("Multiple Exceptions attributes in class file %s", THREAD); - return NULL; + return nullptr; } parsed_checked_exceptions_attribute = true; checked_exceptions_start = @@ -2567,7 +2567,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, if (method_parameters_seen) { classfile_parse_error("Multiple MethodParameters attributes in class file %s", THREAD); - return NULL; + return nullptr; } method_parameters_seen = true; method_parameters_length = cfs->get_u1_fast(); @@ -2576,7 +2576,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, classfile_parse_error( "Invalid MethodParameters method attribute length %u in class file", method_attribute_length, THREAD); - return NULL; + return nullptr; } method_parameters_data = cfs->current(); cfs->skip_u2_fast(method_parameters_length); @@ -2589,7 +2589,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, classfile_parse_error( "Invalid Synthetic method attribute length %u in class file %s", method_attribute_length, THREAD); - return NULL; + return nullptr; } // Should we check that there hasn't already been a synthetic attribute? access_flags.set_is_synthetic(); @@ -2598,7 +2598,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, classfile_parse_error( "Invalid Deprecated method attribute length %u in class file %s", method_attribute_length, THREAD); - return NULL; + return nullptr; } } else if (_major_version >= JAVA_1_5_VERSION) { if (method_attribute_name == vmSymbols::tag_signature()) { @@ -2606,25 +2606,25 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, classfile_parse_error( "Multiple Signature attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } if (method_attribute_length != 2) { classfile_parse_error( "Invalid Signature attribute length %u in class file %s", method_attribute_length, THREAD); - return NULL; + return nullptr; } generic_signature_index = parse_generic_signature_attribute(cfs, CHECK_NULL); } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) { - if (runtime_visible_annotations != NULL) { + if (runtime_visible_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleAnnotations attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } runtime_visible_annotations_length = method_attribute_length; runtime_visible_annotations = cfs->current(); - assert(runtime_visible_annotations != NULL, "null visible annotations"); + assert(runtime_visible_annotations != nullptr, "null visible annotations"); cfs->guarantee_more(runtime_visible_annotations_length, CHECK_NULL); parse_annotations(cp, runtime_visible_annotations, @@ -2638,62 +2638,62 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, classfile_parse_error( "Multiple RuntimeInvisibleAnnotations attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } runtime_invisible_annotations_exists = true; if (PreserveAllAnnotations) { runtime_invisible_annotations_length = method_attribute_length; runtime_invisible_annotations = cfs->current(); - assert(runtime_invisible_annotations != NULL, "null invisible annotations"); + assert(runtime_invisible_annotations != nullptr, "null invisible annotations"); } cfs->skip_u1(method_attribute_length, CHECK_NULL); } else if (method_attribute_name == vmSymbols::tag_runtime_visible_parameter_annotations()) { - if (runtime_visible_parameter_annotations != NULL) { + if (runtime_visible_parameter_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleParameterAnnotations attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } runtime_visible_parameter_annotations_length = method_attribute_length; runtime_visible_parameter_annotations = cfs->current(); - assert(runtime_visible_parameter_annotations != NULL, "null visible parameter annotations"); + assert(runtime_visible_parameter_annotations != nullptr, "null visible parameter annotations"); cfs->skip_u1(runtime_visible_parameter_annotations_length, CHECK_NULL); } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_parameter_annotations()) { if (runtime_invisible_parameter_annotations_exists) { classfile_parse_error( "Multiple RuntimeInvisibleParameterAnnotations attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } runtime_invisible_parameter_annotations_exists = true; if (PreserveAllAnnotations) { runtime_invisible_parameter_annotations_length = method_attribute_length; runtime_invisible_parameter_annotations = cfs->current(); - assert(runtime_invisible_parameter_annotations != NULL, + assert(runtime_invisible_parameter_annotations != nullptr, "null invisible parameter annotations"); } cfs->skip_u1(method_attribute_length, CHECK_NULL); } else if (method_attribute_name == vmSymbols::tag_annotation_default()) { - if (annotation_default != NULL) { + if (annotation_default != nullptr) { classfile_parse_error( "Multiple AnnotationDefault attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } annotation_default_length = method_attribute_length; annotation_default = cfs->current(); - assert(annotation_default != NULL, "null annotation default"); + assert(annotation_default != nullptr, "null annotation default"); cfs->skip_u1(annotation_default_length, CHECK_NULL); } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) { - if (runtime_visible_type_annotations != NULL) { + if (runtime_visible_type_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleTypeAnnotations attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } runtime_visible_type_annotations_length = method_attribute_length; runtime_visible_type_annotations = cfs->current(); - assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); + assert(runtime_visible_type_annotations != nullptr, "null visible type annotations"); // No need for the VM to parse Type annotations cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_NULL); } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) { @@ -2701,14 +2701,14 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, classfile_parse_error( "Multiple RuntimeInvisibleTypeAnnotations attributes for method in class file %s", THREAD); - return NULL; + return nullptr; } else { runtime_invisible_type_annotations_exists = true; } if (PreserveAllAnnotations) { runtime_invisible_type_annotations_length = method_attribute_length; runtime_invisible_type_annotations = cfs->current(); - assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); + assert(runtime_invisible_type_annotations != nullptr, "null invisible type annotations"); } cfs->skip_u1(method_attribute_length, CHECK_NULL); } else { @@ -2721,7 +2721,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, } } - if (linenumber_table != NULL) { + if (linenumber_table != nullptr) { linenumber_table->write_terminator(); linenumber_table_length = linenumber_table->position(); } @@ -2772,7 +2772,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, // Fill in code attribute information m->set_max_stack(max_stack); m->set_max_locals(max_locals); - if (stackmap_data != NULL) { + if (stackmap_data != nullptr) { m->constMethod()->copy_stackmap_data(_loader_data, (u1*)stackmap_data, stackmap_data_length, @@ -2783,7 +2783,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, m->set_code((u1*)code_start); // Copy line number table - if (linenumber_table != NULL) { + if (linenumber_table != nullptr) { memcpy(m->compressed_linenumber_table(), linenumber_table->buffer(), linenumber_table_length); @@ -2881,12 +2881,12 @@ void ClassFileParser::parse_methods(const ClassFileStream* const cfs, bool* has_final_method, bool* declares_nonstatic_concrete_methods, TRAPS) { - assert(cfs != NULL, "invariant"); - assert(has_localvariable_table != NULL, "invariant"); - assert(has_final_method != NULL, "invariant"); - assert(declares_nonstatic_concrete_methods != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); + assert(has_localvariable_table != nullptr, "invariant"); + assert(has_final_method != nullptr, "invariant"); + assert(declares_nonstatic_concrete_methods != nullptr, "invariant"); - assert(NULL == _methods, "invariant"); + assert(nullptr == _methods, "invariant"); cfs->guarantee_more(2, CHECK); // length const u2 length = cfs->get_u2_fast(); @@ -2895,7 +2895,7 @@ void ClassFileParser::parse_methods(const ClassFileStream* const cfs, } else { _methods = MetadataFactory::new_array(_loader_data, length, - NULL, + nullptr, CHECK); for (int index = 0; index < length; index++) { @@ -2924,8 +2924,8 @@ void ClassFileParser::parse_methods(const ClassFileStream* const cfs, THREAD, NameSigHash*, HASH_ROW_SIZE); initialize_hashtable(names_and_sigs); bool dup = false; - const Symbol* name = NULL; - const Symbol* sig = NULL; + const Symbol* name = nullptr; + const Symbol* sig = nullptr; { debug_only(NoSafepointVerifier nsv;) for (int i = 0; i < length; i++) { @@ -2965,7 +2965,7 @@ static const intArray* sort_methods(Array* methods) { // Note that the ordering is not alphabetical, see Symbol::fast_compare Method::sort_methods(methods); - intArray* method_ordering = NULL; + intArray* method_ordering = nullptr; // If JVMTI original method ordering or sharing is enabled construct int // array remembering the original ordering if (JvmtiExport::can_maintain_original_method_order() || Arguments::is_dumping_archive()) { @@ -2984,7 +2984,7 @@ static const intArray* sort_methods(Array* methods) { // Parse generic_signature attribute for methods and fields u2 ClassFileParser::parse_generic_signature_attribute(const ClassFileStream* const cfs, TRAPS) { - assert(cfs != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); cfs->guarantee_more(2, CHECK_0); // generic_signature_index const u2 generic_signature_index = cfs->get_u2_fast(); @@ -2998,7 +2998,7 @@ u2 ClassFileParser::parse_generic_signature_attribute(const ClassFileStream* con void ClassFileParser::parse_classfile_sourcefile_attribute(const ClassFileStream* const cfs, TRAPS) { - assert(cfs != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); cfs->guarantee_more(2, CHECK); // sourcefile_index const u2 sourcefile_index = cfs->get_u2_fast(); @@ -3012,10 +3012,10 @@ void ClassFileParser::parse_classfile_sourcefile_attribute(const ClassFileStream void ClassFileParser::parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs, int length, TRAPS) { - assert(cfs != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); const u1* const sde_buffer = cfs->current(); - assert(sde_buffer != NULL, "null sde buffer"); + assert(sde_buffer != nullptr, "null sde buffer"); // Don't bother storing it if there is no way to retrieve it if (JvmtiExport::can_get_source_debug_extension()) { @@ -3125,7 +3125,7 @@ u2 ClassFileParser::parse_classfile_inner_classes_attribute(const ClassFileStrea TRAPS) { const u1* const current_mark = cfs->current(); u2 length = 0; - if (inner_classes_attribute_start != NULL) { + if (inner_classes_attribute_start != nullptr) { cfs->set_current(inner_classes_attribute_start); cfs->guarantee_more(2, CHECK_0); // length length = cfs->get_u2_fast(); @@ -3232,7 +3232,7 @@ u2 ClassFileParser::parse_classfile_nest_members_attribute(const ClassFileStream TRAPS) { const u1* const current_mark = cfs->current(); u2 length = 0; - if (nest_members_attribute_start != NULL) { + if (nest_members_attribute_start != nullptr) { cfs->set_current(nest_members_attribute_start); cfs->guarantee_more(2, CHECK_0); // length length = cfs->get_u2_fast(); @@ -3264,7 +3264,7 @@ u2 ClassFileParser::parse_classfile_permitted_subclasses_attribute(const ClassFi TRAPS) { const u1* const current_mark = cfs->current(); u2 length = 0; - if (permitted_subclasses_attribute_start != NULL) { + if (permitted_subclasses_attribute_start != nullptr) { cfs->set_current(permitted_subclasses_attribute_start); cfs->guarantee_more(2, CHECK_0); // length length = cfs->get_u2_fast(); @@ -3312,7 +3312,7 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons const u1* const current_mark = cfs->current(); int components_count = 0; unsigned int calculate_attr_size = 0; - if (record_attribute_start != NULL) { + if (record_attribute_start != nullptr) { cfs->set_current(record_attribute_start); cfs->guarantee_more(2, CHECK_0); // num of components components_count = (int)cfs->get_u2_fast(); @@ -3320,7 +3320,7 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons } Array* const record_components = - MetadataFactory::new_array(_loader_data, components_count, NULL, CHECK_0); + MetadataFactory::new_array(_loader_data, components_count, nullptr, CHECK_0); _record_components = record_components; for (int x = 0; x < components_count; x++) { @@ -3343,14 +3343,14 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons const u2 attributes_count = cfs->get_u2_fast(); calculate_attr_size += 6; u2 generic_sig_index = 0; - const u1* runtime_visible_annotations = NULL; + const u1* runtime_visible_annotations = nullptr; int runtime_visible_annotations_length = 0; - const u1* runtime_invisible_annotations = NULL; + const u1* runtime_invisible_annotations = nullptr; int runtime_invisible_annotations_length = 0; bool runtime_invisible_annotations_exists = false; - const u1* runtime_visible_type_annotations = NULL; + const u1* runtime_visible_type_annotations = nullptr; int runtime_visible_type_annotations_length = 0; - const u1* runtime_invisible_type_annotations = NULL; + const u1* runtime_invisible_type_annotations = nullptr; int runtime_invisible_type_annotations_length = 0; bool runtime_invisible_type_annotations_exists = false; @@ -3383,7 +3383,7 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons generic_sig_index = parse_generic_signature_attribute(cfs, CHECK_0); } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) { - if (runtime_visible_annotations != NULL) { + if (runtime_visible_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleAnnotations attributes for Record component in class file %s", THREAD); return 0; @@ -3391,7 +3391,7 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons runtime_visible_annotations_length = attribute_length; runtime_visible_annotations = cfs->current(); - assert(runtime_visible_annotations != NULL, "null record component visible annotation"); + assert(runtime_visible_annotations != nullptr, "null record component visible annotation"); cfs->guarantee_more(runtime_visible_annotations_length, CHECK_0); cfs->skip_u1_fast(runtime_visible_annotations_length); @@ -3405,12 +3405,12 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons if (PreserveAllAnnotations) { runtime_invisible_annotations_length = attribute_length; runtime_invisible_annotations = cfs->current(); - assert(runtime_invisible_annotations != NULL, "null record component invisible annotation"); + assert(runtime_invisible_annotations != nullptr, "null record component invisible annotation"); } cfs->skip_u1(attribute_length, CHECK_0); } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) { - if (runtime_visible_type_annotations != NULL) { + if (runtime_visible_type_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleTypeAnnotations attributes for Record component in class file %s", THREAD); return 0; @@ -3418,7 +3418,7 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons runtime_visible_type_annotations_length = attribute_length; runtime_visible_type_annotations = cfs->current(); - assert(runtime_visible_type_annotations != NULL, "null record component visible type annotation"); + assert(runtime_visible_type_annotations != nullptr, "null record component visible type annotation"); cfs->guarantee_more(runtime_visible_type_annotations_length, CHECK_0); cfs->skip_u1_fast(runtime_visible_type_annotations_length); @@ -3432,7 +3432,7 @@ u2 ClassFileParser::parse_classfile_record_attribute(const ClassFileStream* cons if (PreserveAllAnnotations) { runtime_invisible_type_annotations_length = attribute_length; runtime_invisible_type_annotations = cfs->current(); - assert(runtime_invisible_type_annotations != NULL, "null record component invisible type annotation"); + assert(runtime_invisible_type_annotations != nullptr, "null record component invisible type annotation"); } cfs->skip_u1(attribute_length, CHECK_0); @@ -3471,7 +3471,7 @@ void ClassFileParser::parse_classfile_synthetic_attribute() { } void ClassFileParser::parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS) { - assert(cfs != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); const u2 signature_index = cfs->get_u2(CHECK); check_property( @@ -3485,8 +3485,8 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil ConstantPool* cp, u4 attribute_byte_length, TRAPS) { - assert(cfs != NULL, "invariant"); - assert(cp != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); + assert(cp != nullptr, "invariant"); const u1* const current_start = cfs->current(); @@ -3567,9 +3567,9 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf ConstantPool* cp, ClassFileParser::ClassAnnotationCollector* parsed_annotations, TRAPS) { - assert(cfs != NULL, "invariant"); - assert(cp != NULL, "invariant"); - assert(parsed_annotations != NULL, "invariant"); + assert(cfs != nullptr, "invariant"); + assert(cp != nullptr, "invariant"); + assert(parsed_annotations != nullptr, "invariant"); // Set inner classes attribute to default sentinel _inner_classes = Universe::the_empty_short_array(); @@ -3587,26 +3587,26 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf bool parsed_record_attribute = false; bool parsed_enclosingmethod_attribute = false; bool parsed_bootstrap_methods_attribute = false; - const u1* runtime_visible_annotations = NULL; + const u1* runtime_visible_annotations = nullptr; int runtime_visible_annotations_length = 0; - const u1* runtime_invisible_annotations = NULL; + const u1* runtime_invisible_annotations = nullptr; int runtime_invisible_annotations_length = 0; - const u1* runtime_visible_type_annotations = NULL; + const u1* runtime_visible_type_annotations = nullptr; int runtime_visible_type_annotations_length = 0; - const u1* runtime_invisible_type_annotations = NULL; + const u1* runtime_invisible_type_annotations = nullptr; int runtime_invisible_type_annotations_length = 0; bool runtime_invisible_type_annotations_exists = false; bool runtime_invisible_annotations_exists = false; bool parsed_source_debug_ext_annotations_exist = false; - const u1* inner_classes_attribute_start = NULL; + const u1* inner_classes_attribute_start = nullptr; u4 inner_classes_attribute_length = 0; u2 enclosing_method_class_index = 0; u2 enclosing_method_method_index = 0; - const u1* nest_members_attribute_start = NULL; + const u1* nest_members_attribute_start = nullptr; u4 nest_members_attribute_length = 0; - const u1* record_attribute_start = NULL; + const u1* record_attribute_start = nullptr; u4 record_attribute_length = 0; - const u1* permitted_subclasses_attribute_start = NULL; + const u1* permitted_subclasses_attribute_start = nullptr; u4 permitted_subclasses_attribute_length = 0; // Iterate over attributes @@ -3684,14 +3684,14 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf } parse_classfile_signature_attribute(cfs, CHECK); } else if (tag == vmSymbols::tag_runtime_visible_annotations()) { - if (runtime_visible_annotations != NULL) { + if (runtime_visible_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleAnnotations attributes in class file %s", THREAD); return; } runtime_visible_annotations_length = attribute_length; runtime_visible_annotations = cfs->current(); - assert(runtime_visible_annotations != NULL, "null visible annotations"); + assert(runtime_visible_annotations != nullptr, "null visible annotations"); cfs->guarantee_more(runtime_visible_annotations_length, CHECK); parse_annotations(cp, runtime_visible_annotations, @@ -3710,7 +3710,7 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf if (PreserveAllAnnotations) { runtime_invisible_annotations_length = attribute_length; runtime_invisible_annotations = cfs->current(); - assert(runtime_invisible_annotations != NULL, "null invisible annotations"); + assert(runtime_invisible_annotations != nullptr, "null invisible annotations"); } cfs->skip_u1(attribute_length, CHECK); } else if (tag == vmSymbols::tag_enclosing_method()) { @@ -3748,14 +3748,14 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf parsed_bootstrap_methods_attribute = true; parse_classfile_bootstrap_methods_attribute(cfs, cp, attribute_length, CHECK); } else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) { - if (runtime_visible_type_annotations != NULL) { + if (runtime_visible_type_annotations != nullptr) { classfile_parse_error( "Multiple RuntimeVisibleTypeAnnotations attributes in class file %s", THREAD); return; } runtime_visible_type_annotations_length = attribute_length; runtime_visible_type_annotations = cfs->current(); - assert(runtime_visible_type_annotations != NULL, "null visible type annotations"); + assert(runtime_visible_type_annotations != nullptr, "null visible type annotations"); // No need for the VM to parse Type annotations cfs->skip_u1(runtime_visible_type_annotations_length, CHECK); } else if (tag == vmSymbols::tag_runtime_invisible_type_annotations()) { @@ -3769,7 +3769,7 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf if (PreserveAllAnnotations) { runtime_invisible_type_annotations_length = attribute_length; runtime_invisible_type_annotations = cfs->current(); - assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations"); + assert(runtime_invisible_type_annotations != nullptr, "null invisible type annotations"); } cfs->skip_u1(attribute_length, CHECK); } else if (_major_version >= JAVA_11_VERSION) { @@ -3921,7 +3921,7 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf } void ClassFileParser::apply_parsed_class_attributes(InstanceKlass* k) { - assert(k != NULL, "invariant"); + assert(k != nullptr, "invariant"); if (_synthetic_flag) k->set_is_synthetic(); @@ -3931,7 +3931,7 @@ void ClassFileParser::apply_parsed_class_attributes(InstanceKlass* k) { if (_generic_signature_index != 0) { k->set_generic_signature_index(_generic_signature_index); } - if (_sde_buffer != NULL) { + if (_sde_buffer != nullptr) { k->set_source_debug_extension(_sde_buffer, _sde_length); } } @@ -3939,10 +3939,10 @@ void ClassFileParser::apply_parsed_class_attributes(InstanceKlass* k) { // Create the Annotations object that will // hold the annotations array for the Klass. void ClassFileParser::create_combined_annotations(TRAPS) { - if (_class_annotations == NULL && - _class_type_annotations == NULL && - _fields_annotations == NULL && - _fields_type_annotations == NULL) { + if (_class_annotations == nullptr && + _class_type_annotations == nullptr && + _fields_annotations == nullptr && + _fields_type_annotations == nullptr) { // Don't create the Annotations object unnecessarily. return; } @@ -3959,17 +3959,17 @@ void ClassFileParser::create_combined_annotations(TRAPS) { // The annotations arrays below has been transferred the // _combined_annotations so these fields can now be cleared. - _class_annotations = NULL; - _class_type_annotations = NULL; - _fields_annotations = NULL; - _fields_type_annotations = NULL; + _class_annotations = nullptr; + _class_type_annotations = nullptr; + _fields_annotations = nullptr; + _fields_type_annotations = nullptr; } // Transfer ownership of metadata allocated to the InstanceKlass. void ClassFileParser::apply_parsed_class_metadata( InstanceKlass* this_klass, int java_fields_count) { - assert(this_klass != NULL, "invariant"); + assert(this_klass != nullptr, "invariant"); _cp->set_pool_holder(this_klass); this_klass->set_constants(_cp); @@ -3998,19 +3998,19 @@ AnnotationArray* ClassFileParser::assemble_annotations(const u1* const runtime_v const u1* const runtime_invisible_annotations, int runtime_invisible_annotations_length, TRAPS) { - AnnotationArray* annotations = NULL; - if (runtime_visible_annotations != NULL || - runtime_invisible_annotations != NULL) { + AnnotationArray* annotations = nullptr; + if (runtime_visible_annotations != nullptr || + runtime_invisible_annotations != nullptr) { annotations = MetadataFactory::new_array(_loader_data, runtime_visible_annotations_length + runtime_invisible_annotations_length, CHECK_(annotations)); - if (runtime_visible_annotations != NULL) { + if (runtime_visible_annotations != nullptr) { for (int i = 0; i < runtime_visible_annotations_length; i++) { annotations->at_put(i, runtime_visible_annotations[i]); } } - if (runtime_invisible_annotations != NULL) { + if (runtime_invisible_annotations != nullptr) { for (int i = 0; i < runtime_invisible_annotations_length; i++) { int append = runtime_visible_annotations_length+i; annotations->at_put(append, runtime_invisible_annotations[i]); @@ -4024,8 +4024,8 @@ const InstanceKlass* ClassFileParser::parse_super_class(ConstantPool* const cp, const int super_class_index, const bool need_verify, TRAPS) { - assert(cp != NULL, "invariant"); - const InstanceKlass* super_klass = NULL; + assert(cp != nullptr, "invariant"); + const InstanceKlass* super_klass = nullptr; if (super_class_index == 0) { check_property(_class_name == vmSymbols::java_lang_Object(), @@ -4059,7 +4059,7 @@ OopMapBlocksBuilder::OopMapBlocksBuilder(unsigned int max_blocks) { _max_nonstatic_oop_maps = max_blocks; _nonstatic_oop_map_count = 0; if (max_blocks == 0) { - _nonstatic_oop_maps = NULL; + _nonstatic_oop_maps = nullptr; } else { _nonstatic_oop_maps = NEW_RESOURCE_ARRAY(OopMapBlock, _max_nonstatic_oop_maps); @@ -4172,7 +4172,7 @@ void OopMapBlocksBuilder::print_value_on(outputStream* st) const { } void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) { - assert(ik != NULL, "invariant"); + assert(ik != nullptr, "invariant"); const Klass* const super = ik->super(); @@ -4180,7 +4180,7 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) { // in which case we don't have to register objects as finalizable if (!_has_empty_finalizer) { if (_has_finalizer || - (super != NULL && super->has_finalizer())) { + (super != nullptr && super->has_finalizer())) { ik->set_has_finalizer(); } } @@ -4190,7 +4190,7 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) { const Method* const m = ik->lookup_method(vmSymbols::finalize_method_name(), vmSymbols::void_method_signature()); if (InstanceKlass::is_finalization_enabled() && - (m != NULL) && !m->is_empty_method()) { + (m != nullptr) && !m->is_empty_method()) { f = true; } @@ -4210,7 +4210,7 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) { } // Check if this klass has a vanilla default constructor - if (super == NULL) { + if (super == nullptr) { // java.lang.Object has empty default constructor ik->set_has_vanilla_constructor(); } else { @@ -4224,7 +4224,7 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) { const Method* const constructor = ik->find_method(vmSymbols::object_initializer_name(), vmSymbols::void_method_signature()); - if (constructor != NULL && constructor->is_vanilla_constructor()) { + if (constructor != nullptr && constructor->is_vanilla_constructor()) { v = true; } } @@ -4237,7 +4237,7 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) { assert(ik->size_helper() > 0, "layout_helper is initialized"); if ((!RegisterFinalizersAtInit && ik->has_finalizer()) || ik->is_abstract() || ik->is_interface() - || (ik->name() == vmSymbols::java_lang_Class() && ik->class_loader() == NULL) + || (ik->name() == vmSymbols::java_lang_Class() && ik->class_loader() == nullptr) || ik->size_helper() >= FastAllocateSizeLimit) { // Forbid fast-path allocation. const jint lh = Klass::instance_layout_helper(ik->size_helper(), true); @@ -4262,14 +4262,14 @@ static Array* compute_transitive_interfaces(const InstanceKlass* Array* local_ifs, ClassLoaderData* loader_data, TRAPS) { - assert(local_ifs != NULL, "invariant"); - assert(loader_data != NULL, "invariant"); + assert(local_ifs != nullptr, "invariant"); + assert(loader_data != nullptr, "invariant"); // Compute maximum size for transitive interfaces int max_transitive_size = 0; int super_size = 0; // Add superclass transitive interfaces size - if (super != NULL) { + if (super != nullptr) { super_size = super->transitive_interfaces()->length(); max_transitive_size += super_size; } @@ -4296,7 +4296,7 @@ static Array* compute_transitive_interfaces(const InstanceKlass* GrowableArray* const result = new GrowableArray(max_transitive_size); // Copy down from superclass - if (super != NULL) { + if (super != nullptr) { append_interfaces(result, super->transitive_interfaces()); } @@ -4315,7 +4315,7 @@ static Array* compute_transitive_interfaces(const InstanceKlass* MetadataFactory::new_array(loader_data, length, CHECK_NULL); for (int i = 0; i < length; i++) { InstanceKlass* const e = result->at(i); - assert(e != NULL, "just checking"); + assert(e != nullptr, "just checking"); new_result->at_put(i, e); } return new_result; @@ -4323,10 +4323,10 @@ static Array* compute_transitive_interfaces(const InstanceKlass* } void ClassFileParser::check_super_class_access(const InstanceKlass* this_klass, TRAPS) { - assert(this_klass != NULL, "invariant"); + assert(this_klass != nullptr, "invariant"); const Klass* const super = this_klass->super(); - if (super != NULL) { + if (super != nullptr) { const InstanceKlass* super_ik = InstanceKlass::cast(super); if (super->is_final()) { @@ -4344,7 +4344,7 @@ void ClassFileParser::check_super_class_access(const InstanceKlass* this_klass, // special reflection class loader if (!this_klass->class_loader_data()->is_the_null_class_loader_data()) { PackageEntry* super_package = super->package(); - if (super_package != NULL && + if (super_package != nullptr && super_package->name()->fast_compare(vmSymbols::jdk_internal_reflect()) == 0 && !java_lang_ClassLoader::is_reflection_class_loader(this_klass->class_loader())) { ResourceMark rm(THREAD); @@ -4366,7 +4366,7 @@ void ClassFileParser::check_super_class_access(const InstanceKlass* this_klass, char* msg = Reflection::verify_class_access_msg(this_klass, InstanceKlass::cast(super), vca_result); - if (msg == NULL) { + if (msg == nullptr) { bool same_module = (this_klass->module() == super->module()); Exceptions::fthrow( THREAD_AND_LOCATION, @@ -4392,12 +4392,12 @@ void ClassFileParser::check_super_class_access(const InstanceKlass* this_klass, void ClassFileParser::check_super_interface_access(const InstanceKlass* this_klass, TRAPS) { - assert(this_klass != NULL, "invariant"); + assert(this_klass != nullptr, "invariant"); const Array* const local_interfaces = this_klass->local_interfaces(); const int lng = local_interfaces->length(); for (int i = lng - 1; i >= 0; i--) { InstanceKlass* const k = local_interfaces->at(i); - assert (k != NULL && k->is_interface(), "invalid interface"); + assert (k != nullptr && k->is_interface(), "invalid interface"); if (k->is_sealed() && !k->has_as_permitted_subclass(this_klass)) { classfile_icce_error(this_klass->is_interface() ? @@ -4414,7 +4414,7 @@ void ClassFileParser::check_super_interface_access(const InstanceKlass* this_kla char* msg = Reflection::verify_class_access_msg(this_klass, k, vca_result); - if (msg == NULL) { + if (msg == nullptr) { bool same_module = (this_klass->module() == k->module()); Exceptions::fthrow( THREAD_AND_LOCATION, @@ -4439,7 +4439,7 @@ void ClassFileParser::check_super_interface_access(const InstanceKlass* this_kla static void check_final_method_override(const InstanceKlass* this_klass, TRAPS) { - assert(this_klass != NULL, "invariant"); + assert(this_klass != nullptr, "invariant"); const Array* const methods = this_klass->methods(); const int num_methods = methods->length(); @@ -4454,13 +4454,13 @@ static void check_final_method_override(const InstanceKlass* this_klass, TRAPS) const Symbol* const name = m->name(); const Symbol* const signature = m->signature(); const Klass* k = this_klass->super(); - const Method* super_m = NULL; - while (k != NULL) { + const Method* super_m = nullptr; + while (k != nullptr) { // skip supers that don't have final methods. if (k->has_final_method()) { // lookup a matching method in the super class hierarchy super_m = InstanceKlass::cast(k)->lookup_method(name, signature); - if (super_m == NULL) { + if (super_m == nullptr) { break; // didn't find any match; get out } @@ -4498,7 +4498,7 @@ static void check_final_method_override(const InstanceKlass* this_klass, TRAPS) // assumes that this_klass is an interface static void check_illegal_static_method(const InstanceKlass* this_klass, TRAPS) { - assert(this_klass != NULL, "invariant"); + assert(this_klass != nullptr, "invariant"); assert(this_klass->is_interface(), "not an interface"); const Array* methods = this_klass->methods(); const int num_methods = methods->length(); @@ -4801,7 +4801,7 @@ bool ClassFileParser::verify_unqualified_name(const char* name, // Skip over the longest part of the string that could // be taken as a fieldname. Allow non-trailing '/'s if slash_ok is true. // Return a pointer to just past the fieldname. -// Return NULL if no fieldname at all was found, or in the case of slash_ok +// Return null if no fieldname at all was found, or in the case of slash_ok // being true, we saw consecutive slashes (meaning we were looking for a // qualified path but found something that was badly-formed). static const char* skip_over_field_name(const char* const name, @@ -4826,7 +4826,7 @@ static const char* skip_over_field_name(const char* const name, } if (slash_ok && ch == JVM_SIGNATURE_SLASH) { if (last_is_slash) { - return NULL; // Don't permit consecutive slashes + return nullptr; // Don't permit consecutive slashes } last_is_slash = true; continue; @@ -4865,22 +4865,22 @@ static const char* skip_over_field_name(const char* const name, } if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; - return NULL; + return nullptr; } if(result.get_jboolean()) { continue; } } - return (not_first_ch) ? old_p : NULL; + return (not_first_ch) ? old_p : nullptr; } - return (not_first_ch && !last_is_slash) ? p : NULL; + return (not_first_ch && !last_is_slash) ? p : nullptr; } // Take pointer to a UTF8 byte string (not NUL-terminated). // Skip over the longest part of the string that could // be taken as a field signature. Allow "void" if void_ok. // Return a pointer to just past the signature. -// Return NULL if no legal signature is found. +// Return null if no legal signature is found. const char* ClassFileParser::skip_over_field_signature(const char* signature, bool void_ok, unsigned int length, @@ -4888,7 +4888,7 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, unsigned int array_dim = 0; while (length > 0) { switch (signature[0]) { - case JVM_SIGNATURE_VOID: if (!void_ok) { return NULL; } + case JVM_SIGNATURE_VOID: if (!void_ok) { return nullptr; } case JVM_SIGNATURE_BOOLEAN: case JVM_SIGNATURE_BYTE: case JVM_SIGNATURE_CHAR: @@ -4913,26 +4913,26 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, signature++; const char* c = (const char*) memchr(signature, JVM_SIGNATURE_ENDCLASS, length - 1); // Format check signature - if (c != NULL) { + if (c != nullptr) { int newlen = c - (char*) signature; bool legal = verify_unqualified_name(signature, newlen, LegalClass); if (!legal) { classfile_parse_error("Class name is empty or contains illegal character " "in descriptor in class file %s", THREAD); - return NULL; + return nullptr; } return signature + newlen + 1; } } - return NULL; + return nullptr; } case JVM_SIGNATURE_ARRAY: array_dim++; if (array_dim > 255) { // 4277370: array descriptor is valid only if it represents 255 or fewer dimensions. classfile_parse_error("Array type descriptor has more than 255 dimensions in class file %s", THREAD); - return NULL; + return nullptr; } // The rest of what's there better be a legal signature signature++; @@ -4940,10 +4940,10 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature, void_ok = false; break; default: - return NULL; + return nullptr; } } - return NULL; + return nullptr; } // Checks if name is a legal class name. @@ -4959,11 +4959,11 @@ void ClassFileParser::verify_legal_class_name(const Symbol* name, TRAPS) const { const char* p; if (bytes[0] == JVM_SIGNATURE_ARRAY) { p = skip_over_field_signature(bytes, false, length, CHECK); - legal = (p != NULL) && ((p - bytes) == (int)length); + legal = (p != nullptr) && ((p - bytes) == (int)length); } else if (_major_version < JAVA_1_5_VERSION) { if (bytes[0] != JVM_SIGNATURE_SPECIAL) { p = skip_over_field_name(bytes, true, length); - legal = (p != NULL) && ((p - bytes) == (int)length); + legal = (p != nullptr) && ((p - bytes) == (int)length); } } else { // 4900761: relax the constraints based on JSR202 spec @@ -4975,7 +4975,7 @@ void ClassFileParser::verify_legal_class_name(const Symbol* name, TRAPS) const { } if (!legal) { ResourceMark rm(THREAD); - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), @@ -4998,7 +4998,7 @@ void ClassFileParser::verify_legal_field_name(const Symbol* name, TRAPS) const { if (_major_version < JAVA_1_5_VERSION) { if (bytes[0] != JVM_SIGNATURE_SPECIAL) { const char* p = skip_over_field_name(bytes, false, length); - legal = (p != NULL) && ((p - bytes) == (int)length); + legal = (p != nullptr) && ((p - bytes) == (int)length); } } else { // 4881221: relax the constraints based on JSR202 spec @@ -5008,7 +5008,7 @@ void ClassFileParser::verify_legal_field_name(const Symbol* name, TRAPS) const { if (!legal) { ResourceMark rm(THREAD); - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), @@ -5023,7 +5023,7 @@ void ClassFileParser::verify_legal_field_name(const Symbol* name, TRAPS) const { void ClassFileParser::verify_legal_method_name(const Symbol* name, TRAPS) const { if (!_need_verify || _relax_verify) { return; } - assert(name != NULL, "method name is null"); + assert(name != nullptr, "method name is null"); char* bytes = (char*)name->bytes(); unsigned int length = name->utf8_length(); bool legal = false; @@ -5036,7 +5036,7 @@ void ClassFileParser::verify_legal_method_name(const Symbol* name, TRAPS) const } else if (_major_version < JAVA_1_5_VERSION) { const char* p; p = skip_over_field_name(bytes, false, length); - legal = (p != NULL) && ((p - bytes) == (int)length); + legal = (p != nullptr) && ((p - bytes) == (int)length); } else { // 4881221: relax the constraints based on JSR202 spec legal = verify_unqualified_name(bytes, length, LegalMethod); @@ -5045,7 +5045,7 @@ void ClassFileParser::verify_legal_method_name(const Symbol* name, TRAPS) const if (!legal) { ResourceMark rm(THREAD); - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(), @@ -5067,7 +5067,7 @@ void ClassFileParser::verify_legal_field_signature(const Symbol* name, const unsigned int length = signature->utf8_length(); const char* const p = skip_over_field_signature(bytes, false, length, CHECK); - if (p == NULL || (p - bytes) != (int)length) { + if (p == nullptr || (p - bytes) != (int)length) { throwIllegalSignature("Field", name, signature, CHECK); } } @@ -5119,7 +5119,7 @@ int ClassFileParser::verify_legal_method_signature(const Symbol* name, length--; // Skip over legal field signatures nextp = skip_over_field_signature(p, false, length, CHECK_0); - while ((length > 0) && (nextp != NULL)) { + while ((length > 0) && (nextp != nullptr)) { args_size++; if (p[0] == 'J' || p[0] == 'D') { args_size++; @@ -5144,24 +5144,24 @@ int ClassFileParser::verify_legal_method_signature(const Symbol* name, } int ClassFileParser::static_field_size() const { - assert(_field_info != NULL, "invariant"); + assert(_field_info != nullptr, "invariant"); return _field_info->_static_field_size; } int ClassFileParser::total_oop_map_count() const { - assert(_field_info != NULL, "invariant"); + assert(_field_info != nullptr, "invariant"); return _field_info->oop_map_blocks->_nonstatic_oop_map_count; } jint ClassFileParser::layout_size() const { - assert(_field_info != NULL, "invariant"); + assert(_field_info != nullptr, "invariant"); return _field_info->_instance_size; } static void check_methods_for_intrinsics(const InstanceKlass* ik, const Array* methods) { - assert(ik != NULL, "invariant"); - assert(methods != NULL, "invariant"); + assert(ik != nullptr, "invariant"); + assert(methods != nullptr, "invariant"); // Set up Method*::intrinsic_id as soon as we know the names of methods. // (We used to do this lazily, but now we query it in Rewriter, @@ -5256,7 +5256,7 @@ static void check_methods_for_intrinsics(const InstanceKlass* ik, InstanceKlass* ClassFileParser::create_instance_klass(bool changed_by_loadhook, const ClassInstanceInfo& cl_inst_info, TRAPS) { - if (_klass != NULL) { + if (_klass != nullptr) { return _klass; } @@ -5278,21 +5278,21 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loadhook, const ClassInstanceInfo& cl_inst_info, TRAPS) { - assert(ik != NULL, "invariant"); + assert(ik != nullptr, "invariant"); // Set name and CLD before adding to CLD ik->set_class_loader_data(_loader_data); ik->set_name(_class_name); // Add all classes to our internal class loader list here, - // including classes in the bootstrap (NULL) class loader. + // including classes in the bootstrap (null) class loader. const bool publicize = !is_internal(); _loader_data->add_class(ik, publicize); set_klass_to_deallocate(ik); - assert(_field_info != NULL, "invariant"); + assert(_field_info != nullptr, "invariant"); assert(ik->static_field_size() == _field_info->_static_field_size, "sanity"); assert(ik->nonstatic_oop_map_count() == _field_info->oop_map_blocks->_nonstatic_oop_map_count, "sanity"); @@ -5306,7 +5306,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, // Not yet: supers are done below to support the new subtype-checking fields ik->set_nonstatic_field_size(_field_info->_nonstatic_field_size); ik->set_has_nonstatic_fields(_field_info->_has_nonstatic_fields); - assert(_fac != NULL, "invariant"); + assert(_fac != nullptr, "invariant"); ik->set_static_oop_field_count(_fac->count[STATIC_OOP]); // this transfers ownership of a lot of arrays from @@ -5314,19 +5314,19 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, apply_parsed_class_metadata(ik, _java_fields_count); // can only set dynamic nest-host after static nest information is set - if (cl_inst_info.dynamic_nest_host() != NULL) { + if (cl_inst_info.dynamic_nest_host() != nullptr) { ik->set_nest_host(cl_inst_info.dynamic_nest_host()); } // note that is not safe to use the fields in the parser from this point on - assert(NULL == _cp, "invariant"); - assert(NULL == _fields, "invariant"); - assert(NULL == _methods, "invariant"); - assert(NULL == _inner_classes, "invariant"); - assert(NULL == _nest_members, "invariant"); - assert(NULL == _combined_annotations, "invariant"); - assert(NULL == _record_components, "invariant"); - assert(NULL == _permitted_subclasses, "invariant"); + assert(nullptr == _cp, "invariant"); + assert(nullptr == _fields, "invariant"); + assert(nullptr == _methods, "invariant"); + assert(nullptr == _inner_classes, "invariant"); + assert(nullptr == _nest_members, "invariant"); + assert(nullptr == _combined_annotations, "invariant"); + assert(nullptr == _record_components, "invariant"); + assert(nullptr == _permitted_subclasses, "invariant"); if (_has_localvariable_table) { ik->set_has_localvariable_table(true); @@ -5370,10 +5370,10 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, oop cl = ik->class_loader(); Handle clh = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(cl)); ClassLoaderData* cld = ClassLoaderData::class_loader_data_or_null(clh()); - ik->set_package(cld, NULL, CHECK); + ik->set_package(cld, nullptr, CHECK); const Array* const methods = ik->methods(); - assert(methods != NULL, "invariant"); + assert(methods != nullptr, "invariant"); const int methods_len = methods->length(); check_methods_for_intrinsics(ik, methods); @@ -5388,7 +5388,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, // Miranda methods if ((_num_miranda_methods > 0) || // if this class introduced new miranda methods or - (_super_klass != NULL && _super_klass->has_miranda_methods()) + (_super_klass != nullptr && _super_klass->has_miranda_methods()) // super class exists and this class inherited miranda methods ) { ik->set_has_miranda_methods(); // then set a flag @@ -5398,8 +5398,8 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, ik->initialize_supers(const_cast(_super_klass), _transitive_interfaces, CHECK); ik->set_transitive_interfaces(_transitive_interfaces); ik->set_local_interfaces(_local_interfaces); - _transitive_interfaces = NULL; - _local_interfaces = NULL; + _transitive_interfaces = nullptr; + _local_interfaces = nullptr; // Initialize itable offset tables klassItable::setup_itable_offset_table(ik); @@ -5412,7 +5412,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, } if (_has_contended_fields || _parsed_annotations->is_contended() || - ( _super_klass != NULL && _super_klass->has_contended_annotations())) { + ( _super_klass != nullptr && _super_klass->has_contended_annotations())) { ik->set_has_contended_annotations(true); } @@ -5435,7 +5435,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, // Obtain this_klass' module entry ModuleEntry* module_entry = ik->module(); - assert(module_entry != NULL, "module_entry should always be set"); + assert(module_entry != nullptr, "module_entry should always be set"); // Obtain java.lang.Module Handle module_handle(THREAD, module_entry->module()); @@ -5449,7 +5449,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, cl_inst_info.class_data(), CHECK); - assert(_all_mirandas != NULL, "invariant"); + assert(_all_mirandas != nullptr, "invariant"); // Generate any default methods - default methods are public interface methods // that have a default implementation. This is new with Java 8. @@ -5485,14 +5485,14 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, ResourceMark rm; // print out the superclass. const char * from = ik->external_name(); - if (ik->java_super() != NULL) { + if (ik->java_super() != nullptr) { log_debug(class, resolve)("%s %s (super)", from, ik->java_super()->external_name()); } // print out each of the interface classes referred to by this class. const Array* const local_interfaces = ik->local_interfaces(); - if (local_interfaces != NULL) { + if (local_interfaces != nullptr) { const int length = local_interfaces->length(); for (int i = 0; i < length; i++) { const InstanceKlass* const k = local_interfaces->at(i); @@ -5508,7 +5508,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, // If we reach here, all is well. // Now remove the InstanceKlass* from the _klass_to_deallocate field // in order for it to not be destroyed in the ClassFileParser destructor. - set_klass_to_deallocate(NULL); + set_klass_to_deallocate(nullptr); // it's official set_klass(ik); @@ -5545,34 +5545,34 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, Publicity pub_level, TRAPS) : _stream(stream), - _class_name(NULL), + _class_name(nullptr), _loader_data(loader_data), _is_hidden(cl_info->is_hidden()), _can_access_vm_annotations(cl_info->can_access_vm_annotations()), _orig_cp_size(0), _super_klass(), - _cp(NULL), - _fields(NULL), - _methods(NULL), - _inner_classes(NULL), - _nest_members(NULL), + _cp(nullptr), + _fields(nullptr), + _methods(nullptr), + _inner_classes(nullptr), + _nest_members(nullptr), _nest_host(0), - _permitted_subclasses(NULL), - _record_components(NULL), - _local_interfaces(NULL), - _transitive_interfaces(NULL), - _combined_annotations(NULL), - _class_annotations(NULL), - _class_type_annotations(NULL), - _fields_annotations(NULL), - _fields_type_annotations(NULL), - _klass(NULL), - _klass_to_deallocate(NULL), - _parsed_annotations(NULL), - _fac(NULL), - _field_info(NULL), - _method_ordering(NULL), - _all_mirandas(NULL), + _permitted_subclasses(nullptr), + _record_components(nullptr), + _local_interfaces(nullptr), + _transitive_interfaces(nullptr), + _combined_annotations(nullptr), + _class_annotations(nullptr), + _class_type_annotations(nullptr), + _fields_annotations(nullptr), + _fields_type_annotations(nullptr), + _klass(nullptr), + _klass_to_deallocate(nullptr), + _parsed_annotations(nullptr), + _fac(nullptr), + _field_info(nullptr), + _method_ordering(nullptr), + _all_mirandas(nullptr), _vtable_size(0), _itable_size(0), _num_miranda_methods(0), @@ -5582,7 +5582,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, _bad_constant_seen(0), _synthetic_flag(false), _sde_length(false), - _sde_buffer(NULL), + _sde_buffer(nullptr), _sourcefile_index(0), _generic_signature_index(0), _major_version(0), @@ -5603,14 +5603,14 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, _has_vanilla_constructor(false), _max_bootstrap_specifier_index(-1) { - _class_name = name != NULL ? name : vmSymbols::unknown_class_name(); + _class_name = name != nullptr ? name : vmSymbols::unknown_class_name(); _class_name->increment_refcount(); - assert(_loader_data != NULL, "invariant"); - assert(stream != NULL, "invariant"); - assert(_stream != NULL, "invariant"); + assert(_loader_data != nullptr, "invariant"); + assert(stream != nullptr, "invariant"); + assert(_stream != nullptr, "invariant"); assert(_stream->buffer() == _stream->current(), "invariant"); - assert(_class_name != NULL, "invariant"); + assert(_class_name != nullptr, "invariant"); assert(0 == _access_flags.as_int(), "invariant"); // Figure out whether we can skip format checking (matching classic VM behavior) @@ -5641,48 +5641,48 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, void ClassFileParser::clear_class_metadata() { // metadata created before the instance klass is created. Must be // deallocated if classfile parsing returns an error. - _cp = NULL; - _fields = NULL; - _methods = NULL; - _inner_classes = NULL; - _nest_members = NULL; - _permitted_subclasses = NULL; - _combined_annotations = NULL; - _class_annotations = _class_type_annotations = NULL; - _fields_annotations = _fields_type_annotations = NULL; - _record_components = NULL; + _cp = nullptr; + _fields = nullptr; + _methods = nullptr; + _inner_classes = nullptr; + _nest_members = nullptr; + _permitted_subclasses = nullptr; + _combined_annotations = nullptr; + _class_annotations = _class_type_annotations = nullptr; + _fields_annotations = _fields_type_annotations = nullptr; + _record_components = nullptr; } // Destructor to clean up ClassFileParser::~ClassFileParser() { _class_name->decrement_refcount(); - if (_cp != NULL) { + if (_cp != nullptr) { MetadataFactory::free_metadata(_loader_data, _cp); } - if (_fields != NULL) { + if (_fields != nullptr) { MetadataFactory::free_array(_loader_data, _fields); } - if (_methods != NULL) { + if (_methods != nullptr) { // Free methods InstanceKlass::deallocate_methods(_loader_data, _methods); } // beware of the Universe::empty_blah_array!! - if (_inner_classes != NULL && _inner_classes != Universe::the_empty_short_array()) { + if (_inner_classes != nullptr && _inner_classes != Universe::the_empty_short_array()) { MetadataFactory::free_array(_loader_data, _inner_classes); } - if (_nest_members != NULL && _nest_members != Universe::the_empty_short_array()) { + if (_nest_members != nullptr && _nest_members != Universe::the_empty_short_array()) { MetadataFactory::free_array(_loader_data, _nest_members); } - if (_record_components != NULL) { + if (_record_components != nullptr) { InstanceKlass::deallocate_record_components(_loader_data, _record_components); } - if (_permitted_subclasses != NULL && _permitted_subclasses != Universe::the_empty_short_array()) { + if (_permitted_subclasses != nullptr && _permitted_subclasses != Universe::the_empty_short_array()) { MetadataFactory::free_array(_loader_data, _permitted_subclasses); } @@ -5690,19 +5690,19 @@ ClassFileParser::~ClassFileParser() { InstanceKlass::deallocate_interfaces(_loader_data, _super_klass, _local_interfaces, _transitive_interfaces); - if (_combined_annotations != NULL) { + if (_combined_annotations != nullptr) { // After all annotations arrays have been created, they are installed into the // Annotations object that will be assigned to the InstanceKlass being created. // Deallocate the Annotations object and the installed annotations arrays. _combined_annotations->deallocate_contents(_loader_data); - // If the _combined_annotations pointer is non-NULL, + // If the _combined_annotations pointer is non-null, // then the other annotations fields should have been cleared. - assert(_class_annotations == NULL, "Should have been cleared"); - assert(_class_type_annotations == NULL, "Should have been cleared"); - assert(_fields_annotations == NULL, "Should have been cleared"); - assert(_fields_type_annotations == NULL, "Should have been cleared"); + assert(_class_annotations == nullptr, "Should have been cleared"); + assert(_class_type_annotations == nullptr, "Should have been cleared"); + assert(_fields_annotations == nullptr, "Should have been cleared"); + assert(_fields_type_annotations == nullptr, "Should have been cleared"); } else { // If the annotations arrays were not installed into the Annotations object, // then they have to be deallocated explicitly. @@ -5713,13 +5713,13 @@ ClassFileParser::~ClassFileParser() { } clear_class_metadata(); - _transitive_interfaces = NULL; - _local_interfaces = NULL; + _transitive_interfaces = nullptr; + _local_interfaces = nullptr; // deallocate the klass if already created. Don't directly deallocate, but add // to the deallocate list so that the klass is removed from the CLD::_klasses list // at a safepoint. - if (_klass_to_deallocate != NULL) { + if (_klass_to_deallocate != nullptr) { _loader_data->add_to_deallocate_list(_klass_to_deallocate); } } @@ -5727,8 +5727,8 @@ ClassFileParser::~ClassFileParser() { void ClassFileParser::parse_stream(const ClassFileStream* const stream, TRAPS) { - assert(stream != NULL, "invariant"); - assert(_class_name != NULL, "invariant"); + assert(stream != nullptr, "invariant"); + assert(_class_name != nullptr, "invariant"); // BEGIN STREAM PARSING stream->guarantee_more(8, CHECK); // magic, major, minor @@ -5805,7 +5805,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, _this_class_index, CHECK); Symbol* const class_name_in_cp = cp->klass_name_at(_this_class_index); - assert(class_name_in_cp != NULL, "class_name can't be null"); + assert(class_name_in_cp != nullptr, "class_name can't be null"); // Don't need to check whether this class name is legal or not. // It has been checked when constant pool is parsed. @@ -5826,7 +5826,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, // Update the _class_name as needed depending on whether this is a named, un-named, or hidden class. if (_is_hidden) { - assert(_class_name != NULL, "Unexpected null _class_name"); + assert(_class_name != nullptr, "Unexpected null _class_name"); #ifdef ASSERT if (_need_verify) { verify_legal_class_name(_class_name, CHECK); @@ -5864,7 +5864,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, ResourceMark rm(THREAD); LogStream ls(lt); ls.print("%s", _class_name->as_klass_external_name()); - if (stream->source() != NULL) { + if (stream->source() != nullptr) { ls.print(" source: %s", stream->source()); } ls.cr(); @@ -5886,7 +5886,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, &_has_nonstatic_concrete_methods, CHECK); - assert(_local_interfaces != NULL, "invariant"); + assert(_local_interfaces != nullptr, "invariant"); // Fields (offsets are filled in later) _fac = new FieldAllocationCount(); @@ -5898,7 +5898,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, &_java_fields_count, CHECK); - assert(_fields != NULL, "invariant"); + assert(_fields != nullptr, "invariant"); // Methods parse_methods(stream, @@ -5908,7 +5908,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, &_declares_nonstatic_concrete_methods, CHECK); - assert(_methods != NULL, "invariant"); + assert(_methods != nullptr, "invariant"); if (_declares_nonstatic_concrete_methods) { _has_nonstatic_concrete_methods = true; @@ -5918,7 +5918,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, _parsed_annotations = new ClassAnnotationCollector(); parse_classfile_attributes(stream, cp, _parsed_annotations, CHECK); - assert(_inner_classes != NULL, "invariant"); + assert(_inner_classes != nullptr, "invariant"); // Finalize the Annotations metadata object, // now that all annotation arrays have been created. @@ -5958,7 +5958,7 @@ void ClassFileParser::mangle_hidden_class_name(InstanceKlass* const ik) { update_class_name(SymbolTable::new_symbol(new_name)); // Add a Utf8 entry containing the hidden name. - assert(_class_name != NULL, "Unexpected null _class_name"); + assert(_class_name != nullptr, "Unexpected null _class_name"); int hidden_index = _orig_cp_size; // this is an extra slot we added _cp->symbol_at_put(hidden_index, _class_name); @@ -5975,10 +5975,10 @@ void ClassFileParser::mangle_hidden_class_name(InstanceKlass* const ik) { void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const stream, ConstantPool* cp, TRAPS) { - assert(stream != NULL, "invariant"); + assert(stream != nullptr, "invariant"); assert(stream->at_eos(), "invariant"); - assert(cp != NULL, "invariant"); - assert(_loader_data != NULL, "invariant"); + assert(cp != nullptr, "invariant"); + assert(_loader_data != nullptr, "invariant"); if (_class_name == vmSymbols::java_lang_Object()) { check_property(_local_interfaces == Universe::the_empty_instance_klass_array(), @@ -5986,7 +5986,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st CHECK); } // We check super class after class file is parsed and format is checked - if (_super_class_index > 0 && NULL == _super_klass) { + if (_super_class_index > 0 && nullptr == _super_klass) { Symbol* const super_class_name = cp->klass_name_at(_super_class_index); if (_access_flags.is_interface()) { // Before attempting to resolve the superclass, check for class format @@ -6009,7 +6009,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st } } - if (_super_klass != NULL) { + if (_super_klass != nullptr) { if (_super_klass->has_nonstatic_concrete_methods()) { _has_nonstatic_concrete_methods = true; } @@ -6027,7 +6027,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st _loader_data, CHECK); - assert(_transitive_interfaces != NULL, "invariant"); + assert(_transitive_interfaces != nullptr, "invariant"); // sort methods _method_ordering = sort_methods(_methods); @@ -6050,8 +6050,8 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st _itable_size = _access_flags.is_interface() ? 0 : klassItable::compute_itable_size(_transitive_interfaces); - assert(_fac != NULL, "invariant"); - assert(_parsed_annotations != NULL, "invariant"); + assert(_fac != nullptr, "invariant"); + assert(_parsed_annotations != nullptr, "invariant"); _field_info = new FieldLayoutInfo(); FieldLayoutBuilder lb(class_name(), super_klass(), _cp, _fields, @@ -6062,8 +6062,8 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st void ClassFileParser::set_klass(InstanceKlass* klass) { #ifdef ASSERT - if (klass != NULL) { - assert(NULL == _klass, "leaking?"); + if (klass != nullptr) { + assert(nullptr == _klass, "leaking?"); } #endif @@ -6073,8 +6073,8 @@ void ClassFileParser::set_klass(InstanceKlass* klass) { void ClassFileParser::set_klass_to_deallocate(InstanceKlass* klass) { #ifdef ASSERT - if (klass != NULL) { - assert(NULL == _klass_to_deallocate, "leaking?"); + if (klass != nullptr) { + assert(nullptr == _klass_to_deallocate, "leaking?"); } #endif @@ -6084,13 +6084,13 @@ void ClassFileParser::set_klass_to_deallocate(InstanceKlass* klass) { // Caller responsible for ResourceMark // clone stream with rewound position const ClassFileStream* ClassFileParser::clone_stream() const { - assert(_stream != NULL, "invariant"); + assert(_stream != nullptr, "invariant"); return _stream->clone(); } ReferenceType ClassFileParser::super_reference_type() const { - return _super_klass == NULL ? REF_NONE : _super_klass->reference_type(); + return _super_klass == nullptr ? REF_NONE : _super_klass->reference_type(); } bool ClassFileParser::is_instance_ref_klass() const { @@ -6103,7 +6103,7 @@ bool ClassFileParser::is_instance_ref_klass() const { } bool ClassFileParser::is_java_lang_ref_Reference_subclass() const { - if (_super_klass == NULL) { + if (_super_klass == nullptr) { return false; } @@ -6122,10 +6122,10 @@ bool ClassFileParser::is_java_lang_ref_Reference_subclass() const { // return true if class_name contains no '.' (internal format is '/') bool ClassFileParser::is_internal_format(Symbol* class_name) { - if (class_name != NULL) { + if (class_name != nullptr) { ResourceMark rm; char* name = class_name->as_C_string(); - return strchr(name, JVM_SIGNATURE_DOT) == NULL; + return strchr(name, JVM_SIGNATURE_DOT) == nullptr; } else { return true; } diff --git a/src/hotspot/share/classfile/classFileParser.hpp b/src/hotspot/share/classfile/classFileParser.hpp index d8bb95b8a7a..9c9a388f3e8 100644 --- a/src/hotspot/share/classfile/classFileParser.hpp +++ b/src/hotspot/share/classfile/classFileParser.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -118,7 +118,7 @@ class ClassFileParser { // Metadata created before the instance klass is created. Must be deallocated // if not transferred to the InstanceKlass upon successful class loading - // in which case these pointers have been set to NULL. + // in which case these pointers have been set to null. const InstanceKlass* _super_klass; ConstantPool* _cp; Array* _fields; diff --git a/src/hotspot/share/classfile/classFileStream.cpp b/src/hotspot/share/classfile/classFileStream.cpp index b65b827c583..ed530353216 100644 --- a/src/hotspot/share/classfile/classFileStream.cpp +++ b/src/hotspot/share/classfile/classFileStream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -45,7 +45,7 @@ ClassFileStream::ClassFileStream(const u1* buffer, _source(source), _need_verify(verify_stream), _from_boot_loader_modules_image(from_boot_loader_modules_image) { - assert(buffer != NULL, "caller should throw NPE"); + assert(buffer != nullptr, "caller should throw NPE"); } const u1* ClassFileStream::clone_buffer() const { @@ -56,8 +56,8 @@ const u1* ClassFileStream::clone_buffer() const { const char* const ClassFileStream::clone_source() const { const char* const src = source(); - char* source_copy = NULL; - if (src != NULL) { + char* source_copy = nullptr; + if (src != nullptr) { size_t source_len = strlen(src); source_copy = NEW_RESOURCE_ARRAY(char, source_len + 1); strncpy(source_copy, src, source_len + 1); diff --git a/src/hotspot/share/classfile/classLoadInfo.hpp b/src/hotspot/share/classfile/classLoadInfo.hpp index f68196e8384..b1257dc9987 100644 --- a/src/hotspot/share/classfile/classLoadInfo.hpp +++ b/src/hotspot/share/classfile/classLoadInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, 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 @@ -38,7 +38,7 @@ class ClassInstanceInfo : public StackObj { public: ClassInstanceInfo() { - _dynamic_nest_host = NULL; + _dynamic_nest_host = nullptr; _class_data = Handle(); } ClassInstanceInfo(InstanceKlass* dynamic_nest_host, Handle class_data) { @@ -62,7 +62,7 @@ class ClassLoadInfo : public StackObj { public: ClassLoadInfo(Handle protection_domain) { _protection_domain = protection_domain; - _class_hidden_info._dynamic_nest_host = NULL; + _class_hidden_info._dynamic_nest_host = nullptr; _class_hidden_info._class_data = Handle(); _is_hidden = false; _is_strong_hidden = false; diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 534412cb0f7..e094ad32fb9 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -82,7 +82,7 @@ typedef int (*canonicalize_fn_t)(const char *orig, char *out, int len); -static canonicalize_fn_t CanonicalizeEntry = NULL; +static canonicalize_fn_t CanonicalizeEntry = nullptr; // Entry points in zip.dll for loading zip/jar file entries @@ -92,60 +92,60 @@ typedef jzentry* (*FindEntry_t)(jzfile *zip, const char *name, jint *sizeP, jint typedef jboolean (*ReadEntry_t)(jzfile *zip, jzentry *entry, unsigned char *buf, char *namebuf); typedef jint (*Crc32_t)(jint crc, const jbyte *buf, jint len); -static ZipOpen_t ZipOpen = NULL; -static ZipClose_t ZipClose = NULL; -static FindEntry_t FindEntry = NULL; -static ReadEntry_t ReadEntry = NULL; -static Crc32_t Crc32 = NULL; +static ZipOpen_t ZipOpen = nullptr; +static ZipClose_t ZipClose = nullptr; +static FindEntry_t FindEntry = nullptr; +static ReadEntry_t ReadEntry = nullptr; +static Crc32_t Crc32 = nullptr; int ClassLoader::_libzip_loaded = 0; -void* ClassLoader::_zip_handle = NULL; +void* ClassLoader::_zip_handle = nullptr; // Entry points for jimage.dll for loading jimage file entries -static JImageOpen_t JImageOpen = NULL; -static JImageClose_t JImageClose = NULL; -static JImageFindResource_t JImageFindResource = NULL; -static JImageGetResource_t JImageGetResource = NULL; +static JImageOpen_t JImageOpen = nullptr; +static JImageClose_t JImageClose = nullptr; +static JImageFindResource_t JImageFindResource = nullptr; +static JImageGetResource_t JImageGetResource = nullptr; // JimageFile pointer, or null if exploded JDK build. -static JImageFile* JImage_file = NULL; +static JImageFile* JImage_file = nullptr; // Globals -PerfCounter* ClassLoader::_perf_accumulated_time = NULL; -PerfCounter* ClassLoader::_perf_classes_inited = NULL; -PerfCounter* ClassLoader::_perf_class_init_time = NULL; -PerfCounter* ClassLoader::_perf_class_init_selftime = NULL; -PerfCounter* ClassLoader::_perf_classes_verified = NULL; -PerfCounter* ClassLoader::_perf_class_verify_time = NULL; -PerfCounter* ClassLoader::_perf_class_verify_selftime = NULL; -PerfCounter* ClassLoader::_perf_classes_linked = NULL; -PerfCounter* ClassLoader::_perf_class_link_time = NULL; -PerfCounter* ClassLoader::_perf_class_link_selftime = NULL; -PerfCounter* ClassLoader::_perf_sys_class_lookup_time = NULL; -PerfCounter* ClassLoader::_perf_shared_classload_time = NULL; -PerfCounter* ClassLoader::_perf_sys_classload_time = NULL; -PerfCounter* ClassLoader::_perf_app_classload_time = NULL; -PerfCounter* ClassLoader::_perf_app_classload_selftime = NULL; -PerfCounter* ClassLoader::_perf_app_classload_count = NULL; -PerfCounter* ClassLoader::_perf_define_appclasses = NULL; -PerfCounter* ClassLoader::_perf_define_appclass_time = NULL; -PerfCounter* ClassLoader::_perf_define_appclass_selftime = NULL; -PerfCounter* ClassLoader::_perf_app_classfile_bytes_read = NULL; -PerfCounter* ClassLoader::_perf_sys_classfile_bytes_read = NULL; -PerfCounter* ClassLoader::_unsafe_defineClassCallCounter = NULL; +PerfCounter* ClassLoader::_perf_accumulated_time = nullptr; +PerfCounter* ClassLoader::_perf_classes_inited = nullptr; +PerfCounter* ClassLoader::_perf_class_init_time = nullptr; +PerfCounter* ClassLoader::_perf_class_init_selftime = nullptr; +PerfCounter* ClassLoader::_perf_classes_verified = nullptr; +PerfCounter* ClassLoader::_perf_class_verify_time = nullptr; +PerfCounter* ClassLoader::_perf_class_verify_selftime = nullptr; +PerfCounter* ClassLoader::_perf_classes_linked = nullptr; +PerfCounter* ClassLoader::_perf_class_link_time = nullptr; +PerfCounter* ClassLoader::_perf_class_link_selftime = nullptr; +PerfCounter* ClassLoader::_perf_sys_class_lookup_time = nullptr; +PerfCounter* ClassLoader::_perf_shared_classload_time = nullptr; +PerfCounter* ClassLoader::_perf_sys_classload_time = nullptr; +PerfCounter* ClassLoader::_perf_app_classload_time = nullptr; +PerfCounter* ClassLoader::_perf_app_classload_selftime = nullptr; +PerfCounter* ClassLoader::_perf_app_classload_count = nullptr; +PerfCounter* ClassLoader::_perf_define_appclasses = nullptr; +PerfCounter* ClassLoader::_perf_define_appclass_time = nullptr; +PerfCounter* ClassLoader::_perf_define_appclass_selftime = nullptr; +PerfCounter* ClassLoader::_perf_app_classfile_bytes_read = nullptr; +PerfCounter* ClassLoader::_perf_sys_classfile_bytes_read = nullptr; +PerfCounter* ClassLoader::_unsafe_defineClassCallCounter = nullptr; -GrowableArray* ClassLoader::_patch_mod_entries = NULL; -GrowableArray* ClassLoader::_exploded_entries = NULL; -ClassPathEntry* ClassLoader::_jrt_entry = NULL; +GrowableArray* ClassLoader::_patch_mod_entries = nullptr; +GrowableArray* ClassLoader::_exploded_entries = nullptr; +ClassPathEntry* ClassLoader::_jrt_entry = nullptr; -ClassPathEntry* volatile ClassLoader::_first_append_entry_list = NULL; -ClassPathEntry* volatile ClassLoader::_last_append_entry = NULL; +ClassPathEntry* volatile ClassLoader::_first_append_entry_list = nullptr; +ClassPathEntry* volatile ClassLoader::_last_append_entry = nullptr; #if INCLUDE_CDS -ClassPathEntry* ClassLoader::_app_classpath_entries = NULL; -ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL; -ClassPathEntry* ClassLoader::_module_path_entries = NULL; -ClassPathEntry* ClassLoader::_last_module_path_entry = NULL; +ClassPathEntry* ClassLoader::_app_classpath_entries = nullptr; +ClassPathEntry* ClassLoader::_last_app_classpath_entry = nullptr; +ClassPathEntry* ClassLoader::_module_path_entries = nullptr; +ClassPathEntry* ClassLoader::_last_module_path_entry = nullptr; #endif // helper routines @@ -178,19 +178,19 @@ bool ClassLoader::string_ends_with(const char* str, const char* str_to_find) { // Used to obtain the package name from a fully qualified class name. Symbol* ClassLoader::package_from_class_name(const Symbol* name, bool* bad_class_name) { - if (name == NULL) { - if (bad_class_name != NULL) { + if (name == nullptr) { + if (bad_class_name != nullptr) { *bad_class_name = true; } - return NULL; + return nullptr; } int utf_len = name->utf8_length(); const jbyte* base = (const jbyte*)name->base(); const jbyte* start = base; const jbyte* end = UTF8::strrchr(start, utf_len, JVM_SIGNATURE_SLASH); - if (end == NULL) { - return NULL; + if (end == nullptr) { + return nullptr; } // Skip over '['s if (*start == JVM_SIGNATURE_ARRAY) { @@ -203,20 +203,20 @@ Symbol* ClassLoader::package_from_class_name(const Symbol* name, bool* bad_class // could not be obtained due to an error condition. // In this situation, is_same_class_package returns false. if (*start == JVM_SIGNATURE_CLASS) { - if (bad_class_name != NULL) { + if (bad_class_name != nullptr) { *bad_class_name = true; } - return NULL; + return nullptr; } } // A class name could have just the slash character in the name, // in which case start > end if (start >= end) { // No package name - if (bad_class_name != NULL) { + if (bad_class_name != nullptr) { *bad_class_name = true; } - return NULL; + return nullptr; } return SymbolTable::new_symbol(name, start - base, end - base); } @@ -224,8 +224,8 @@ Symbol* ClassLoader::package_from_class_name(const Symbol* name, bool* bad_class // Given a fully qualified package name, find its defining package in the class loader's // package entry table. PackageEntry* ClassLoader::get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data) { - if (pkg_name == NULL) { - return NULL; + if (pkg_name == nullptr) { + return nullptr; } PackageEntryTable* pkgEntryTable = loader_data->packages(); return pkgEntryTable->lookup_only(pkg_name); @@ -243,7 +243,7 @@ ClassPathDirEntry::~ClassPathDirEntry() { ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char* name) { // construct full path name - assert((_dir != NULL) && (name != NULL), "sanity"); + assert((_dir != nullptr) && (name != nullptr), "sanity"); size_t path_len = strlen(_dir) + strlen(name) + strlen(os::file_separator()) + 1; char* path = NEW_RESOURCE_ARRAY_IN_THREAD(current, char, path_len); int len = jio_snprintf(path, path_len, "%s%s%s", _dir, os::file_separator(), name); @@ -278,7 +278,7 @@ ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char* } } FREE_RESOURCE_ARRAY_IN_THREAD(current, char, path, path_len); - return NULL; + return nullptr; } ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name, @@ -299,7 +299,7 @@ u1* ClassPathZipEntry::open_entry(JavaThread* current, const char* name, jint* f // check whether zip archive contains name jint name_len; jzentry* entry = (*FindEntry)(_zip, name, filesize, &name_len); - if (entry == NULL) return NULL; + if (entry == nullptr) return nullptr; u1* buffer; char name_buf[128]; char* filename; @@ -313,12 +313,12 @@ u1* ClassPathZipEntry::open_entry(JavaThread* current, const char* name, jint* f size_t size = (uint32_t)(*filesize); if (nul_terminate) { if (sizeof(size) == sizeof(uint32_t) && size == UINT_MAX) { - return NULL; // 32-bit integer overflow will occur. + return nullptr; // 32-bit integer overflow will occur. } size++; } buffer = NEW_RESOURCE_ARRAY(u1, size); - if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL; + if (!(*ReadEntry)(_zip, entry, buffer, filename)) return nullptr; // return result if (nul_terminate) { @@ -330,8 +330,8 @@ u1* ClassPathZipEntry::open_entry(JavaThread* current, const char* name, jint* f ClassFileStream* ClassPathZipEntry::open_stream(JavaThread* current, const char* name) { jint filesize; u1* buffer = open_entry(current, name, &filesize, false); - if (buffer == NULL) { - return NULL; + if (buffer == nullptr) { + return nullptr; } if (UsePerfData) { ClassLoader::perf_sys_classfile_bytes_read()->inc(filesize); @@ -343,7 +343,7 @@ ClassFileStream* ClassPathZipEntry::open_stream(JavaThread* current, const char* ClassFileStream::verify); } -DEBUG_ONLY(ClassPathImageEntry* ClassPathImageEntry::_singleton = NULL;) +DEBUG_ONLY(ClassPathImageEntry* ClassPathImageEntry::_singleton = nullptr;) JImageFile* ClassPathImageEntry::jimage() const { return JImage_file; @@ -351,23 +351,23 @@ JImageFile* ClassPathImageEntry::jimage() const { JImageFile* ClassPathImageEntry::jimage_non_null() const { assert(ClassLoader::has_jrt_entry(), "must be"); - assert(jimage() != NULL, "should have been opened by ClassLoader::lookup_vm_options " + assert(jimage() != nullptr, "should have been opened by ClassLoader::lookup_vm_options " "and remained throughout normal JVM lifetime"); return jimage(); } void ClassPathImageEntry::close_jimage() { - if (jimage() != NULL) { + if (jimage() != nullptr) { (*JImageClose)(jimage()); - JImage_file = NULL; + JImage_file = nullptr; } } ClassPathImageEntry::ClassPathImageEntry(JImageFile* jimage, const char* name) : ClassPathEntry() { - guarantee(jimage != NULL, "jimage file is null"); - guarantee(name != NULL, "jimage file name is null"); - assert(_singleton == NULL, "VM supports only one jimage"); + guarantee(jimage != nullptr, "jimage file is null"); + guarantee(name != nullptr, "jimage file name is null"); + assert(_singleton == nullptr, "VM supports only one jimage"); DEBUG_ONLY(_singleton = this); size_t len = strlen(name) + 1; _name = copy_path(name); @@ -392,19 +392,19 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(JavaThread* current TempNewSymbol class_name = SymbolTable::new_symbol(name); TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name); - if (pkg_name != NULL) { + if (pkg_name != nullptr) { if (!Universe::is_module_initialized()) { location = (*JImageFindResource)(jimage_non_null(), JAVA_BASE_NAME, get_jimage_version_string(), name, &size); } else { PackageEntry* package_entry = ClassLoader::get_package_entry(pkg_name, loader_data); - if (package_entry != NULL) { + if (package_entry != nullptr) { ResourceMark rm(current); // Get the module name ModuleEntry* module = package_entry->module(); - assert(module != NULL, "Boot classLoader package missing module"); + assert(module != nullptr, "Boot classLoader package missing module"); assert(module->is_named(), "Boot classLoader package is in unnamed module"); const char* module_name = module->name()->as_C_string(); - if (module_name != NULL) { + if (module_name != nullptr) { location = (*JImageFindResource)(jimage_non_null(), module_name, get_jimage_version_string(), name, &size); } } @@ -426,7 +426,7 @@ ClassFileStream* ClassPathImageEntry::open_stream_for_loader(JavaThread* current true); // from_boot_loader_modules_image } - return NULL; + return nullptr; } JImageLocationRef ClassLoader::jimage_find_resource(JImageFile* jf, @@ -452,14 +452,14 @@ void ClassLoader::exit_with_path_failure(const char* error, const char* message) ModuleClassPathList::ModuleClassPathList(Symbol* module_name) { _module_name = module_name; - _module_first_entry = NULL; - _module_last_entry = NULL; + _module_first_entry = nullptr; + _module_last_entry = nullptr; } ModuleClassPathList::~ModuleClassPathList() { // Clean out each ClassPathEntry on list ClassPathEntry* e = _module_first_entry; - while (e != NULL) { + while (e != nullptr) { ClassPathEntry* next_entry = e->next(); delete e; e = next_entry; @@ -467,8 +467,8 @@ ModuleClassPathList::~ModuleClassPathList() { } void ModuleClassPathList::add_to_list(ClassPathEntry* new_entry) { - if (new_entry != NULL) { - if (_module_last_entry == NULL) { + if (new_entry != nullptr) { + if (_module_last_entry == nullptr) { _module_first_entry = _module_last_entry = new_entry; } else { _module_last_entry->set_next(new_entry); @@ -502,7 +502,7 @@ void ClassLoader::trace_class_path(const char* msg, const char* name) { void ClassLoader::setup_bootstrap_search_path(JavaThread* current) { const char* bootcp = Arguments::get_boot_class_path(); - assert(bootcp != NULL, "Boot class path must not be NULL"); + assert(bootcp != nullptr, "Boot class path must not be nullptr"); if (PrintSharedArchiveAndExit) { // Don't print bootcp - this is the bootcp of this current VM process, not necessarily // the same as the boot classpath of the shared archive. @@ -527,12 +527,12 @@ void ClassLoader::setup_app_search_path(JavaThread* current, const char *class_p void ClassLoader::add_to_module_path_entries(const char* path, ClassPathEntry* entry) { - assert(entry != NULL, "ClassPathEntry should not be NULL"); + assert(entry != nullptr, "ClassPathEntry should not be nullptr"); Arguments::assert_is_dumping_archive(); // The entry does not exist, add to the list - if (_module_path_entries == NULL) { - assert(_last_module_path_entry == NULL, "Sanity"); + if (_module_path_entries == nullptr) { + assert(_last_module_path_entry == nullptr, "Sanity"); _module_path_entries = _last_module_path_entry = entry; } else { _last_module_path_entry->set_next(entry); @@ -550,10 +550,10 @@ void ClassLoader::setup_module_search_path(JavaThread* current, const char* path vm_exit_during_initialization(); } // File or directory found - ClassPathEntry* new_entry = NULL; + ClassPathEntry* new_entry = nullptr; new_entry = create_class_path_entry(current, path, &st, false /*is_boot_append */, false /* from_class_path_attr */); - if (new_entry != NULL) { + if (new_entry != nullptr) { add_to_module_path_entries(path, new_entry); } } @@ -580,7 +580,7 @@ void ClassLoader::setup_patch_mod_entries() { for (int i = 0; i < num_of_entries; i++) { const char* module_name = (patch_mod_args->at(i))->module_name(); Symbol* const module_sym = SymbolTable::new_symbol(module_name); - assert(module_sym != NULL, "Failed to obtain Symbol for module name"); + assert(module_sym != nullptr, "Failed to obtain Symbol for module name"); ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); char* class_path = (patch_mod_args->at(i))->path_string(); @@ -594,7 +594,7 @@ void ClassLoader::setup_patch_mod_entries() { // File or directory found ClassPathEntry* new_entry = create_class_path_entry(current, path, &st, false, false); // If the path specification is valid, enter it into this module's list - if (new_entry != NULL) { + if (new_entry != nullptr) { module_cpl->add_to_list(new_entry); } } @@ -602,7 +602,7 @@ void ClassLoader::setup_patch_mod_entries() { // Record the module into the list of --patch-module entries only if // valid ClassPathEntrys have been created - if (module_cpl->module_first_entry() != NULL) { + if (module_cpl->module_first_entry() != nullptr) { _patch_mod_entries->push(module_cpl); } } @@ -611,7 +611,7 @@ void ClassLoader::setup_patch_mod_entries() { // Determine whether the module has been patched via the command-line // option --patch-module bool ClassLoader::is_in_patch_mod_entries(Symbol* module_name) { - if (_patch_mod_entries != NULL && _patch_mod_entries->is_nonempty()) { + if (_patch_mod_entries != nullptr && _patch_mod_entries->is_nonempty()) { int table_len = _patch_mod_entries->length(); for (int i = 0; i < table_len; i++) { ModuleClassPathList* patch_mod = _patch_mod_entries->at(i); @@ -632,7 +632,7 @@ void ClassLoader::setup_bootstrap_search_path_impl(JavaThread* current, const ch #if INCLUDE_CDS if (Arguments::is_dumping_archive()) { if (!Arguments::has_jimage()) { - vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL); + vm_exit_during_initialization("CDS is not supported in exploded JDK build", nullptr); } } #endif @@ -649,14 +649,14 @@ void ClassLoader::setup_bootstrap_search_path_impl(JavaThread* current, const ch struct stat st; if (os::stat(path, &st) == 0) { // Directory found - if (JImage_file != NULL) { + if (JImage_file != nullptr) { assert(Arguments::has_jimage(), "sanity check"); const char* canonical_path = get_canonical_path(path, current); - assert(canonical_path != NULL, "canonical_path issue"); + assert(canonical_path != nullptr, "canonical_path issue"); _jrt_entry = new ClassPathImageEntry(JImage_file, canonical_path); - assert(_jrt_entry != NULL && _jrt_entry->is_modules_image(), "No java runtime image present"); - assert(_jrt_entry->jimage() != NULL, "No java runtime image"); + assert(_jrt_entry != nullptr && _jrt_entry->is_modules_image(), "No java runtime image present"); + assert(_jrt_entry->jimage() != nullptr, "No java runtime image"); } // else it's an exploded build. } else { // If path does not exist, exit @@ -687,7 +687,7 @@ static const char* get_exploded_module_path(const char* module_name, bool c_heap // will be added to the ClassLoader::_exploded_entries array. void ClassLoader::add_to_exploded_build_list(JavaThread* current, Symbol* module_sym) { assert(!ClassLoader::has_jrt_entry(), "Exploded build not applicable"); - assert(_exploded_entries != NULL, "_exploded_entries was not initialized"); + assert(_exploded_entries != nullptr, "_exploded_entries was not initialized"); // Find the module's symbol ResourceMark rm(current); @@ -703,7 +703,7 @@ void ClassLoader::add_to_exploded_build_list(JavaThread* current, Symbol* module // There is no need to check for duplicate modules in the exploded entry list, // since no two modules with the same name can be defined to the boot loader. // This is checked at module definition time in Modules::define_module. - if (new_entry != NULL) { + if (new_entry != nullptr) { ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); module_cpl->add_to_list(new_entry); { @@ -727,24 +727,24 @@ ClassPathEntry* ClassLoader::create_class_path_entry(JavaThread* current, const char *path, const struct stat* st, bool is_boot_append, bool from_class_path_attr) { - ClassPathEntry* new_entry = NULL; + ClassPathEntry* new_entry = nullptr; if ((st->st_mode & S_IFMT) == S_IFREG) { ResourceMark rm(current); // Regular file, should be a zip file // Canonicalized filename const char* canonical_path = get_canonical_path(path, current); - if (canonical_path == NULL) { - return NULL; + if (canonical_path == nullptr) { + return nullptr; } - char* error_msg = NULL; + char* error_msg = nullptr; jzfile* zip = open_zip_file(canonical_path, &error_msg, current); - if (zip != NULL && error_msg == NULL) { + if (zip != nullptr && error_msg == nullptr) { new_entry = new ClassPathZipEntry(zip, path, is_boot_append, from_class_path_attr); } else { #if INCLUDE_CDS ClassLoaderExt::set_has_non_jar_in_classpath(); #endif - return NULL; + return nullptr; } log_info(class, path)("opened: %s", path); log_info(class, load)("opened: %s", path); @@ -757,7 +757,7 @@ ClassPathEntry* ClassLoader::create_class_path_entry(JavaThread* current, } -// Create a class path zip entry for a given path (return NULL if not found +// Create a class path zip entry for a given path (return null if not found // or zip/JAR file cannot be opened) ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bool is_boot_append) { // check for a regular file @@ -767,26 +767,26 @@ ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bo JavaThread* thread = JavaThread::current(); ResourceMark rm(thread); const char* canonical_path = get_canonical_path(path, thread); - if (canonical_path != NULL) { - char* error_msg = NULL; + if (canonical_path != nullptr) { + char* error_msg = nullptr; jzfile* zip = open_zip_file(canonical_path, &error_msg, thread); - if (zip != NULL && error_msg == NULL) { + if (zip != nullptr && error_msg == nullptr) { // create using canonical path return new ClassPathZipEntry(zip, canonical_path, is_boot_append, false); } } } } - return NULL; + return nullptr; } // The boot append entries are added with a lock, and read lock free. void ClassLoader::add_to_boot_append_entries(ClassPathEntry *new_entry) { - if (new_entry != NULL) { + if (new_entry != nullptr) { MutexLocker ml(Bootclasspath_lock, Mutex::_no_safepoint_check_flag); - if (_last_append_entry == NULL) { + if (_last_append_entry == nullptr) { _last_append_entry = new_entry; - assert(first_append_entry() == NULL, "boot loader's append class path entry list not empty"); + assert(first_append_entry() == nullptr, "boot loader's append class path entry list not empty"); Atomic::release_store(&_first_append_entry_list, new_entry); } else { _last_append_entry->set_next(new_entry); @@ -806,10 +806,10 @@ void ClassLoader::add_to_app_classpath_entries(JavaThread* current, ClassPathEntry* entry, bool check_for_duplicates) { #if INCLUDE_CDS - assert(entry != NULL, "ClassPathEntry should not be NULL"); + assert(entry != nullptr, "ClassPathEntry should not be nullptr"); ClassPathEntry* e = _app_classpath_entries; if (check_for_duplicates) { - while (e != NULL) { + while (e != nullptr) { if (strcmp(e->name(), entry->name()) == 0) { // entry already exists return; @@ -819,8 +819,8 @@ void ClassLoader::add_to_app_classpath_entries(JavaThread* current, } // The entry does not exist, add to the list - if (_app_classpath_entries == NULL) { - assert(_last_app_classpath_entry == NULL, "Sanity"); + if (_app_classpath_entries == nullptr) { + assert(_last_app_classpath_entry == nullptr, "Sanity"); _app_classpath_entries = _last_app_classpath_entry = entry; } else { _last_app_classpath_entry->set_next(entry); @@ -842,9 +842,9 @@ bool ClassLoader::update_class_path_entry_list(JavaThread* current, struct stat st; if (os::stat(path, &st) == 0) { // File or directory found - ClassPathEntry* new_entry = NULL; + ClassPathEntry* new_entry = nullptr; new_entry = create_class_path_entry(current, path, &st, is_boot_append, from_class_path_attr); - if (new_entry == NULL) { + if (new_entry == nullptr) { return false; } @@ -869,10 +869,10 @@ static void print_module_entry_table(const GrowableArray* ModuleClassPathList* mpl = module_list->at(i); tty->print("%s=", mpl->module_name()->as_C_string()); e = mpl->module_first_entry(); - while (e != NULL) { + while (e != nullptr) { tty->print("%s", e->name()); e = e->next(); - if (e != NULL) { + if (e != nullptr) { tty->print("%s", os::path_separator()); } } @@ -885,7 +885,7 @@ void ClassLoader::print_bootclasspath() { tty->print("[bootclasspath= "); // Print --patch-module module/path specifications first - if (_patch_mod_entries != NULL) { + if (_patch_mod_entries != nullptr) { print_module_entry_table(_patch_mod_entries); } @@ -895,14 +895,14 @@ void ClassLoader::print_bootclasspath() { tty->print("%s ;", _jrt_entry->name()); } else { // Print exploded module build path specifications - if (_exploded_entries != NULL) { + if (_exploded_entries != nullptr) { print_module_entry_table(_exploded_entries); } } // appended entries e = first_append_entry(); - while (e != NULL) { + while (e != nullptr) { tty->print("%s ;", e->name()); e = e->next(); } @@ -911,7 +911,7 @@ void ClassLoader::print_bootclasspath() { void* ClassLoader::dll_lookup(void* lib, const char* name, const char* path) { void* func = os::dll_lookup(lib, name); - if (func == NULL) { + if (func == nullptr) { char msg[256] = ""; jio_snprintf(msg, sizeof(msg), "Could not resolve \"%s\"", name); vm_exit_during_initialization(msg, path); @@ -920,13 +920,13 @@ void* ClassLoader::dll_lookup(void* lib, const char* name, const char* path) { } void ClassLoader::load_java_library() { - assert(CanonicalizeEntry == NULL, "should not load java library twice"); + assert(CanonicalizeEntry == nullptr, "should not load java library twice"); void *javalib_handle = os::native_java_library(); - if (javalib_handle == NULL) { - vm_exit_during_initialization("Unable to load java library", NULL); + if (javalib_handle == nullptr) { + vm_exit_during_initialization("Unable to load java library", nullptr); } - CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "JDK_Canonicalize", NULL)); + CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "JDK_Canonicalize", nullptr)); } void ClassLoader::release_load_zip_library() { @@ -938,13 +938,13 @@ void ClassLoader::release_load_zip_library() { } void ClassLoader::load_zip_library() { - assert(ZipOpen == NULL, "should not load zip library twice"); + assert(ZipOpen == nullptr, "should not load zip library twice"); char path[JVM_MAXPATHLEN]; char ebuf[1024]; if (os::dll_locate_lib(path, sizeof(path), Arguments::get_dll_dir(), "zip")) { _zip_handle = os::dll_load(path, ebuf, sizeof ebuf); } - if (_zip_handle == NULL) { + if (_zip_handle == nullptr) { vm_exit_during_initialization("Unable to load zip library", path); } @@ -956,14 +956,14 @@ void ClassLoader::load_zip_library() { } void ClassLoader::load_jimage_library() { - assert(JImageOpen == NULL, "should not load jimage library twice"); + assert(JImageOpen == nullptr, "should not load jimage library twice"); char path[JVM_MAXPATHLEN]; char ebuf[1024]; - void* handle = NULL; + void* handle = nullptr; if (os::dll_locate_lib(path, sizeof(path), Arguments::get_dll_dir(), "jimage")) { handle = os::dll_load(path, ebuf, sizeof ebuf); } - if (handle == NULL) { + if (handle == nullptr) { vm_exit_during_initialization("Unable to load jimage library", path); } @@ -980,17 +980,17 @@ int ClassLoader::crc32(int crc, const char* buf, int len) { oop ClassLoader::get_system_package(const char* name, TRAPS) { // Look up the name in the boot loader's package entry table. - if (name != NULL) { + if (name != nullptr) { TempNewSymbol package_sym = SymbolTable::new_symbol(name); // Look for the package entry in the boot loader's package entry table. PackageEntry* package = ClassLoaderData::the_null_class_loader_data()->packages()->lookup_only(package_sym); - // Return NULL if package does not exist or if no classes in that package + // Return null if package does not exist or if no classes in that package // have been loaded. - if (package != NULL && package->has_loaded_class()) { + if (package != nullptr && package->has_loaded_class()) { ModuleEntry* module = package->module(); - if (module->location() != NULL) { + if (module->location() != nullptr) { ResourceMark rm(THREAD); Handle ml = java_lang_String::create_from_str( module->location()->as_C_string(), THREAD); @@ -1002,7 +1002,7 @@ oop ClassLoader::get_system_package(const char* name, TRAPS) { return cph(); } } - return NULL; + return nullptr; } objArrayOop ClassLoader::get_system_packages(TRAPS) { @@ -1027,7 +1027,7 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) { // caller needs ResourceMark const char* ClassLoader::file_name_for_class_name(const char* class_name, int class_name_len) { - assert(class_name != NULL, "invariant"); + assert(class_name != nullptr, "invariant"); assert((int)strlen(class_name) == class_name_len, "invariant"); static const char class_suffix[] = ".class"; @@ -1035,7 +1035,7 @@ const char* ClassLoader::file_name_for_class_name(const char* class_name, char* const file_name = NEW_RESOURCE_ARRAY(char, class_name_len + - class_suffix_len); // includes term NULL + class_suffix_len); // includes term null strncpy(file_name, class_name, class_name_len); strncpy(&file_name[class_name_len], class_suffix, class_suffix_len); @@ -1058,7 +1058,7 @@ ClassPathEntry* find_first_module_cpe(ModuleEntry* mod_entry, return module_cpl->module_first_entry(); } } - return NULL; + return nullptr; } @@ -1067,13 +1067,13 @@ ClassFileStream* ClassLoader::search_module_entries(JavaThread* current, const GrowableArray* const module_list, const char* const class_name, const char* const file_name) { - ClassFileStream* stream = NULL; + ClassFileStream* stream = nullptr; // Find the class' defining module in the boot loader's module entry table TempNewSymbol class_name_symbol = SymbolTable::new_symbol(class_name); TempNewSymbol pkg_name = package_from_class_name(class_name_symbol); PackageEntry* pkg_entry = get_package_entry(pkg_name, ClassLoaderData::the_null_class_loader_data()); - ModuleEntry* mod_entry = (pkg_entry != NULL) ? pkg_entry->module() : NULL; + ModuleEntry* mod_entry = (pkg_entry != nullptr) ? pkg_entry->module() : nullptr; // If the module system has not defined java.base yet, then // classes loaded are assumed to be defined to java.base. @@ -1082,13 +1082,13 @@ ClassFileStream* ClassLoader::search_module_entries(JavaThread* current, // are verified in ModuleEntryTable::verify_javabase_packages(). if (!Universe::is_module_initialized() && !ModuleEntryTable::javabase_defined() && - mod_entry == NULL) { + mod_entry == nullptr) { mod_entry = ModuleEntryTable::javabase_moduleEntry(); } // The module must be a named module - ClassPathEntry* e = NULL; - if (mod_entry != NULL && mod_entry->is_named()) { + ClassPathEntry* e = nullptr; + if (mod_entry != nullptr && mod_entry->is_named()) { if (module_list == _exploded_entries) { // The exploded build entries can be added to at any time so a lock is // needed when searching them. @@ -1101,11 +1101,11 @@ ClassFileStream* ClassLoader::search_module_entries(JavaThread* current, } // Try to load the class from the module's ClassPathEntry list. - while (e != NULL) { + while (e != nullptr) { stream = e->open_stream(current, file_name); // No context.check is required since CDS is not supported // for an exploded modules build or if --patch-module is specified. - if (NULL != stream) { + if (nullptr != stream) { return stream; } e = e->next(); @@ -1113,12 +1113,12 @@ ClassFileStream* ClassLoader::search_module_entries(JavaThread* current, // If the module was located, break out even if the class was not // located successfully from that module's ClassPathEntry list. // There will not be another valid entry for that module. - return NULL; + return nullptr; } // Called by the boot classloader to load classes InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TRAPS) { - assert(name != NULL, "invariant"); + assert(name != nullptr, "invariant"); ResourceMark rm(THREAD); HandleMark hm(THREAD); @@ -1129,12 +1129,12 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR const char* const file_name = file_name_for_class_name(class_name, name->utf8_length()); - assert(file_name != NULL, "invariant"); + assert(file_name != nullptr, "invariant"); // Lookup stream for parsing .class file - ClassFileStream* stream = NULL; + ClassFileStream* stream = nullptr; s2 classpath_index = 0; - ClassPathEntry* e = NULL; + ClassPathEntry* e = nullptr; // If search_append_only is true, boot loader visibility boundaries are // set to be _first_append_entry to the end. This includes: @@ -1153,7 +1153,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR // found within its module specification, the search should continue to Load Attempt #2. // Note: The --patch-module entries are never searched if the boot loader's // visibility boundary is limited to only searching the append entries. - if (_patch_mod_entries != NULL && !search_append_only) { + if (_patch_mod_entries != nullptr && !search_append_only) { // At CDS dump time, the --patch-module entries are ignored. That means a // class is still loaded from the runtime image even if it might // appear in the _patch_mod_entries. The runtime shared class visibility @@ -1169,19 +1169,19 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR } // Load Attempt #2: [jimage | exploded build] - if (!search_append_only && (NULL == stream)) { + if (!search_append_only && (nullptr == stream)) { if (has_jrt_entry()) { e = _jrt_entry; stream = _jrt_entry->open_stream(THREAD, file_name); } else { // Exploded build - attempt to locate class in its defining module's location. - assert(_exploded_entries != NULL, "No exploded build entries present"); + assert(_exploded_entries != nullptr, "No exploded build entries present"); stream = search_module_entries(THREAD, _exploded_entries, class_name, file_name); } } // Load Attempt #3: [-Xbootclasspath/a]; [jvmti appended entries] - if (search_append_only && (NULL == stream)) { + if (search_append_only && (nullptr == stream)) { // For the boot loader append path search, the starting classpath_index // for the appended piece is always 1 to account for either the // _jrt_entry or the _exploded_entries. @@ -1189,9 +1189,9 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR classpath_index = 1; e = first_append_entry(); - while (e != NULL) { + while (e != nullptr) { stream = e->open_stream(THREAD, file_name); - if (NULL != stream) { + if (nullptr != stream) { break; } e = e->next(); @@ -1199,8 +1199,8 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR } } - if (NULL == stream) { - return NULL; + if (nullptr == stream) { + return nullptr; } stream->set_verify(ClassLoaderExt::should_verify(classpath_index)); @@ -1243,7 +1243,7 @@ char* ClassLoader::skip_uri_protocol(char* source) { void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, const ClassFileStream* stream, bool redefined) { Arguments::assert_is_dumping_archive(); - assert(stream != NULL, "sanity"); + assert(stream != nullptr, "sanity"); if (ik->is_hidden()) { // We do not archive hidden classes. @@ -1252,8 +1252,8 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, oop loader = ik->class_loader(); char* src = (char*)stream->source(); - if (src == NULL) { - if (loader == NULL) { + if (src == nullptr) { + if (loader == nullptr) { // JFR classes ik->set_shared_classpath_index(0); ik->set_shared_class_loader_type(ClassLoader::BOOT_LOADER); @@ -1272,22 +1272,22 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, // if no protocol prefix is found, path is the same as stream->source(). This path // must be valid since the class has been successfully parsed. char* path = skip_uri_protocol(src); - assert(path != NULL, "sanity"); + assert(path != nullptr, "sanity"); for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) { SharedClassPathEntry* ent = FileMapInfo::shared_path(i); // A shared path has been validated during its creation in ClassLoader::create_class_path_entry(), // it must be valid here. - assert(ent->name() != NULL, "sanity"); + assert(ent->name() != nullptr, "sanity"); // If the path (from the class stream source) is the same as the shared // class or module path, then we have a match. // src may come from the App/Platform class loaders, which would canonicalize // the file name. We cannot use strcmp to check for equality against ent->name(). // We must use os::same_files (which is faster than canonicalizing ent->name()). if (os::same_files(ent->name(), path)) { - // NULL pkg_entry and pkg_entry in an unnamed module implies the class + // null pkg_entry and pkg_entry in an unnamed module implies the class // is from the -cp or boot loader append path which consists of -Xbootclasspath/a // and jvmti appended entries. - if ((pkg_entry == NULL) || (pkg_entry->in_unnamed_module())) { + if ((pkg_entry == nullptr) || (pkg_entry->in_unnamed_module())) { // Ensure the index is within the -cp range before assigning // to the classpath_index. if (SystemDictionary::is_system_class_loader(loader) && @@ -1300,7 +1300,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, (i < ClassLoaderExt::app_class_paths_start_index())) { // The class must be from boot loader append path which consists of // -Xbootclasspath/a and jvmti appended entries. - assert(loader == NULL, "sanity"); + assert(loader == nullptr, "sanity"); classpath_index = i; break; } @@ -1308,7 +1308,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, } else { // A class from a named module from the --module-path. Ensure the index is // within the --module-path range before assigning to the classpath_index. - if ((pkg_entry != NULL) && !(pkg_entry->in_unnamed_module()) && (i > 0)) { + if ((pkg_entry != nullptr) && !(pkg_entry->in_unnamed_module()) && (i > 0)) { if (i >= ClassLoaderExt::app_module_paths_start_index() && i < FileMapInfo::get_number_of_shared_paths()) { classpath_index = i; @@ -1345,7 +1345,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, const char* const class_name = ik->name()->as_C_string(); const char* const file_name = file_name_for_class_name(class_name, ik->name()->utf8_length()); - assert(file_name != NULL, "invariant"); + assert(file_name != nullptr, "invariant"); ClassLoaderExt::record_result(classpath_index, ik, redefined); } @@ -1395,7 +1395,7 @@ char* lookup_vm_resource(JImageFile *jimage, const char *jimage_version, const c jlong size; JImageLocationRef location = (*JImageFindResource)(jimage, "java.base", jimage_version, path, &size); if (location == 0) - return NULL; + return nullptr; char *val = NEW_C_HEAP_ARRAY(char, size+1, mtClass); (*JImageGetResource)(jimage, location, val, size); val[size] = '\0'; @@ -1413,8 +1413,8 @@ char* ClassLoader::lookup_vm_options() { jio_snprintf(modules_path, JVM_MAXPATHLEN, "%s%slib%smodules", Arguments::get_java_home(), fileSep, fileSep); JImage_file =(*JImageOpen)(modules_path, &error); - if (JImage_file == NULL) { - return NULL; + if (JImage_file == nullptr) { + return nullptr; } const char *jimage_version = get_jimage_version_string(); @@ -1423,8 +1423,8 @@ char* ClassLoader::lookup_vm_options() { } bool ClassLoader::is_module_observable(const char* module_name) { - assert(JImageOpen != NULL, "jimage library should have been opened"); - if (JImage_file == NULL) { + assert(JImageOpen != nullptr, "jimage library should have been opened"); + if (JImage_file == nullptr) { struct stat st; const char *path = get_exploded_module_path(module_name, true); bool res = os::stat(path, &st) == 0; @@ -1456,7 +1456,7 @@ int ClassLoader::num_module_path_entries() { Arguments::assert_is_dumping_archive(); int num_entries = 0; ClassPathEntry* e= ClassLoader::_module_path_entries; - while (e != NULL) { + while (e != nullptr) { num_entries ++; e = e->next(); } @@ -1514,7 +1514,7 @@ void ClassLoader::classLoader_init2(JavaThread* current) { // Setup the list of module/path pairs for --patch-module processing // This must be done after the SymbolTable is created in order // to use fast_compare on module names instead of a string compare. - if (Arguments::get_patch_mod_prefix() != NULL) { + if (Arguments::get_patch_mod_prefix() != nullptr) { setup_patch_mod_entries(); } @@ -1532,7 +1532,7 @@ void ClassLoader::classLoader_init2(JavaThread* current) { // Set up the boot loader's _exploded_entries list. Note that this gets // done before loading any classes, by the same thread that will // subsequently do the first class load. So, no lock is needed for this. - assert(_exploded_entries == NULL, "Should only get initialized once"); + assert(_exploded_entries == nullptr, "Should only get initialized once"); _exploded_entries = new (mtModule) GrowableArray(EXPLODED_ENTRY_SIZE, mtModule); add_to_exploded_build_list(current, vmSymbols::java_base()); @@ -1540,7 +1540,7 @@ void ClassLoader::classLoader_init2(JavaThread* current) { } char* ClassLoader::get_canonical_path(const char* orig, Thread* thread) { - assert(orig != NULL, "bad arguments"); + assert(orig != nullptr, "bad arguments"); // caller needs to allocate ResourceMark for the following output buffer char* canonical_path = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, JVM_MAXPATHLEN); ResourceMark rm(thread); @@ -1548,7 +1548,7 @@ char* ClassLoader::get_canonical_path(const char* orig, Thread* thread) { char* orig_copy = NEW_RESOURCE_ARRAY_IN_THREAD(thread, char, strlen(orig)+1); strcpy(orig_copy, orig); if ((CanonicalizeEntry)(os::native_path(orig_copy), canonical_path, JVM_MAXPATHLEN) < 0) { - return NULL; + return nullptr; } return canonical_path; } @@ -1562,16 +1562,16 @@ void ClassLoader::create_javabase() { // Get module entry table ModuleEntryTable* null_cld_modules = null_cld->modules(); - if (null_cld_modules == NULL) { + if (null_cld_modules == nullptr) { vm_exit_during_initialization("No ModuleEntryTable for the boot class loader"); } { MutexLocker ml(current, Module_lock); - if (ModuleEntryTable::javabase_moduleEntry() == NULL) { // may have been inited by CDS. + if (ModuleEntryTable::javabase_moduleEntry() == nullptr) { // may have been inited by CDS. ModuleEntry* jb_module = null_cld_modules->locked_create_entry(Handle(), - false, vmSymbols::java_base(), NULL, NULL, null_cld); - if (jb_module == NULL) { + false, vmSymbols::java_base(), nullptr, nullptr, null_cld); + if (jb_module == nullptr) { vm_exit_during_initialization("Unable to create ModuleEntry for " JAVA_BASE_NAME); } ModuleEntryTable::set_javabase_moduleEntry(jb_module); @@ -1584,7 +1584,7 @@ void ClassLoader::create_javabase() { void PerfClassTraceTime::initialize() { if (!UsePerfData) return; - if (_eventp != NULL) { + if (_eventp != nullptr) { // increment the event counter _eventp->inc(); } @@ -1599,7 +1599,7 @@ void PerfClassTraceTime::initialize() { } } - if (_recursion_counters == NULL || (_recursion_counters[_event_type])++ == 0) { + if (_recursion_counters == nullptr || (_recursion_counters[_event_type])++ == 0) { // start the inclusive timer if not recursively called _t.start(); } @@ -1622,12 +1622,12 @@ PerfClassTraceTime::~PerfClassTraceTime() { _timers[_prev_active_event].start(); } - if (_recursion_counters != NULL && --(_recursion_counters[_event_type]) > 0) return; + if (_recursion_counters != nullptr && --(_recursion_counters[_event_type]) > 0) return; // increment the counters only on the leaf call _t.stop(); _timep->inc(_t.ticks()); - if (_selftimep != NULL) { + if (_selftimep != nullptr) { _selftimep->inc(selftime); } // add all class loading related event selftime to the accumulated time counter diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index 56aa0977739..728c97ccaca 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -59,10 +59,10 @@ public: // Is this entry created from the "Class-path" attribute from a JAR Manifest? virtual bool from_class_path_attr() const { return false; } virtual const char* name() const = 0; - virtual JImageFile* jimage() const { return NULL; } + virtual JImageFile* jimage() const { return nullptr; } virtual void close_jimage() {} // Constructor - ClassPathEntry() : _next(NULL) {} + ClassPathEntry() : _next(nullptr) {} // Attempt to locate file_name through this class path entry. // Returns a class file parsing stream if successful. virtual ClassFileStream* open_stream(JavaThread* current, const char* name) = 0; @@ -120,7 +120,7 @@ private: DEBUG_ONLY(static ClassPathImageEntry* _singleton;) public: bool is_modules_image() const; - const char* name() const { return _name == NULL ? "" : _name; } + const char* name() const { return _name == nullptr ? "" : _name; } JImageFile* jimage() const; JImageFile* jimage_non_null() const; void close_jimage(); @@ -235,7 +235,7 @@ class ClassLoader: AllStatic { CDS_ONLY(static ClassPathEntry* app_classpath_entries() {return _app_classpath_entries;}) CDS_ONLY(static ClassPathEntry* module_path_entries() {return _module_path_entries;}) - static bool has_bootclasspath_append() { return first_append_entry() != NULL; } + static bool has_bootclasspath_append() { return first_append_entry() != nullptr; } protected: // Initialization: @@ -308,7 +308,7 @@ class ClassLoader: AllStatic { } // Modular java runtime image is present vs. a build with exploded modules - static bool has_jrt_entry() { return (_jrt_entry != NULL); } + static bool has_jrt_entry() { return (_jrt_entry != nullptr); } static ClassPathEntry* get_jrt_entry() { return _jrt_entry; } static void close_jrt_image(); @@ -381,7 +381,7 @@ class ClassLoader: AllStatic { static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name, const char* file_name, jlong &size); - static void trace_class_path(const char* msg, const char* name = NULL); + static void trace_class_path(const char* msg, const char* name = nullptr); // VM monitoring and management support static jlong classloader_time_ms(); @@ -395,15 +395,15 @@ class ClassLoader: AllStatic { // adds a class path to the boot append entries static void add_to_boot_append_entries(ClassPathEntry* new_entry); - // creates a class path zip entry (returns NULL if JAR file cannot be opened) + // creates a class path zip entry (returns null if JAR file cannot be opened) static ClassPathZipEntry* create_class_path_zip_entry(const char *apath, bool is_boot_append); static bool string_ends_with(const char* str, const char* str_to_find); // Extract package name from a fully qualified class name // *bad_class_name is set to true if there's a problem with parsing class_name, to - // distinguish from a class_name with no package name, as both cases have a NULL return value - static Symbol* package_from_class_name(const Symbol* class_name, bool* bad_class_name = NULL); + // distinguish from a class_name with no package name, as both cases have a null return value + static Symbol* package_from_class_name(const Symbol* class_name, bool* bad_class_name = nullptr); // Debugging static void verify() PRODUCT_RETURN; @@ -458,7 +458,7 @@ class PerfClassTraceTime { inline PerfClassTraceTime(PerfLongCounter* timep, /* counter incremented with inclusive time */ elapsedTimer* timers, /* thread-local timer array */ int type /* event type */ ) : - _timep(timep), _selftimep(NULL), _eventp(NULL), _recursion_counters(NULL), _timers(timers), _event_type(type) { + _timep(timep), _selftimep(nullptr), _eventp(nullptr), _recursion_counters(nullptr), _timers(timers), _event_type(type) { initialize(); } diff --git a/src/hotspot/share/classfile/classLoader.inline.hpp b/src/hotspot/share/classfile/classLoader.inline.hpp index 183024252cd..fd22b67165b 100644 --- a/src/hotspot/share/classfile/classLoader.inline.hpp +++ b/src/hotspot/share/classfile/classLoader.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, 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 @@ -51,7 +51,7 @@ inline ClassPathEntry* ClassLoader::classpath_entry(int n) { // class path vs. the shared archive class path. ClassPathEntry* e = first_append_entry(); while (--n >= 1) { - assert(e != NULL, "Not that many classpath entries."); + assert(e != nullptr, "Not that many classpath entries."); e = e->next(); } return e; @@ -74,7 +74,7 @@ inline int ClassLoader::num_boot_classpath_entries() { assert(has_jrt_entry(), "must have a java runtime image"); int num_entries = 1; // count the runtime image ClassPathEntry* e = first_append_entry(); - while (e != NULL) { + while (e != nullptr) { num_entries ++; e = e->next(); } @@ -95,7 +95,7 @@ inline int ClassLoader::num_app_classpath_entries() { Arguments::assert_is_dumping_archive(); int num_entries = 0; ClassPathEntry* e= ClassLoader::_app_classpath_entries; - while (e != NULL) { + while (e != nullptr) { num_entries ++; e = e->next(); } diff --git a/src/hotspot/share/classfile/classLoaderData.cpp b/src/hotspot/share/classfile/classLoaderData.cpp index 3feb706f394..f31cc9760d9 100644 --- a/src/hotspot/share/classfile/classLoaderData.cpp +++ b/src/hotspot/share/classfile/classLoaderData.cpp @@ -43,7 +43,7 @@ // Instances of java.lang.ClassLoader holds a pointer to a ClassLoaderData that // that represent the loader's "linking domain" in the JVM. // -// The bootstrap loader (represented by NULL) also has a ClassLoaderData, +// The bootstrap loader (represented by null) also has a ClassLoaderData, // the singleton class the_null_class_loader_data(). #include "precompiled.hpp" @@ -80,11 +80,11 @@ #include "utilities/macros.hpp" #include "utilities/ostream.hpp" -ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL; +ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = nullptr; void ClassLoaderData::init_null_class_loader_data() { - assert(_the_null_class_loader_data == NULL, "cannot initialize twice"); - assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice"); + assert(_the_null_class_loader_data == nullptr, "cannot initialize twice"); + assert(ClassLoaderDataGraph::_head == nullptr, "cannot initialize twice"); _the_null_class_loader_data = new ClassLoaderData(Handle(), false); ClassLoaderDataGraph::_head = _the_null_class_loader_data; @@ -110,10 +110,10 @@ void ClassLoaderData::initialize_name(Handle class_loader) { // Obtain the class loader's name. If the class loader's name was not // explicitly set during construction, the CLD's _name field will be null. oop cl_name = java_lang_ClassLoader::name(class_loader()); - if (cl_name != NULL) { + if (cl_name != nullptr) { const char* cl_instance_name = java_lang_String::as_utf8_string(cl_name); - if (cl_instance_name != NULL && cl_instance_name[0] != '\0') { + if (cl_instance_name != nullptr && cl_instance_name[0] != '\0') { _name = SymbolTable::new_symbol(cl_instance_name); } } @@ -127,14 +127,14 @@ void ClassLoaderData::initialize_name(Handle class_loader) { // name. Thus CLD's _name_and_id field should never have a null value. oop cl_name_and_id = java_lang_ClassLoader::nameAndId(class_loader()); const char* cl_instance_name_and_id = - (cl_name_and_id == NULL) ? _class_loader_klass->external_name() : + (cl_name_and_id == nullptr) ? _class_loader_klass->external_name() : java_lang_String::as_utf8_string(cl_name_and_id); - assert(cl_instance_name_and_id != NULL && cl_instance_name_and_id[0] != '\0', "class loader has no name and id"); + assert(cl_instance_name_and_id != nullptr && cl_instance_name_and_id[0] != '\0', "class loader has no name and id"); _name_and_id = SymbolTable::new_symbol(cl_instance_name_and_id); } ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool has_class_mirror_holder) : - _metaspace(NULL), + _metaspace(nullptr), _metaspace_lock(new Mutex(Mutex::nosafepoint-2, "MetaspaceAllocation_lock")), _unloading(false), _has_class_mirror_holder(has_class_mirror_holder), _modified_oops(true), @@ -144,11 +144,11 @@ ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool has_class_mirror_ho _keep_alive((has_class_mirror_holder || h_class_loader.is_null()) ? 1 : 0), _claim(0), _handles(), - _klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL), - _jmethod_ids(NULL), - _deallocate_list(NULL), - _next(NULL), - _class_loader_klass(NULL), _name(NULL), _name_and_id(NULL) { + _klasses(nullptr), _packages(nullptr), _modules(nullptr), _unnamed_module(nullptr), _dictionary(nullptr), + _jmethod_ids(nullptr), + _deallocate_list(nullptr), + _next(nullptr), + _class_loader_klass(nullptr), _name(nullptr), _name_and_id(nullptr) { if (!h_class_loader.is_null()) { _class_loader = _handles.add(h_class_loader()); @@ -181,7 +181,7 @@ ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool has_class_mirror_ho ClassLoaderData::ChunkedHandleList::~ChunkedHandleList() { Chunk* c = _head; - while (c != NULL) { + while (c != nullptr) { Chunk* next = c->_next; delete c; c = next; @@ -189,7 +189,7 @@ ClassLoaderData::ChunkedHandleList::~ChunkedHandleList() { } OopHandle ClassLoaderData::ChunkedHandleList::add(oop o) { - if (_head == NULL || _head->_size == Chunk::CAPACITY) { + if (_head == nullptr || _head->_size == Chunk::CAPACITY) { Chunk* next = new Chunk(_head); Atomic::release_store(&_head, next); } @@ -202,7 +202,7 @@ OopHandle ClassLoaderData::ChunkedHandleList::add(oop o) { int ClassLoaderData::ChunkedHandleList::count() const { int count = 0; Chunk* chunk = _head; - while (chunk != NULL) { + while (chunk != nullptr) { count += chunk->_size; chunk = chunk->_next; } @@ -217,10 +217,10 @@ inline void ClassLoaderData::ChunkedHandleList::oops_do_chunk(OopClosure* f, Chu void ClassLoaderData::ChunkedHandleList::oops_do(OopClosure* f) { Chunk* head = Atomic::load_acquire(&_head); - if (head != NULL) { + if (head != nullptr) { // Must be careful when reading size of head oops_do_chunk(f, head, Atomic::load_acquire(&head->_size)); - for (Chunk* c = head->_next; c != NULL; c = c->_next) { + for (Chunk* c = head->_next; c != nullptr; c = c->_next) { oops_do_chunk(f, c, c->_size); } } @@ -234,7 +234,7 @@ class VerifyContainsOopClosure : public OopClosure { VerifyContainsOopClosure(oop target) : _target(target), _found(false) {} void do_oop(oop* p) { - if (p != NULL && NativeAccess::oop_load(p) == _target) { + if (p != nullptr && NativeAccess::oop_load(p) == _target) { _found = true; } } @@ -258,7 +258,7 @@ bool ClassLoaderData::ChunkedHandleList::contains(oop p) { #ifndef PRODUCT bool ClassLoaderData::ChunkedHandleList::owner_of(oop* oop_handle) { Chunk* chunk = _head; - while (chunk != NULL) { + while (chunk != nullptr) { if (&(chunk->_data[0]) <= oop_handle && oop_handle < &(chunk->_data[chunk->_size])) { return true; } @@ -334,7 +334,7 @@ void ClassLoaderData::oops_do(OopClosure* f, int claim_value, bool clear_mod_oop void ClassLoaderData::classes_do(KlassClosure* klass_closure) { // Lock-free access requires load_acquire - for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) { + for (Klass* k = Atomic::load_acquire(&_klasses); k != nullptr; k = k->next_link()) { klass_closure->do_klass(k); assert(k != k->next_link(), "no loops!"); } @@ -342,7 +342,7 @@ void ClassLoaderData::classes_do(KlassClosure* klass_closure) { void ClassLoaderData::classes_do(void f(Klass * const)) { // Lock-free access requires load_acquire - for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) { + for (Klass* k = Atomic::load_acquire(&_klasses); k != nullptr; k = k->next_link()) { f(k); assert(k != k->next_link(), "no loops!"); } @@ -350,7 +350,7 @@ void ClassLoaderData::classes_do(void f(Klass * const)) { void ClassLoaderData::methods_do(void f(Method*)) { // Lock-free access requires load_acquire - for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) { + for (Klass* k = Atomic::load_acquire(&_klasses); k != nullptr; k = k->next_link()) { if (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded()) { InstanceKlass::cast(k)->methods_do(f); } @@ -362,7 +362,7 @@ void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { assert_locked_or_safepoint(MultiArray_lock); // Lock-free access requires load_acquire - for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) { + for (Klass* k = Atomic::load_acquire(&_klasses); k != nullptr; k = k->next_link()) { // Filter out InstanceKlasses (or their ObjArrayKlasses) that have not entered the // loaded state. if (k->is_instance_klass()) { @@ -381,7 +381,7 @@ void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { #ifdef ASSERT oop m = k->java_mirror(); - assert(m != NULL, "NULL mirror"); + assert(m != nullptr, "nullptr mirror"); assert(m->is_a(vmClasses::Class_klass()), "invalid mirror"); #endif klass_closure->do_klass(k); @@ -390,7 +390,7 @@ void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { void ClassLoaderData::classes_do(void f(InstanceKlass*)) { // Lock-free access requires load_acquire - for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) { + for (Klass* k = Atomic::load_acquire(&_klasses); k != nullptr; k = k->next_link()) { if (k->is_instance_klass()) { f(InstanceKlass::cast(k)); } @@ -400,23 +400,23 @@ void ClassLoaderData::classes_do(void f(InstanceKlass*)) { void ClassLoaderData::modules_do(void f(ModuleEntry*)) { assert_locked_or_safepoint(Module_lock); - if (_unnamed_module != NULL) { + if (_unnamed_module != nullptr) { f(_unnamed_module); } - if (_modules != NULL) { + if (_modules != nullptr) { _modules->modules_do(f); } } void ClassLoaderData::packages_do(void f(PackageEntry*)) { assert_locked_or_safepoint(Module_lock); - if (_packages != NULL) { + if (_packages != nullptr) { _packages->packages_do(f); } } void ClassLoaderData::record_dependency(const Klass* k) { - assert(k != NULL, "invariant"); + assert(k != nullptr, "invariant"); ClassLoaderData * const from_cld = this; ClassLoaderData * const to_cld = k->class_loader_data(); @@ -498,7 +498,7 @@ void ClassLoaderData::add_class(Klass* k, bool publicize /* true */) { } void ClassLoaderData::initialize_holder(Handle loader_or_mirror) { - if (loader_or_mirror() != NULL) { + if (loader_or_mirror() != nullptr) { assert(_holder.is_null(), "never replace holders"); _holder = WeakHandle(Universe::vm_weak(), loader_or_mirror); } @@ -512,10 +512,10 @@ void ClassLoaderData::remove_class(Klass* scratch_class) { // Adjust global class iterator. ClassLoaderDataGraph::adjust_saved_class(scratch_class); - Klass* prev = NULL; - for (Klass* k = _klasses; k != NULL; k = k->next_link()) { + Klass* prev = nullptr; + for (Klass* k = _klasses; k != nullptr; k = k->next_link()) { if (k == scratch_class) { - if (prev == NULL) { + if (prev == nullptr) { _klasses = k->next_link(); } else { Klass* next = k->next_link(); @@ -557,7 +557,7 @@ void ClassLoaderData::unload() { // after erroneous classes are released. classes_do(InstanceKlass::unload_class); - // Method::clear_jmethod_ids only sets the jmethod_ids to NULL without + // Method::clear_jmethod_ids only sets the jmethod_ids to null without // releasing the memory for related JNIMethodBlocks and JNIMethodBlockNodes. // This is done intentionally because native code (e.g. JVMTI agent) holding // jmethod_ids may access them after the associated classes and class loader @@ -565,10 +565,10 @@ void ClassLoaderData::unload() { // does not prevent the VM from unloading the class from which the ID has // been derived. After the class is unloaded, the method or field ID becomes // invalid". In real world usages, the native code may rely on jmethod_ids - // being NULL after class unloading. Hence, it is unsafe to free the memory + // being null after class unloading. Hence, it is unsafe to free the memory // from the VM side without knowing when native code is going to stop using // them. - if (_jmethod_ids != NULL) { + if (_jmethod_ids != nullptr) { Method::clear_jmethod_ids(this); } @@ -580,10 +580,10 @@ ModuleEntryTable* ClassLoaderData::modules() { // Lazily create the module entry table at first request. // Lock-free access requires load_acquire. ModuleEntryTable* modules = Atomic::load_acquire(&_modules); - if (modules == NULL) { + if (modules == nullptr) { MutexLocker m1(Module_lock); // Check if _modules got allocated while we were waiting for this lock. - if ((modules = _modules) == NULL) { + if ((modules = _modules) == nullptr) { modules = new ModuleEntryTable(); { @@ -602,7 +602,7 @@ const int _default_loader_dictionary_size = 107; Dictionary* ClassLoaderData::create_dictionary() { assert(!has_class_mirror_holder(), "class mirror holder cld does not have a dictionary"); int size; - if (_the_null_class_loader_data == NULL) { + if (_the_null_class_loader_data == nullptr) { size = _boot_loader_dictionary_size; } else if (class_loader()->is_a(vmClasses::reflect_DelegatingClassLoader_klass())) { size = 1; // there's only one class in relection class loader and no initiated classes @@ -622,26 +622,26 @@ oop ClassLoaderData::holder() const { // or a reachable object making it alive again. The SATB part of G1 needs // to get notified about this potential resurrection, otherwise the marking // might not find the object. - if (!_holder.is_null()) { // NULL class_loader + if (!_holder.is_null()) { // null class_loader return _holder.resolve(); } else { - return NULL; + return nullptr; } } // Let the GC read the holder without keeping it alive. oop ClassLoaderData::holder_no_keepalive() const { - if (!_holder.is_null()) { // NULL class_loader + if (!_holder.is_null()) { // null class_loader return _holder.peek(); } else { - return NULL; + return nullptr; } } // Unloading support bool ClassLoaderData::is_alive() const { bool alive = keep_alive() // null class loader and incomplete non-strong hidden class. - || (_holder.peek() != NULL); // and not cleaned by the GC weak handle processing. + || (_holder.peek() != nullptr); // and not cleaned by the GC weak handle processing. return alive; } @@ -679,35 +679,35 @@ ClassLoaderData::~ClassLoaderData() { _holder.release(Universe::vm_weak()); // Release C heap allocated hashtable for all the packages. - if (_packages != NULL) { + if (_packages != nullptr) { // Destroy the table itself delete _packages; - _packages = NULL; + _packages = nullptr; } // Release C heap allocated hashtable for all the modules. - if (_modules != NULL) { + if (_modules != nullptr) { // Destroy the table itself delete _modules; - _modules = NULL; + _modules = nullptr; } // Release C heap allocated hashtable for the dictionary - if (_dictionary != NULL) { + if (_dictionary != nullptr) { // Destroy the table itself delete _dictionary; - _dictionary = NULL; + _dictionary = nullptr; } - if (_unnamed_module != NULL) { + if (_unnamed_module != nullptr) { delete _unnamed_module; - _unnamed_module = NULL; + _unnamed_module = nullptr; } // release the metaspace ClassLoaderMetaspace *m = _metaspace; - if (m != NULL) { - _metaspace = NULL; + if (m != nullptr) { + _metaspace = nullptr; delete m; } @@ -715,15 +715,15 @@ ClassLoaderData::~ClassLoaderData() { delete _metaspace_lock; // Delete free list - if (_deallocate_list != NULL) { + if (_deallocate_list != nullptr) { delete _deallocate_list; } // Decrement refcounts of Symbols if created. - if (_name != NULL) { + if (_name != nullptr) { _name->decrement_refcount(); } - if (_name_and_id != NULL) { + if (_name_and_id != nullptr) { _name_and_id->decrement_refcount(); } } @@ -766,12 +766,12 @@ ClassLoaderMetaspace* ClassLoaderData::metaspace_non_null() { // simply for delegating with no metadata of their own. // Lock-free access requires load_acquire. ClassLoaderMetaspace* metaspace = Atomic::load_acquire(&_metaspace); - if (metaspace == NULL) { + if (metaspace == nullptr) { MutexLocker ml(_metaspace_lock, Mutex::_no_safepoint_check_flag); // Check if _metaspace got allocated while we were waiting for this lock. - if ((metaspace = _metaspace) == NULL) { + if ((metaspace = _metaspace) == nullptr) { if (this == the_null_class_loader_data()) { - assert (class_loader() == NULL, "Must be"); + assert (class_loader() == nullptr, "Must be"); metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::BootMetaspaceType); } else if (has_class_mirror_holder()) { metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::ClassMirrorHolderMetaspaceType); @@ -796,15 +796,15 @@ OopHandle ClassLoaderData::add_handle(Handle h) { void ClassLoaderData::remove_handle(OopHandle h) { assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading"); oop* ptr = h.ptr_raw(); - if (ptr != NULL) { + if (ptr != nullptr) { assert(_handles.owner_of(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr)); - NativeAccess<>::oop_store(ptr, oop(NULL)); + NativeAccess<>::oop_store(ptr, oop(nullptr)); } } void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) { MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); - if (dest.resolve() != NULL) { + if (dest.resolve() != nullptr) { return; } else { record_modified_oops(); @@ -818,7 +818,7 @@ void ClassLoaderData::add_to_deallocate_list(Metadata* m) { // Metadata in shared region isn't deleted. if (!m->is_shared()) { MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); - if (_deallocate_list == NULL) { + if (_deallocate_list == nullptr) { _deallocate_list = new (mtClass) GrowableArray(100, mtClass); } _deallocate_list->append_if_missing(m); @@ -834,7 +834,7 @@ void ClassLoaderData::free_deallocate_list() { // safepoint cleanup time. assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); assert(!is_unloading(), "only called for ClassLoaderData that are not unloading"); - if (_deallocate_list == NULL) { + if (_deallocate_list == nullptr) { return; } // Go backwards because this removes entries that are freed. @@ -873,7 +873,7 @@ void ClassLoaderData::free_deallocate_list() { void ClassLoaderData::free_deallocate_list_C_heap_structures() { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); assert(is_unloading(), "only called for ClassLoaderData that are unloading"); - if (_deallocate_list == NULL) { + if (_deallocate_list == nullptr) { return; } // Go backwards because this removes entries that are freed. @@ -899,9 +899,9 @@ void ClassLoaderData::free_deallocate_list_C_heap_structures() { // If the class loader's _name has not been explicitly set, the class loader's // qualified class name is returned. const char* ClassLoaderData::loader_name() const { - if (_class_loader_klass == NULL) { + if (_class_loader_klass == nullptr) { return BOOTSTRAP_LOADER_NAME; - } else if (_name != NULL) { + } else if (_name != nullptr) { return _name->as_C_string(); } else { return _class_loader_klass->external_name(); @@ -914,9 +914,9 @@ const char* ClassLoaderData::loader_name() const { // If the defining loader has no name then @ // If built-in loader, then omit '@' as there is only one instance. const char* ClassLoaderData::loader_name_and_id() const { - if (_class_loader_klass == NULL) { + if (_class_loader_klass == nullptr) { return "'" BOOTSTRAP_LOADER_NAME "'"; - } else if (_name_and_id != NULL) { + } else if (_name_and_id != nullptr) { return _name_and_id->as_C_string(); } else { // May be called in a race before _name_and_id is initialized. @@ -925,7 +925,7 @@ const char* ClassLoaderData::loader_name_and_id() const { } void ClassLoaderData::print_value_on(outputStream* out) const { - if (!is_unloading() && class_loader() != NULL) { + if (!is_unloading() && class_loader() != nullptr) { out->print("loader data: " INTPTR_FORMAT " for instance ", p2i(this)); class_loader()->print_value_on(out); // includes loader_name_and_id() and address of class loader instance } else { @@ -997,7 +997,7 @@ void ClassLoaderData::print_on(outputStream* out) const { } else { out->print_cr(" - dictionary " INTPTR_FORMAT, p2i(_dictionary)); } - if (_jmethod_ids != NULL) { + if (_jmethod_ids != nullptr) { out->print (" - jmethod count "); Method::print_jmethod_ids_count(this, out); out->print_cr(""); @@ -1031,22 +1031,22 @@ void ClassLoaderData::verify() { oop cl = class_loader(); guarantee(this == class_loader_data(cl) || has_class_mirror_holder(), "Must be the same"); - guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || has_class_mirror_holder(), "must be"); + guarantee(cl != nullptr || this == ClassLoaderData::the_null_class_loader_data() || has_class_mirror_holder(), "must be"); // Verify the integrity of the allocated space. #ifdef ASSERT - if (metaspace_or_null() != NULL) { + if (metaspace_or_null() != nullptr) { metaspace_or_null()->verify(); } #endif - for (Klass* k = _klasses; k != NULL; k = k->next_link()) { + for (Klass* k = _klasses; k != nullptr; k = k->next_link()) { guarantee(k->class_loader_data() == this, "Must be the same"); k->verify(); assert(k != k->next_link(), "no loops!"); } - if (_modules != NULL) { + if (_modules != nullptr) { _modules->verify(); } @@ -1066,7 +1066,7 @@ void ClassLoaderData::verify() { bool ClassLoaderData::contains_klass(Klass* klass) { // Lock-free access requires load_acquire - for (Klass* k = Atomic::load_acquire(&_klasses); k != NULL; k = k->next_link()) { + for (Klass* k = Atomic::load_acquire(&_klasses); k != nullptr; k = k->next_link()) { if (k == klass) return true; } return false; diff --git a/src/hotspot/share/classfile/classLoaderData.hpp b/src/hotspot/share/classfile/classLoaderData.hpp index 3a01c5acd33..4477ce4e789 100644 --- a/src/hotspot/share/classfile/classLoaderData.hpp +++ b/src/hotspot/share/classfile/classLoaderData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023, 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 @@ -84,7 +84,7 @@ class ClassLoaderData : public CHeapObj { void oops_do_chunk(OopClosure* f, Chunk* c, const juint size); public: - ChunkedHandleList() : _head(NULL) {} + ChunkedHandleList() : _head(nullptr) {} ~ChunkedHandleList(); // Only one thread at a time can add, guarded by ClassLoaderData::metaspace_lock(). @@ -143,7 +143,7 @@ class ClassLoaderData : public CHeapObj { ModuleEntry* _unnamed_module; // This class loader's unnamed module. Dictionary* _dictionary; // The loaded InstanceKlasses, including initiated by this class loader - // These method IDs are created for the class loader and set to NULL when the + // These method IDs are created for the class loader and set to null when the // class loader is unloaded. They are rarely freed, only for redefine classes // and if they lose a data race in InstanceKlass. JNIMethodBlock* _jmethod_ids; @@ -254,7 +254,7 @@ class ClassLoaderData : public CHeapObj { OopHandle class_loader_handle() const { return _class_loader; } - // The Metaspace is created lazily so may be NULL. This + // The Metaspace is created lazily so may be null. This // method will allocate a Metaspace if needed. ClassLoaderMetaspace* metaspace_non_null(); @@ -300,7 +300,7 @@ class ClassLoaderData : public CHeapObj { PackageEntryTable* packages() { return _packages; } ModuleEntry* unnamed_module() { return _unnamed_module; } ModuleEntryTable* modules(); - bool modules_defined() { return (_modules != NULL); } + bool modules_defined() { return (_modules != nullptr); } // Offsets static ByteSize holder_offset() { return in_ByteSize(offset_of(ClassLoaderData, _holder)); } @@ -314,7 +314,7 @@ class ClassLoaderData : public CHeapObj { static ClassLoaderData* class_loader_data(oop loader); static ClassLoaderData* class_loader_data_or_null(oop loader); - // Returns Klass* of associated class loader, or NULL if associated loader is 'bootstrap'. + // Returns Klass* of associated class loader, or null if associated loader is 'bootstrap'. // Also works if unloading. Klass* class_loader_klass() const { return _class_loader_klass; } @@ -322,7 +322,7 @@ class ClassLoaderData : public CHeapObj { // construction or the class loader's qualified class name. // Works during unloading. const char* loader_name() const; - // Returns the explicitly specified class loader name or NULL. + // Returns the explicitly specified class loader name or null. Symbol* name() const { return _name; } // Obtain the class loader's _name_and_id, works during unloading. diff --git a/src/hotspot/share/classfile/classLoaderData.inline.hpp b/src/hotspot/share/classfile/classLoaderData.inline.hpp index 3acd2327bf8..61dde041113 100644 --- a/src/hotspot/share/classfile/classLoaderData.inline.hpp +++ b/src/hotspot/share/classfile/classLoaderData.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023, 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 @@ -35,22 +35,22 @@ inline oop ClassLoaderData::class_loader() const { assert(!_unloading, "This oop is not available to unloading class loader data"); - assert(_holder.is_null() || holder_no_keepalive() != NULL , "This class loader data holder must be alive"); + assert(_holder.is_null() || holder_no_keepalive() != nullptr , "This class loader data holder must be alive"); return _class_loader.resolve(); } inline oop ClassLoaderData::class_loader_no_keepalive() const { assert(!_unloading, "This oop is not available to unloading class loader data"); - assert(_holder.is_null() || holder_no_keepalive() != NULL , "This class loader data holder must be alive"); + assert(_holder.is_null() || holder_no_keepalive() != nullptr , "This class loader data holder must be alive"); return _class_loader.peek(); } inline bool ClassLoaderData::is_boot_class_loader_data() const { - return this == _the_null_class_loader_data || class_loader() == NULL; + return this == _the_null_class_loader_data || class_loader() == nullptr; } inline ClassLoaderData* ClassLoaderData::class_loader_data_or_null(oop loader) { - if (loader == NULL) { + if (loader == nullptr) { return ClassLoaderData::the_null_class_loader_data(); } return java_lang_ClassLoader::loader_data_acquire(loader); @@ -58,7 +58,7 @@ inline ClassLoaderData* ClassLoaderData::class_loader_data_or_null(oop loader) { inline ClassLoaderData* ClassLoaderData::class_loader_data(oop loader) { ClassLoaderData* loader_data = class_loader_data_or_null(loader); - assert(loader_data != NULL, "Must be"); + assert(loader_data != nullptr, "Must be"); return loader_data; } diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.cpp b/src/hotspot/share/classfile/classLoaderDataGraph.cpp index 7ca44fa3188..7a1c499b9e3 100644 --- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp +++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, 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 @@ -61,20 +61,20 @@ void ClassLoaderDataGraph::clear_claimed_marks() { // // Any ClassLoaderData added after or during walking the list are prepended to // _head. Their claim mark need not be handled here. - for (ClassLoaderData* cld = Atomic::load_acquire(&_head); cld != NULL; cld = cld->next()) { + for (ClassLoaderData* cld = Atomic::load_acquire(&_head); cld != nullptr; cld = cld->next()) { cld->clear_claim(); } } void ClassLoaderDataGraph::clear_claimed_marks(int claim) { - for (ClassLoaderData* cld = Atomic::load_acquire(&_head); cld != NULL; cld = cld->next()) { + for (ClassLoaderData* cld = Atomic::load_acquire(&_head); cld != nullptr; cld = cld->next()) { cld->clear_claim(claim); } } void ClassLoaderDataGraph::verify_claimed_marks_cleared(int claim) { #ifdef ASSERT - for (ClassLoaderData* cld = Atomic::load_acquire(&_head); cld != NULL; cld = cld->next()) { + for (ClassLoaderData* cld = Atomic::load_acquire(&_head); cld != nullptr; cld = cld->next()) { cld->verify_not_claimed(claim); } #endif @@ -87,7 +87,7 @@ class ClassLoaderDataGraphKlassIteratorStatic { Klass* _current_class_entry; public: - ClassLoaderDataGraphKlassIteratorStatic() : _current_loader_data(NULL), _current_class_entry(NULL) {} + ClassLoaderDataGraphKlassIteratorStatic() : _current_loader_data(nullptr), _current_class_entry(nullptr) {} InstanceKlass* try_get_next_class() { assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint"); @@ -95,7 +95,7 @@ class ClassLoaderDataGraphKlassIteratorStatic { assert(max_classes > 0, "should not be called with no instance classes"); for (size_t i = 0; i < max_classes; ) { - if (_current_class_entry != NULL) { + if (_current_class_entry != nullptr) { Klass* k = _current_class_entry; _current_class_entry = _current_class_entry->next_link(); @@ -110,11 +110,11 @@ class ClassLoaderDataGraphKlassIteratorStatic { } } else { // Go to next CLD - if (_current_loader_data != NULL) { + if (_current_loader_data != nullptr) { _current_loader_data = _current_loader_data->next(); } // Start at the beginning - if (_current_loader_data == NULL) { + if (_current_loader_data == nullptr) { _current_loader_data = ClassLoaderDataGraph::_head; } @@ -122,8 +122,8 @@ class ClassLoaderDataGraphKlassIteratorStatic { } } // Should never be reached unless all instance classes have failed or are not fully loaded. - // Caller handles NULL. - return NULL; + // Caller handles null. + return nullptr; } // If the current class for the static iterator is a class being unloaded or @@ -131,7 +131,7 @@ class ClassLoaderDataGraphKlassIteratorStatic { void adjust_saved_class(ClassLoaderData* cld) { if (_current_loader_data == cld) { _current_loader_data = cld->next(); - if (_current_loader_data != NULL) { + if (_current_loader_data != nullptr) { _current_class_entry = _current_loader_data->klasses(); } // else try_get_next_class will start at the head } @@ -162,7 +162,7 @@ void ClassLoaderDataGraph::adjust_saved_class(Klass* klass) { void ClassLoaderDataGraph::clean_deallocate_lists(bool walk_previous_versions) { assert(SafepointSynchronize::is_at_safepoint(), "must only be called at safepoint"); uint loaders_processed = 0; - for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { + for (ClassLoaderData* cld = _head; cld != nullptr; cld = cld->next()) { // is_alive check will be necessary for concurrent class unloading. if (cld->is_alive()) { // clean metaspace @@ -202,8 +202,8 @@ void ClassLoaderDataGraph::walk_metadata_and_clean_metaspaces() { } // GC root of class loader data created. -ClassLoaderData* volatile ClassLoaderDataGraph::_head = NULL; -ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL; +ClassLoaderData* volatile ClassLoaderDataGraph::_head = nullptr; +ClassLoaderData* ClassLoaderDataGraph::_unloading = nullptr; bool ClassLoaderDataGraph::_should_clean_deallocate_lists = false; bool ClassLoaderDataGraph::_safepoint_cleanup_needed = false; @@ -221,7 +221,7 @@ ClassLoaderData* ClassLoaderDataGraph::add_to_graph(Handle loader, bool has_clas // it into the loader while we were waiting for the lock. if (!has_class_mirror_holder && loader.not_null()) { cld = java_lang_ClassLoader::loader_data_acquire(loader()); - if (cld != NULL) { + if (cld != nullptr) { return cld; } } @@ -264,7 +264,7 @@ ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool has_class_mirror_ void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) { assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); - for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) { + for (ClassLoaderData* cld = _unloading; cld != nullptr; cld = cld->next()) { assert(cld->is_unloading(), "invariant"); cl->do_cld(cld); } @@ -274,16 +274,16 @@ void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) { // unloading ones. void ClassLoaderDataGraph::cld_do(CLDClosure* cl) { assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); - for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->_next) { + for (ClassLoaderData* cld = _head; cld != nullptr; cld = cld->_next) { cl->do_cld(cld); } } void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) { assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); - for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->_next) { + for (ClassLoaderData* cld = _head; cld != nullptr; cld = cld->_next) { CLDClosure* closure = cld->keep_alive() ? strong : weak; - if (closure != NULL) { + if (closure != nullptr) { closure->do_cld(cld); } } @@ -292,7 +292,7 @@ void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) { void ClassLoaderDataGraph::always_strong_cld_do(CLDClosure* cl) { assert_locked_or_safepoint_weak(ClassLoaderDataGraph_lock); if (ClassUnloading) { - roots_cld_do(cl, NULL); + roots_cld_do(cl, nullptr); } else { cld_do(cl); } @@ -306,7 +306,7 @@ LockedClassesDo::LockedClassesDo(classes_do_func_t f) : _function(f), } } -LockedClassesDo::LockedClassesDo() : _function(NULL), +LockedClassesDo::LockedClassesDo() : _function(nullptr), _do_lock(!SafepointSynchronize::is_at_safepoint()) { // callers provide their own do_klass if (_do_lock) { @@ -343,17 +343,17 @@ public: ClassLoaderData* get_next() { ClassLoaderData* cld = _next; // Skip already unloaded CLD for concurrent unloading. - while (cld != NULL && !cld->is_alive()) { + while (cld != nullptr && !cld->is_alive()) { cld = cld->next(); } - if (cld != NULL) { + if (cld != nullptr) { if (keep_alive) { // Keep cld that is being returned alive. Handle(_thread, cld->holder()); } _next = cld->next(); } else { - _next = NULL; + _next = nullptr; } return cld; } @@ -424,7 +424,7 @@ void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) { void ClassLoaderDataGraph::classes_unloading_do(void f(Klass* const)) { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); - for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) { + for (ClassLoaderData* cld = _unloading; cld != nullptr; cld = cld->next()) { assert(cld->is_unloading(), "invariant"); cld->classes_do(f); } @@ -441,7 +441,7 @@ void ClassLoaderDataGraph::verify_dictionary() { #define FOR_ALL_DICTIONARY(X) ClassLoaderDataGraphIterator iter; \ while (ClassLoaderData* X = iter.get_next()) \ - if (X->dictionary() != NULL) + if (X->dictionary() != nullptr) void ClassLoaderDataGraph::print_dictionary(outputStream* st) { FOR_ALL_DICTIONARY(cld) { @@ -465,7 +465,7 @@ void ClassLoaderDataGraph::print_table_statistics(outputStream* st) { #ifndef PRODUCT bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); - for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { + for (ClassLoaderData* data = _head; data != nullptr; data = data->next()) { if (loader_data == data) { return true; } @@ -477,11 +477,11 @@ bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { bool ClassLoaderDataGraph::is_valid(ClassLoaderData* loader_data) { DEBUG_ONLY( if (!VMError::is_error_reported()) { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); } ) - if (loader_data != NULL) { + if (loader_data != nullptr) { if (loader_data == ClassLoaderData::the_null_class_loader_data()) { return true; } - for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { + for (ClassLoaderData* data = _head; data != nullptr; data = data->next()) { if (loader_data == data) { return true; } @@ -496,13 +496,13 @@ bool ClassLoaderDataGraph::do_unloading() { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); ClassLoaderData* data = _head; - ClassLoaderData* prev = NULL; + ClassLoaderData* prev = nullptr; bool seen_dead_loader = false; uint loaders_processed = 0; uint loaders_removed = 0; data = _head; - while (data != NULL) { + while (data != nullptr) { if (data->is_alive()) { prev = data; data = data->next(); @@ -517,7 +517,7 @@ bool ClassLoaderDataGraph::do_unloading() { // Remove from loader list. // This class loader data will no longer be found // in the ClassLoaderDataGraph. - if (prev != NULL) { + if (prev != nullptr) { prev->set_next(data); } else { assert(dead == _head, "sanity check"); @@ -538,14 +538,14 @@ void ClassLoaderDataGraph::clean_module_and_package_info() { assert_locked_or_safepoint(ClassLoaderDataGraph_lock); ClassLoaderData* data = _head; - while (data != NULL) { + while (data != nullptr) { // Walk a ModuleEntry's reads, and a PackageEntry's exports // lists to determine if there are modules on those lists that are now // dead and should be removed. A module's life cycle is equivalent // to its defining class loader's life cycle. Since a module is // considered dead if its class loader is dead, these walks must // occur after each class loader's aliveness is determined. - if (data->packages() != NULL) { + if (data->packages() != nullptr) { data->packages()->purge_all_package_exports(); } if (data->modules_defined()) { @@ -557,10 +557,10 @@ void ClassLoaderDataGraph::clean_module_and_package_info() { void ClassLoaderDataGraph::purge(bool at_safepoint) { ClassLoaderData* list = _unloading; - _unloading = NULL; + _unloading = nullptr; ClassLoaderData* next = list; bool classes_unloaded = false; - while (next != NULL) { + while (next != nullptr) { ClassLoaderData* purge_me = next; next = purge_me->next(); delete purge_me; @@ -591,16 +591,16 @@ void ClassLoaderDataGraph::purge(bool at_safepoint) { } ClassLoaderDataGraphKlassIteratorAtomic::ClassLoaderDataGraphKlassIteratorAtomic() - : _next_klass(NULL) { + : _next_klass(nullptr) { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); ClassLoaderData* cld = ClassLoaderDataGraph::_head; - Klass* klass = NULL; + Klass* klass = nullptr; // Find the first klass in the CLDG. - while (cld != NULL) { + while (cld != nullptr) { assert_locked_or_safepoint(cld->metaspace_lock()); klass = cld->_klasses; - if (klass != NULL) { + if (klass != nullptr) { _next_klass = klass; return; } @@ -610,16 +610,16 @@ ClassLoaderDataGraphKlassIteratorAtomic::ClassLoaderDataGraphKlassIteratorAtomic Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass_in_cldg(Klass* klass) { Klass* next = klass->next_link(); - if (next != NULL) { + if (next != nullptr) { return next; } // No more klasses in the current CLD. Time to find a new CLD. ClassLoaderData* cld = klass->class_loader_data(); assert_locked_or_safepoint(cld->metaspace_lock()); - while (next == NULL) { + while (next == nullptr) { cld = cld->next(); - if (cld == NULL) { + if (cld == nullptr) { break; } next = cld->_klasses; @@ -631,7 +631,7 @@ Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass_in_cldg(Klass* klass) Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() { Klass* head = _next_klass; - while (head != NULL) { + while (head != nullptr) { Klass* next = next_klass_in_cldg(head); Klass* old_head = Atomic::cmpxchg(&_next_klass, head, next); @@ -644,8 +644,8 @@ Klass* ClassLoaderDataGraphKlassIteratorAtomic::next_klass() { } // Nothing more for the iterator to hand out. - assert(head == NULL, "head is " PTR_FORMAT ", expected not null:", p2i(head)); - return NULL; + assert(head == nullptr, "head is " PTR_FORMAT ", expected not null:", p2i(head)); + return nullptr; } void ClassLoaderDataGraph::verify() { diff --git a/src/hotspot/share/classfile/classLoaderDataGraph.inline.hpp b/src/hotspot/share/classfile/classLoaderDataGraph.inline.hpp index e5b51ac277c..4d290c0dfdd 100644 --- a/src/hotspot/share/classfile/classLoaderDataGraph.inline.hpp +++ b/src/hotspot/share/classfile/classLoaderDataGraph.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, 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 @@ -33,7 +33,7 @@ #include "runtime/orderAccess.hpp" inline ClassLoaderData *ClassLoaderDataGraph::find_or_create(Handle loader) { - guarantee(loader() != NULL && oopDesc::is_oop(loader()), "Loader must be oop"); + guarantee(loader() != nullptr && oopDesc::is_oop(loader()), "Loader must be oop"); // Gets the class loader data out of the java/lang/ClassLoader object, if non-null // it's already in the loader_data, so no need to add ClassLoaderData* loader_data = java_lang_ClassLoader::loader_data_acquire(loader()); diff --git a/src/hotspot/share/classfile/classLoaderDataShared.cpp b/src/hotspot/share/classfile/classLoaderDataShared.cpp index 92532427446..9d7a5049859 100644 --- a/src/hotspot/share/classfile/classLoaderDataShared.cpp +++ b/src/hotspot/share/classfile/classLoaderDataShared.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, 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 @@ -41,15 +41,15 @@ class ArchivedClassLoaderData { Array* _modules; void assert_valid(ClassLoaderData* loader_data) { - // loader_data may be NULL if the boot layer has loaded no modules for the platform or + // loader_data may be null if the boot layer has loaded no modules for the platform or // system loaders (e.g., if you create a custom JDK image with only java.base). - if (loader_data != NULL) { + if (loader_data != nullptr) { assert(!loader_data->has_class_mirror_holder(), "loaders for non-strong hidden classes not supported"); } } public: - ArchivedClassLoaderData() : _packages(NULL), _modules(NULL) {} + ArchivedClassLoaderData() : _packages(nullptr), _modules(nullptr) {} void iterate_symbols(ClassLoaderData* loader_data, MetaspaceClosure* closure); void allocate(ClassLoaderData* loader_data); @@ -67,12 +67,12 @@ public: static ArchivedClassLoaderData _archived_boot_loader_data; static ArchivedClassLoaderData _archived_platform_loader_data; static ArchivedClassLoaderData _archived_system_loader_data; -static ModuleEntry* _archived_javabase_moduleEntry = NULL; +static ModuleEntry* _archived_javabase_moduleEntry = nullptr; void ArchivedClassLoaderData::iterate_symbols(ClassLoaderData* loader_data, MetaspaceClosure* closure) { assert(DumpSharedSpaces, "must be"); assert_valid(loader_data); - if (loader_data != NULL) { + if (loader_data != nullptr) { loader_data->packages()->iterate_symbols(closure); loader_data->modules() ->iterate_symbols(closure); } @@ -81,7 +81,7 @@ void ArchivedClassLoaderData::iterate_symbols(ClassLoaderData* loader_data, Meta void ArchivedClassLoaderData::allocate(ClassLoaderData* loader_data) { assert(DumpSharedSpaces, "must be"); assert_valid(loader_data); - if (loader_data != NULL) { + if (loader_data != nullptr) { // We can't create hashtables at dump time because the hashcode depends on the // address of the Symbols, which may be relocated at runtime due to ASLR. // So we store the packages/modules in Arrays. At runtime, we create @@ -94,7 +94,7 @@ void ArchivedClassLoaderData::allocate(ClassLoaderData* loader_data) { void ArchivedClassLoaderData::init_archived_entries(ClassLoaderData* loader_data) { assert(DumpSharedSpaces, "must be"); assert_valid(loader_data); - if (loader_data != NULL) { + if (loader_data != nullptr) { loader_data->packages()->init_archived_entries(_packages); loader_data->modules() ->init_archived_entries(_modules); } @@ -103,7 +103,7 @@ void ArchivedClassLoaderData::init_archived_entries(ClassLoaderData* loader_data void ArchivedClassLoaderData::restore(ClassLoaderData* loader_data, bool do_entries, bool do_oops) { assert(UseSharedSpaces, "must be"); assert_valid(loader_data); - if (_modules != NULL) { // Could be NULL if we have archived no modules for platform/system loaders + if (_modules != nullptr) { // Could be null if we have archived no modules for platform/system loaders ModuleEntryTable* modules = loader_data->modules(); PackageEntryTable* packages = loader_data->packages(); @@ -120,7 +120,7 @@ void ArchivedClassLoaderData::restore(ClassLoaderData* loader_data, bool do_entr void ArchivedClassLoaderData::clear_archived_oops() { assert(UseSharedSpaces, "must be"); - if (_modules != NULL) { + if (_modules != nullptr) { for (int i = 0; i < _modules->length(); i++) { _modules->at(i)->clear_archived_oops(); } @@ -131,7 +131,7 @@ void ArchivedClassLoaderData::clear_archived_oops() { static ClassLoaderData* null_class_loader_data() { ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); - assert(loader_data != NULL, "must be"); + assert(loader_data != nullptr, "must be"); return loader_data; } diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index ec5749db8cb..23c017b7d01 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, 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 @@ -130,9 +130,9 @@ char* ClassLoaderExt::read_manifest(JavaThread* current, ClassPathEntry* entry, assert(entry->is_jar_file(), "must be"); manifest = (char*) ((ClassPathZipEntry*)entry )->open_entry(current, name, &size, true); - if (manifest == NULL) { // No Manifest + if (manifest == nullptr) { // No Manifest *manifest_size = 0; - return NULL; + return nullptr; } @@ -152,7 +152,7 @@ char* ClassLoaderExt::read_manifest(JavaThread* current, ClassPathEntry* entry, char* ClassLoaderExt::get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size) { const char* tag = "Class-Path: "; const int tag_len = (int)strlen(tag); - char* found = NULL; + char* found = nullptr; char* line_start = manifest; char* end = manifest + manifest_size; @@ -160,12 +160,12 @@ char* ClassLoaderExt::get_class_path_attr(const char* jar_path, char* manifest, while (line_start < end) { char* line_end = strchr(line_start, '\n'); - if (line_end == NULL) { + if (line_end == nullptr) { // JAR spec require the manifest file to be terminated by a new line. break; } if (strncmp(tag, line_start, tag_len) == 0) { - if (found != NULL) { + if (found != nullptr) { // Same behavior as jdk/src/share/classes/java/util/jar/Attributes.java // If duplicated entries are found, the last one is used. log_warning(cds)("Warning: Duplicate name in Manifest: %s.\n" @@ -187,24 +187,24 @@ void ClassLoaderExt::process_jar_manifest(JavaThread* current, ClassPathEntry* e jint manifest_size; char* manifest = read_manifest(current, entry, &manifest_size); - if (manifest == NULL) { + if (manifest == nullptr) { return; } - if (strstr(manifest, "Extension-List:") != NULL) { + if (strstr(manifest, "Extension-List:") != nullptr) { vm_exit_during_cds_dumping(err_msg("-Xshare:dump does not support Extension-List in JAR manifest: %s", entry->name())); } char* cp_attr = get_class_path_attr(entry->name(), manifest, manifest_size); - if (cp_attr != NULL && strlen(cp_attr) > 0) { + if (cp_attr != nullptr && strlen(cp_attr) > 0) { trace_class_path("found Class-Path: ", cp_attr); char sep = os::file_separator()[0]; const char* dir_name = entry->name(); const char* dir_tail = strrchr(dir_name, sep); int dir_len; - if (dir_tail == NULL) { + if (dir_tail == nullptr) { dir_len = 0; } else { dir_len = dir_tail - dir_name + 1; @@ -216,7 +216,7 @@ void ClassLoaderExt::process_jar_manifest(JavaThread* current, ClassPathEntry* e while (file_start < end) { char* file_end = strchr(file_start, ' '); - if (file_end != NULL) { + if (file_end != nullptr) { *file_end = 0; file_end += 1; } else { diff --git a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp index 248201772dc..6778f6b862d 100644 --- a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp +++ b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -48,8 +48,8 @@ ClassLoaderHierarchyDCmd::ClassLoaderHierarchyDCmd(outputStream* output, bool he int ClassLoaderHierarchyDCmd::num_arguments() { ResourceMark rm; - ClassLoaderHierarchyDCmd* dcmd = new ClassLoaderHierarchyDCmd(NULL, false); - if (dcmd != NULL) { + ClassLoaderHierarchyDCmd* dcmd = new ClassLoaderHierarchyDCmd(nullptr, false); + if (dcmd != nullptr) { DCmdMark mark(dcmd); return dcmd->_dcmdparser.num_arguments(); } else { @@ -122,7 +122,7 @@ public: const ClassLoaderData* const _cld; LoadedClassInfo(Klass* klass, const ClassLoaderData* cld) - : _next(NULL), _klass(klass), _cld(cld) {} + : _next(nullptr), _klass(klass), _cld(cld) {} }; @@ -137,7 +137,7 @@ class LoaderTreeNode : public ResourceObj { // this parent loader, we fill in all the other details. const oop _loader_oop; - const ClassLoaderData* _cld; // May be NULL if loader never loaded anything + const ClassLoaderData* _cld; // May be null if loader never loaded anything LoaderTreeNode* _child; LoaderTreeNode* _next; @@ -154,31 +154,31 @@ class LoaderTreeNode : public ResourceObj { // one. int _num_folded; - // Returns Klass of loader; NULL for bootstrap loader + // Returns Klass of loader; null for bootstrap loader const Klass* loader_klass() const { - return (_loader_oop != NULL) ? _loader_oop->klass() : NULL; + return (_loader_oop != nullptr) ? _loader_oop->klass() : nullptr; } // Returns ResourceArea-allocated class name of loader class; "" if there is no klass (bootstrap loader) const char* loader_class_name() const { const Klass* klass = loader_klass(); - return klass != NULL ? klass->external_name() : ""; + return klass != nullptr ? klass->external_name() : ""; } - // Returns oop of loader name; NULL for bootstrap; NULL if no name was set + // Returns oop of loader name; null for bootstrap; null if no name was set oop loader_name_oop() const { - return (_loader_oop != NULL) ? java_lang_ClassLoader::name(_loader_oop) : NULL; + return (_loader_oop != nullptr) ? java_lang_ClassLoader::name(_loader_oop) : nullptr; } // Returns ResourceArea-allocated name of loader, "" if none is set const char* loader_name() const { oop name_oop = loader_name_oop(); - return name_oop != NULL ? java_lang_String::as_utf8_string(name_oop) : ""; + return name_oop != nullptr ? java_lang_String::as_utf8_string(name_oop) : ""; } bool is_bootstrap() const { - if (_loader_oop == NULL) { - assert(_cld != NULL && _cld->is_boot_class_loader_data(), "bootstrap loader must have CLD"); + if (_loader_oop == nullptr) { + assert(_cld != nullptr && _cld->is_boot_class_loader_data(), "bootstrap loader must have CLD"); return true; } return false; @@ -215,13 +215,13 @@ class LoaderTreeNode : public ResourceObj { // Output following this node (node details and child nodes) - up to the next sibling node // needs to be prefixed with "|" if there is a follow up sibling. - const bool have_sibling = _next != NULL; + const bool have_sibling = _next != nullptr; BranchTracker::Mark trm(branchtracker, have_sibling); { // optional node details following this node needs to be prefixed with "|" // if there are follow up child nodes. - const bool have_child = _child != NULL; + const bool have_child = _child != nullptr; BranchTracker::Mark trm(branchtracker, have_child); // Empty line @@ -244,8 +244,8 @@ class LoaderTreeNode : public ResourceObj { } if (print_classes) { - if (_classes != NULL) { - assert(_cld != NULL, "we have classes, we should have a CLD"); + if (_classes != nullptr) { + assert(_cld != nullptr, "we have classes, we should have a CLD"); for (LoadedClassInfo* lci = _classes; lci; lci = lci->_next) { // non-strong hidden classes should not live in // the primary CLD of their loaders. @@ -269,8 +269,8 @@ class LoaderTreeNode : public ResourceObj { st->cr(); } - if (_hidden_classes != NULL) { - assert(_cld != NULL, "we have classes, we should have a CLD"); + if (_hidden_classes != nullptr) { + assert(_cld != nullptr, "we have classes, we should have a CLD"); for (LoadedClassInfo* lci = _hidden_classes; lci; lci = lci->_next) { branchtracker.print(st); if (lci == _hidden_classes) { // first iteration @@ -303,7 +303,7 @@ class LoaderTreeNode : public ResourceObj { // Print children, recursively LoaderTreeNode* c = _child; - while (c != NULL) { + while (c != nullptr) { c->print_with_child_nodes(st, branchtracker, print_classes, verbose); c = c->_next; } @@ -318,7 +318,7 @@ class LoaderTreeNode : public ResourceObj { // Must have the same non-null klass const Klass* k = loader_klass(); - if (k == NULL || k != target_node->loader_klass()) { + if (k == nullptr || k != target_node->loader_klass()) { return false; } @@ -333,13 +333,13 @@ class LoaderTreeNode : public ResourceObj { public: LoaderTreeNode(const oop loader_oop) - : _loader_oop(loader_oop), _cld(NULL), _child(NULL), _next(NULL), - _classes(NULL), _num_classes(0), _hidden_classes(NULL), + : _loader_oop(loader_oop), _cld(nullptr), _child(nullptr), _next(nullptr), + _classes(nullptr), _num_classes(0), _hidden_classes(nullptr), _num_hidden_classes(0), _num_folded(0) {} void set_cld(const ClassLoaderData* cld) { - assert(_cld == NULL, "there should be only one primary CLD per loader"); + assert(_cld == nullptr, "there should be only one primary CLD per loader"); _cld = cld; } @@ -349,7 +349,7 @@ public: } void add_sibling(LoaderTreeNode* info) { - assert(info->_next == NULL, "must be"); + assert(info->_next == nullptr, "must be"); info->_next = _next; _next = info; } @@ -363,7 +363,7 @@ public: p_list_to_add_to = &_classes; } // Search tail. - while ((*p_list_to_add_to) != NULL) { + while ((*p_list_to_add_to) != nullptr) { p_list_to_add_to = &(*p_list_to_add_to)->_next; } *p_list_to_add_to = first_class; @@ -375,12 +375,12 @@ public: } LoaderTreeNode* find(const oop loader_oop) { - LoaderTreeNode* result = NULL; + LoaderTreeNode* result = nullptr; if (_loader_oop == loader_oop) { result = this; } else { LoaderTreeNode* c = _child; - while (c != NULL && result == NULL) { + while (c != nullptr && result == nullptr) { result = c->find(loader_oop); c = c->_next; } @@ -388,20 +388,20 @@ public: return result; } - bool is_leaf() const { return _child == NULL; } + bool is_leaf() const { return _child == nullptr; } // Attempt to fold similar nodes among this node's children. We only fold leaf nodes // (no child class loaders). // For non-leaf nodes (class loaders with child class loaders), do this recursively. void fold_children() { LoaderTreeNode* node = _child; - LoaderTreeNode* prev = NULL; + LoaderTreeNode* prev = nullptr; ResourceMark rm; - while (node != NULL) { - LoaderTreeNode* matching_node = NULL; + while (node != nullptr) { + LoaderTreeNode* matching_node = nullptr; if (node->is_leaf()) { // Look among the preceding node siblings for a match. - for (LoaderTreeNode* node2 = _child; node2 != node && matching_node == NULL; + for (LoaderTreeNode* node2 = _child; node2 != node && matching_node == nullptr; node2 = node2->_next) { if (node2->is_leaf() && node->can_fold_into(node2)) { matching_node = node2; @@ -410,10 +410,10 @@ public: } else { node->fold_children(); } - if (matching_node != NULL) { + if (matching_node != nullptr) { // Increase fold count for the matching node and remove folded node from the child list. matching_node->_num_folded ++; - assert(prev != NULL, "Sanity"); // can never happen since we do not fold the first node. + assert(prev != nullptr, "Sanity"); // can never happen since we do not fold the first node. prev->_next = node->_next; } else { prev = node; @@ -435,7 +435,7 @@ public: const ClassLoaderData* _cld; int _num_classes; LoadedClassCollectClosure(const ClassLoaderData* cld) - : _list(NULL), _cld(cld), _num_classes(0) {} + : _list(nullptr), _cld(cld), _num_classes(0) {} void do_klass(Klass* k) { LoadedClassInfo* lki = new LoadedClassInfo(k, _cld); lki->_next = _list; @@ -451,7 +451,7 @@ class LoaderInfoScanClosure : public CLDClosure { LoaderTreeNode* _root; static void fill_in_classes(LoaderTreeNode* info, const ClassLoaderData* cld) { - assert(info != NULL && cld != NULL, "must be"); + assert(info != nullptr && cld != nullptr, "must be"); LoadedClassCollectClosure lccc(cld); const_cast(cld)->classes_do(&lccc); if (lccc._num_classes > 0) { @@ -461,30 +461,30 @@ class LoaderInfoScanClosure : public CLDClosure { LoaderTreeNode* find_node_or_add_empty_node(oop loader_oop) { - assert(_root != NULL, "root node must exist"); + assert(_root != nullptr, "root node must exist"); - if (loader_oop == NULL) { + if (loader_oop == nullptr) { return _root; } // Check if a node for this oop already exists. LoaderTreeNode* info = _root->find(loader_oop); - if (info == NULL) { + if (info == nullptr) { // It does not. Create a node. info = new LoaderTreeNode(loader_oop); // Add it to tree. - LoaderTreeNode* parent_info = NULL; + LoaderTreeNode* parent_info = nullptr; // Recursively add parent nodes if needed. const oop parent_oop = java_lang_ClassLoader::parent(loader_oop); - if (parent_oop == NULL) { + if (parent_oop == nullptr) { parent_info = _root; } else { parent_info = find_node_or_add_empty_node(parent_oop); } - assert(parent_info != NULL, "must be"); + assert(parent_info != nullptr, "must be"); parent_info->add_child(info); } @@ -494,8 +494,8 @@ class LoaderInfoScanClosure : public CLDClosure { public: LoaderInfoScanClosure(bool print_classes, bool verbose) - : _print_classes(print_classes), _verbose(verbose), _root(NULL) { - _root = new LoaderTreeNode(NULL); + : _print_classes(print_classes), _verbose(verbose), _root(nullptr) { + _root = new LoaderTreeNode(nullptr); } void print_results(outputStream* st) const { @@ -512,7 +512,7 @@ public: const oop loader_oop = cld->class_loader(); LoaderTreeNode* info = find_node_or_add_empty_node(loader_oop); - assert(info != NULL, "must be"); + assert(info != nullptr, "must be"); // Update CLD in node, but only if this is the primary CLD for this loader. if (cld->has_class_mirror_holder() == false) { diff --git a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.hpp b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.hpp index 10b486b6a17..1d4fe861335 100644 --- a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.hpp +++ b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -48,7 +48,7 @@ public: } static const JavaPermission permission() { JavaPermission p = {"java.lang.management.ManagementPermission", - "monitor", NULL}; + "monitor", nullptr}; return p; } static int num_arguments(); diff --git a/src/hotspot/share/classfile/classLoaderStats.cpp b/src/hotspot/share/classfile/classLoaderStats.cpp index 690ca9b5702..621d0a67dc2 100644 --- a/src/hotspot/share/classfile/classLoaderStats.cpp +++ b/src/hotspot/share/classfile/classLoaderStats.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, 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 @@ -65,7 +65,7 @@ void ClassLoaderStatsClosure::do_cld(ClassLoaderData* cld) { cls->_cld = cld; } - if (cl != NULL) { + if (cl != nullptr) { cls->_parent = java_lang_ClassLoader::parent_no_keepalive(cl); addEmptyParents(cls->_parent); } @@ -83,7 +83,7 @@ void ClassLoaderStatsClosure::do_cld(ClassLoaderData* cld) { _total_classes += csc._num_classes; ClassLoaderMetaspace* ms = cld->metaspace_or_null(); - if (ms != NULL) { + if (ms != nullptr) { size_t used_bytes, capacity_bytes; ms->calculate_jfr_stats(&used_bytes, &capacity_bytes); if(cld->has_class_mirror_holder()) { @@ -108,14 +108,14 @@ void ClassLoaderStatsClosure::do_cld(ClassLoaderData* cld) { bool ClassLoaderStatsClosure::do_entry(oop const& key, ClassLoaderStats const& cls) { - Klass* class_loader_klass = (cls._class_loader == NULL ? NULL : cls._class_loader->klass()); - Klass* parent_klass = (cls._parent == NULL ? NULL : cls._parent->klass()); + Klass* class_loader_klass = (cls._class_loader == nullptr ? nullptr : cls._class_loader->klass()); + Klass* parent_klass = (cls._parent == nullptr ? nullptr : cls._parent->klass()); _out->print(INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " UINTX_FORMAT_W(6) " " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(8) " ", p2i(class_loader_klass), p2i(parent_klass), p2i(cls._cld), cls._classes_count, cls._chunk_sz, cls._block_sz); - if (class_loader_klass != NULL) { + if (class_loader_klass != nullptr) { _out->print("%s", class_loader_klass->external_name()); } else { _out->print(""); @@ -146,7 +146,7 @@ void ClassLoaderStatsClosure::print() { void ClassLoaderStatsClosure::addEmptyParents(oop cl) { - while (cl != NULL && java_lang_ClassLoader::loader_data_acquire(cl) == NULL) { + while (cl != nullptr && java_lang_ClassLoader::loader_data_acquire(cl) == nullptr) { // This classloader has not loaded any classes bool added = false; ClassLoaderStats* cls = _stats->put_if_absent(cl, &added); diff --git a/src/hotspot/share/classfile/classLoaderStats.hpp b/src/hotspot/share/classfile/classLoaderStats.hpp index ce690945b47..a121e653906 100644 --- a/src/hotspot/share/classfile/classLoaderStats.hpp +++ b/src/hotspot/share/classfile/classLoaderStats.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, 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 @@ -61,7 +61,7 @@ public: static const JavaPermission permission() { JavaPermission p = {"java.lang.management.ManagementPermission", - "monitor", NULL}; + "monitor", nullptr}; return p; } }; diff --git a/src/hotspot/share/classfile/classPrinter.cpp b/src/hotspot/share/classfile/classPrinter.cpp index 417b1fd836a..45a1eff4aed 100644 --- a/src/hotspot/share/classfile/classPrinter.cpp +++ b/src/hotspot/share/classfile/classPrinter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, 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 @@ -77,7 +77,7 @@ public: } static bool match(const char* pattern, Symbol* sym) { - return (pattern == NULL || sym->is_star_match(pattern)); + return (pattern == nullptr || sym->is_star_match(pattern)); } void print_klass_name(InstanceKlass* ik) { @@ -147,7 +147,7 @@ void ClassPrinter::print_flags_help(outputStream* os) { } void ClassPrinter::print_classes(const char* class_name_pattern, int flags, outputStream* os) { - KlassPrintClosure closure(class_name_pattern, NULL, NULL, true, flags, os); + KlassPrintClosure closure(class_name_pattern, nullptr, nullptr, true, flags, os); ClassLoaderDataGraph::classes_do(&closure); } @@ -158,9 +158,9 @@ void ClassPrinter::print_methods(const char* class_name_pattern, const char* method_signature_pattern; const char* colon = strchr(method_pattern, ':'); - if (colon == NULL) { + if (colon == nullptr) { method_name_pattern = method_pattern; - method_signature_pattern = NULL; + method_signature_pattern = nullptr; } else { ptrdiff_t name_pat_len = colon - method_pattern; assert(name_pat_len >= 0, "sanity"); diff --git a/src/hotspot/share/classfile/compactHashtable.cpp b/src/hotspot/share/classfile/compactHashtable.cpp index ffe92181a03..f20741a78f7 100644 --- a/src/hotspot/share/classfile/compactHashtable.cpp +++ b/src/hotspot/share/classfile/compactHashtable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -56,8 +56,8 @@ CompactHashtableWriter::CompactHashtableWriter(int num_entries, } _stats = stats; - _compact_buckets = NULL; - _compact_entries = NULL; + _compact_buckets = nullptr; + _compact_entries = nullptr; _num_empty_buckets = 0; _num_value_only_buckets = 0; _num_other_buckets = 0; @@ -239,8 +239,8 @@ HashtableTextDump::HashtableTextDump(const char* filename) : _fd(-1) { if (_fd < 0) { quit("Unable to open hashtable dump file", filename); } - _base = os::map_memory(_fd, filename, 0, NULL, _size, true, false); - if (_base == NULL) { + _base = os::map_memory(_fd, filename, 0, nullptr, _size, true, false); + if (_base == nullptr) { quit("Unable to map hashtable dump file", filename); } _p = _base; diff --git a/src/hotspot/share/classfile/compactHashtable.hpp b/src/hotspot/share/classfile/compactHashtable.hpp index bcd6f52f68f..e4a31cde8e1 100644 --- a/src/hotspot/share/classfile/compactHashtable.hpp +++ b/src/hotspot/share/classfile/compactHashtable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -279,7 +279,7 @@ public: } } } - return NULL; + return nullptr; } template diff --git a/src/hotspot/share/classfile/defaultMethods.cpp b/src/hotspot/share/classfile/defaultMethods.cpp index ce145e08405..c04c095496e 100644 --- a/src/hotspot/share/classfile/defaultMethods.cpp +++ b/src/hotspot/share/classfile/defaultMethods.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023, 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 @@ -84,7 +84,7 @@ static void print_method(outputStream* str, Method* mo, bool with_class=true) { * * Bare minimum needed to be an ALGO class: * class Algo : public HierarchyVisitor { - * void* new_node_data() { return NULL; } + * void* new_node_data() { return nullptr; } * void free_node_data(void* data) { return; } * bool visit() { return true; } * }; @@ -138,7 +138,7 @@ class HierarchyVisitor : StackObj { Node* current_top() const { return _path.top(); } bool has_more_nodes() const { return _path.length() > 0; } void push(InstanceKlass* cls, ALGO* algo) { - assert(cls != NULL, "Requires a valid instance class"); + assert(cls != nullptr, "Requires a valid instance class"); if (cls == vmClasses::Object_klass()) { _visited_Object = true; } @@ -163,11 +163,11 @@ class HierarchyVisitor : StackObj { // only ensures we don't then repeatedly enqueue Object for each interface // in the class hierarchy. bool has_super(InstanceKlass* cls) { - return cls->super() != NULL && (!_visited_Object || !cls->is_interface()); + return cls->super() != nullptr && (!_visited_Object || !cls->is_interface()); } Node* node_at_depth(int i) const { - return (i >= _path.length()) ? NULL : _path.at(_path.length() - i - 1); + return (i >= _path.length()) ? nullptr : _path.at(_path.length() - i - 1); } protected: @@ -182,13 +182,13 @@ class HierarchyVisitor : StackObj { InstanceKlass* class_at_depth(int i) { Node* n = node_at_depth(i); - return n == NULL ? NULL : n->_class; + return n == nullptr ? nullptr : n->_class; } InstanceKlass* current_class() { return class_at_depth(0); } void* data_at_depth(int i) { Node* n = node_at_depth(i); - return n == NULL ? NULL : n->_algorithm_data; + return n == nullptr ? nullptr : n->_algorithm_data; } void* current_data() { return data_at_depth(0); } @@ -216,7 +216,7 @@ class HierarchyVisitor : StackObj { algo->free_node_data(top->_algorithm_data); pop(); } else { - InstanceKlass* next = NULL; + InstanceKlass* next = nullptr; if (top->has_visited_super() == false) { next = top->next_super(); top->set_super_visited(); @@ -224,7 +224,7 @@ class HierarchyVisitor : StackObj { next = top->next_interface(); top->increment_visited_interface(); } - assert(next != NULL, "Otherwise we shouldn't be here"); + assert(next != nullptr, "Otherwise we shouldn't be here"); push(next, algo); top_needs_visit = true; } @@ -243,7 +243,7 @@ class PrintHierarchy : public HierarchyVisitor { return true; } - void* new_node_data() { return NULL; } + void* new_node_data() { return nullptr; } void free_node_data(void* data) { return; } PrintHierarchy(outputStream* st = tty) : _st(st) {} @@ -291,7 +291,7 @@ class KeepAliveVisitor : public HierarchyVisitor { public: KeepAliveVisitor(KeepAliveRegistrar* registrar) : _registrar(registrar) {} - void* new_node_data() { return NULL; } + void* new_node_data() { return nullptr; } void free_node_data(void* data) { return; } bool visit() { @@ -313,7 +313,7 @@ class MethodState { Method* _method; QualifiedState _state; - MethodState() : _method(NULL), _state(DISQUALIFIED) {} + MethodState() : _method(nullptr), _state(DISQUALIFIED) {} MethodState(Method* method, QualifiedState state) : _method(method), _state(state) {} }; @@ -332,7 +332,7 @@ class MethodFamily : public ResourceObj { return &_members.at(i); } } - return NULL; + return nullptr; } void add_method(Method* method, QualifiedState state) { @@ -347,10 +347,10 @@ class MethodFamily : public ResourceObj { public: MethodFamily() - : _selected_target(NULL), _exception_message(NULL), _exception_name(NULL) {} + : _selected_target(nullptr), _exception_message(nullptr), _exception_name(nullptr) {} void set_target_if_empty(Method* m) { - if (_selected_target == NULL && !m->is_overpass()) { + if (_selected_target == nullptr && !m->is_overpass()) { _selected_target = m; } } @@ -360,15 +360,15 @@ class MethodFamily : public ResourceObj { // as is if state is qualified, or set it to disqualified if state is // disqualified. MethodState* method_state = find_method(m); - if (method_state == NULL) { + if (method_state == nullptr) { add_method(m, state); } else if (state == DISQUALIFIED) { method_state->_state = DISQUALIFIED; } } - bool has_target() const { return _selected_target != NULL; } - bool throws_exception() { return _exception_message != NULL; } + bool has_target() const { return _selected_target != nullptr; } + bool throws_exception() { return _exception_message != nullptr; } Method* get_selected_target() { return _selected_target; } Symbol* get_exception_message() { return _exception_message; } @@ -419,7 +419,7 @@ class MethodFamily : public ResourceObj { if (qualified_methods.length() == 0) { _exception_message = generate_no_defaults_message(); } else { - assert(root != NULL, "Null root class"); + assert(root != nullptr, "Null root class"); _exception_message = generate_method_message(root->name(), qualified_methods.at(0)); } _exception_name = vmSymbols::java_lang_AbstractMethodError(); @@ -449,7 +449,7 @@ class MethodFamily : public ResourceObj { void print_exception(outputStream* str, int indent) { assert(throws_exception(), "Should be called otherwise"); - assert(_exception_name != NULL, "exception_name should be set"); + assert(_exception_name != nullptr, "exception_name should be set"); streamIndentor si(str, indent * 2); str->indent().print_cr("%s: %s", _exception_name->as_C_string(), _exception_message->as_C_string()); } @@ -530,7 +530,7 @@ class StateRestorer : public ResourceObj { StatefulMethodFamily* _method; QualifiedState _state_to_restore; - StateRestorer() : _method(NULL), _state_to_restore(DISQUALIFIED) {} + StateRestorer() : _method(nullptr), _state_to_restore(DISQUALIFIED) {} void restore_state() { _method->set_qualification_state(_state_to_restore); } }; @@ -595,14 +595,14 @@ class EmptyVtableSlot : public ResourceObj { public: EmptyVtableSlot(Method* method) : _name(method->name()), _signature(method->signature()), - _size_of_parameters(method->size_of_parameters()), _binding(NULL) {} + _size_of_parameters(method->size_of_parameters()), _binding(nullptr) {} Symbol* name() const { return _name; } Symbol* signature() const { return _signature; } int size_of_parameters() const { return _size_of_parameters; } void bind_family(MethodFamily* lm) { _binding = lm; } - bool is_bound() { return _binding != NULL; } + bool is_bound() { return _binding != nullptr; } MethodFamily* get_binding() { return _binding; } void print_on(outputStream* str) const { @@ -625,7 +625,7 @@ static bool already_in_vtable_slots(GrowableArray* slots, Meth static void find_empty_vtable_slots(GrowableArray* slots, InstanceKlass* klass, const GrowableArray* mirandas) { - assert(klass != NULL, "Must be valid class"); + assert(klass != nullptr, "Must be valid class"); // All miranda methods are obvious candidates for (int i = 0; i < mirandas->length(); ++i) { @@ -638,7 +638,7 @@ static void find_empty_vtable_slots(GrowableArray* slots, // Also any overpasses in our superclasses, that we haven't implemented. // (can't use the vtable because it is not guaranteed to be initialized yet) InstanceKlass* super = klass->java_super(); - while (super != NULL) { + while (super != nullptr) { for (int i = 0; i < super->methods()->length(); ++i) { Method* m = super->methods()->at(i); if (m->is_overpass() || m->is_static()) { @@ -648,7 +648,7 @@ static void find_empty_vtable_slots(GrowableArray* slots, // unless we have a real implementation of it in the current class. if (!already_in_vtable_slots(slots, m)) { Method *impl = klass->lookup_method(m->name(), m->signature()); - if (impl == NULL || impl->is_overpass() || impl->is_static()) { + if (impl == nullptr || impl->is_overpass() || impl->is_static()) { slots->append(new EmptyVtableSlot(m)); } } @@ -656,7 +656,7 @@ static void find_empty_vtable_slots(GrowableArray* slots, } // also any default methods in our superclasses - if (super->default_methods() != NULL) { + if (super->default_methods() != nullptr) { for (int i = 0; i < super->default_methods()->length(); ++i) { Method* m = super->default_methods()->at(i); // m is a method that would have been a miranda if not for the @@ -665,7 +665,7 @@ static void find_empty_vtable_slots(GrowableArray* slots, // unless we have a real implementation of it in the current class. if (!already_in_vtable_slots(slots, m)) { Method* impl = klass->lookup_method(m->name(), m->signature()); - if (impl == NULL || impl->is_overpass() || impl->is_static()) { + if (impl == nullptr || impl->is_overpass() || impl->is_static()) { slots->append(new EmptyVtableSlot(m)); } } @@ -707,15 +707,15 @@ class FindMethodsByErasedSig : public HierarchyVisitor { reset(); _method_name = name; _method_signature = signature; - _family = NULL; + _family = nullptr; _cur_class_is_interface = is_interf; } void get_discovered_family(MethodFamily** family) { - if (_family != NULL) { + if (_family != nullptr) { *family = _family->get_method_family(); } else { - *family = NULL; + *family = nullptr; } } @@ -750,9 +750,9 @@ class FindMethodsByErasedSig : public HierarchyVisitor { // Non-public methods in java.lang.Object are not candidates for default // methods. // Future: take access controls into account for superclass methods - if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private() && + if (m != nullptr && !m->is_static() && !m->is_overpass() && !m->is_private() && (!_cur_class_is_interface || !SystemDictionary::is_nonpublic_Object_method(m))) { - if (_family == NULL) { + if (_family == nullptr) { _family = new StatefulMethodFamily(); } @@ -790,7 +790,7 @@ static void generate_erased_defaults( MethodFamily* family; visitor->get_discovered_family(&family); - if (family != NULL) { + if (family != nullptr) { family->determine_target_or_set_exception_message(klass); slot->bind_family(family); } @@ -815,7 +815,7 @@ static void create_default_methods( InstanceKlass* klass, // The JVM does not create bridges nor handle generic signatures here. void DefaultMethods::generate_default_methods( InstanceKlass* klass, const GrowableArray* mirandas, TRAPS) { - assert(klass != NULL, "invariant"); + assert(klass != nullptr, "invariant"); assert(klass != vmClasses::Object_klass(), "Shouldn't be called for Object"); // This resource mark is the bound for all memory allocation that takes @@ -891,7 +891,7 @@ static Method* new_method( int code_length = 0; InlineTableSizes sizes; - if (bytecodes != NULL && bytecodes->length() > 0) { + if (bytecodes != nullptr && bytecodes->length() > 0) { code_start = static_cast
(bytecodes->adr_at(0)); code_length = bytecodes->length(); } @@ -900,14 +900,14 @@ static Method* new_method( code_length, flags, &sizes, mt, name, CHECK_NULL); - m->set_constants(NULL); // This will get filled in later + m->set_constants(nullptr); // This will get filled in later m->set_name_index(cp->utf8(name)); m->set_signature_index(cp->utf8(sig)); m->compute_from_signature(sig); m->set_size_of_parameters(params); m->set_max_stack(max_stack); m->set_max_locals(params); - m->constMethod()->set_stackmap_data(NULL); + m->constMethod()->set_stackmap_data(nullptr); m->set_code(code_start); return m; @@ -956,7 +956,7 @@ static void create_defaults_and_exceptions(GrowableArray* slot GrowableArray defaults; BytecodeConstantPool bpool(klass->constants()); - BytecodeBuffer* buffer = NULL; // Lazily create a reusable buffer + BytecodeBuffer* buffer = nullptr; // Lazily create a reusable buffer for (int i = 0; i < slots->length(); ++i) { EmptyVtableSlot* slot = slots->at(i); @@ -984,7 +984,7 @@ static void create_defaults_and_exceptions(GrowableArray* slot defaults.push(selected); } } else if (method->throws_exception()) { - if (buffer == NULL) { + if (buffer == nullptr) { buffer = new BytecodeBuffer(); } else { buffer->clear(); @@ -998,7 +998,7 @@ static void create_defaults_and_exceptions(GrowableArray* slot ConstMethod::OVERPASS, CHECK); // We push to the methods list: // overpass methods which are exception throwing methods - if (m != NULL) { + if (m != nullptr) { overpasses.push(m); } } @@ -1023,7 +1023,7 @@ static void create_default_methods(InstanceKlass* klass, int new_size = new_methods->length(); Array* total_default_methods = MetadataFactory::new_array( - klass->class_loader_data(), new_size, NULL, CHECK); + klass->class_loader_data(), new_size, nullptr, CHECK); for (int index = 0; index < new_size; index++ ) { total_default_methods->at_put(index, new_methods->at(index)); } @@ -1076,7 +1076,7 @@ static void merge_in_new_methods(InstanceKlass* klass, int new_size = klass->methods()->length() + new_methods->length(); Array* merged_methods = MetadataFactory::new_array( - klass->class_loader_data(), new_size, NULL, CHECK); + klass->class_loader_data(), new_size, nullptr, CHECK); // original_ordering might be empty if this class has no methods of its own if (JvmtiExport::can_maintain_original_method_order() || Arguments::is_dumping_archive()) { @@ -1092,8 +1092,8 @@ static void merge_in_new_methods(InstanceKlass* klass, int new_idx = 0; for (int i = 0; i < new_size; ++i) { - Method* orig_method = NULL; - Method* new_method = NULL; + Method* orig_method = nullptr; + Method* new_method = nullptr; if (orig_idx < original_methods->length()) { orig_method = original_methods->at(orig_idx); } @@ -1101,12 +1101,12 @@ static void merge_in_new_methods(InstanceKlass* klass, new_method = new_methods->at(new_idx); } - if (orig_method != NULL && - (new_method == NULL || orig_method->name() < new_method->name())) { + if (orig_method != nullptr && + (new_method == nullptr || orig_method->name() < new_method->name())) { merged_methods->at_put(i, orig_method); - original_methods->at_put(orig_idx, NULL); + original_methods->at_put(orig_idx, nullptr); if (merged_ordering->length() > 0) { - assert(original_ordering != NULL && original_ordering->length() > 0, + assert(original_ordering != nullptr && original_ordering->length() > 0, "should have original order information for this method"); merged_ordering->at_put(i, original_ordering->at(orig_idx)); } @@ -1144,7 +1144,7 @@ static void merge_in_new_methods(InstanceKlass* klass, if (original_methods->length() > 0) { MetadataFactory::free_array(cld, original_methods); } - if (original_ordering != NULL && original_ordering->length() > 0) { + if (original_ordering != nullptr && original_ordering->length() > 0) { MetadataFactory::free_array(cld, original_ordering); } } diff --git a/src/hotspot/share/classfile/dictionary.cpp b/src/hotspot/share/classfile/dictionary.cpp index 9eacb33f291..f60d426f5fb 100644 --- a/src/hotspot/share/classfile/dictionary.cpp +++ b/src/hotspot/share/classfile/dictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -90,7 +90,7 @@ DictionaryEntry::~DictionaryEntry() { // pd_set is accessed during a safepoint. // This doesn't require a lock because nothing is reading this // entry anymore. The ClassLoader is dead. - while (pd_set_acquire() != NULL) { + while (pd_set_acquire() != nullptr) { ProtectionDomainEntry* to_delete = pd_set_acquire(); release_set_pd_set(to_delete->next_acquire()); delete to_delete; @@ -110,7 +110,7 @@ bool Dictionary::check_if_needs_resize() { bool DictionaryEntry::is_valid_protection_domain(Handle protection_domain) { - return protection_domain() == NULL || !java_lang_System::allow_security_manager() + return protection_domain() == nullptr || !java_lang_System::allow_security_manager() ? true : contains_protection_domain(protection_domain()); } @@ -133,7 +133,7 @@ bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { // Ensure this doesn't show up in the pd_set (invariant) bool in_pd_set = false; for (ProtectionDomainEntry* current = pd_set_acquire(); - current != NULL; + current != nullptr; current = current->next_acquire()) { if (current->object_no_keepalive() == protection_domain) { in_pd_set = true; @@ -153,7 +153,7 @@ bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { } for (ProtectionDomainEntry* current = pd_set_acquire(); - current != NULL; + current != nullptr; current = current->next_acquire()) { if (current->object_no_keepalive() == protection_domain) { return true; @@ -240,7 +240,7 @@ public: void Dictionary::add_klass(JavaThread* current, Symbol* class_name, InstanceKlass* obj) { assert_locked_or_safepoint(SystemDictionary_lock); // doesn't matter now - assert(obj != NULL, "adding NULL obj"); + assert(obj != nullptr, "adding nullptr obj"); assert(obj->name() == class_name, "sanity check on name"); DictionaryEntry* entry = new DictionaryEntry(obj); @@ -296,10 +296,10 @@ InstanceKlass* Dictionary::find(Thread* current, Symbol* name, NoSafepointVerifier nsv; DictionaryEntry* entry = get_entry(current, name); - if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) { + if (entry != nullptr && entry->is_valid_protection_domain(protection_domain)) { return entry->instance_klass(); } else { - return NULL; + return nullptr; } } @@ -307,7 +307,7 @@ InstanceKlass* Dictionary::find_class(Thread* current, Symbol* name) { assert_locked_or_safepoint(SystemDictionary_lock); DictionaryEntry* entry = get_entry(current, name); - return (entry != NULL) ? entry->instance_klass() : NULL; + return (entry != nullptr) ? entry->instance_klass() : nullptr; } void Dictionary::add_protection_domain(JavaThread* current, @@ -317,8 +317,8 @@ void Dictionary::add_protection_domain(JavaThread* current, Symbol* klass_name = klass->name(); DictionaryEntry* entry = get_entry(current, klass_name); - assert(entry != NULL,"entry must be present, we just created it"); - assert(protection_domain() != NULL, + assert(entry != nullptr,"entry must be present, we just created it"); + assert(protection_domain() != nullptr, "real protection domain should be present"); entry->add_protection_domain(loader_data(), protection_domain); @@ -344,8 +344,8 @@ void Dictionary::validate_protection_domain(InstanceKlass* klass, Handle protection_domain, TRAPS) { - assert(class_loader() != NULL, "Should not call this"); - assert(protection_domain() != NULL, "Should not call this"); + assert(class_loader() != nullptr, "Should not call this"); + assert(protection_domain() != nullptr, "Should not call this"); if (!java_lang_System::allow_security_manager() || is_valid_protection_domain(THREAD, klass->name(), protection_domain)) { @@ -422,9 +422,9 @@ void Dictionary::clean_cached_protection_domains(GrowableArrayinstance_klass(); ProtectionDomainEntry* current = probe->pd_set_acquire(); - ProtectionDomainEntry* prev = NULL; - while (current != NULL) { - if (current->object_no_keepalive() == NULL) { + ProtectionDomainEntry* prev = nullptr; + while (current != nullptr) { + if (current->object_no_keepalive() == nullptr) { LogTarget(Debug, protectiondomain) lt; if (lt.is_enabled()) { ResourceMark rm; @@ -438,7 +438,7 @@ void Dictionary::clean_cached_protection_domains(GrowableArraypd_set_acquire() == current) { probe->release_set_pd_set(current->next_acquire()); } else { - assert(prev != NULL, "should be set by alive entry"); + assert(prev != nullptr, "should be set by alive entry"); prev->release_set_next(current->next_acquire()); } // Mark current for deletion but in the meantime it can still be @@ -459,7 +459,7 @@ void Dictionary::clean_cached_protection_domains(GrowableArraynext_acquire()) { guarantee(oopDesc::is_oop_or_null(current->object_no_keepalive()), "Invalid oop"); } @@ -469,7 +469,7 @@ void DictionaryEntry::print_count(outputStream *st) { assert_locked_or_safepoint(SystemDictionary_lock); int count = 0; for (ProtectionDomainEntry* current = pd_set_acquire(); - current != NULL; + current != nullptr; current = current->next_acquire()) { count++; } @@ -486,7 +486,7 @@ void Dictionary::print_size(outputStream* st) const { void Dictionary::print_on(outputStream* st) const { ResourceMark rm; - assert(loader_data() != NULL, "loader data should not be null"); + assert(loader_data() != nullptr, "loader data should not be null"); assert(!loader_data()->has_class_mirror_holder(), "cld should have a ClassLoader holder not a Class holder"); print_size(st); st->print_cr("^ indicates that initiating loader is different from defining loader"); @@ -532,7 +532,7 @@ void Dictionary::verify() { ClassLoaderData* cld = loader_data(); // class loader must be present; a null class loader is the // bootstrap loader - guarantee(cld != NULL && + guarantee(cld != nullptr && (cld->is_the_null_class_loader_data() || cld->class_loader_no_keepalive()->is_instance()), "checking type of class_loader"); diff --git a/src/hotspot/share/classfile/fieldLayoutBuilder.cpp b/src/hotspot/share/classfile/fieldLayoutBuilder.cpp index aef7a062e12..f89eb625642 100644 --- a/src/hotspot/share/classfile/fieldLayoutBuilder.cpp +++ b/src/hotspot/share/classfile/fieldLayoutBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, 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 @@ -36,8 +36,8 @@ LayoutRawBlock::LayoutRawBlock(Kind kind, int size) : - _next_block(NULL), - _prev_block(NULL), + _next_block(nullptr), + _prev_block(nullptr), _kind(kind), _offset(-1), _alignment(1), @@ -51,8 +51,8 @@ LayoutRawBlock::LayoutRawBlock(Kind kind, int size) : LayoutRawBlock::LayoutRawBlock(int index, Kind kind, int size, int alignment, bool is_reference) : - _next_block(NULL), - _prev_block(NULL), + _next_block(nullptr), + _prev_block(nullptr), _kind(kind), _offset(-1), _alignment(alignment), @@ -74,16 +74,16 @@ bool LayoutRawBlock::fit(int size, int alignment) { } FieldGroup::FieldGroup(int contended_group) : - _next(NULL), - _primitive_fields(NULL), - _oop_fields(NULL), + _next(nullptr), + _primitive_fields(nullptr), + _oop_fields(nullptr), _contended_group(contended_group), // -1 means no contended group, 0 means default contended group _oop_count(0) {} void FieldGroup::add_primitive_field(AllFieldStream fs, BasicType type) { int size = type2aelembytes(type); LayoutRawBlock* block = new LayoutRawBlock(fs.index(), LayoutRawBlock::REGULAR, size, size /* alignment == size for primitive types */, false); - if (_primitive_fields == NULL) { + if (_primitive_fields == nullptr) { _primitive_fields = new GrowableArray(INITIAL_LIST_SIZE); } _primitive_fields->append(block); @@ -92,7 +92,7 @@ void FieldGroup::add_primitive_field(AllFieldStream fs, BasicType type) { void FieldGroup::add_oop_field(AllFieldStream fs) { int size = type2aelembytes(T_OBJECT); LayoutRawBlock* block = new LayoutRawBlock(fs.index(), LayoutRawBlock::REGULAR, size, size /* alignment == size for oops */, true); - if (_oop_fields == NULL) { + if (_oop_fields == nullptr) { _oop_fields = new GrowableArray(INITIAL_LIST_SIZE); } _oop_fields->append(block); @@ -100,7 +100,7 @@ void FieldGroup::add_oop_field(AllFieldStream fs) { } void FieldGroup::sort_by_size() { - if (_primitive_fields != NULL) { + if (_primitive_fields != nullptr) { _primitive_fields->sort(LayoutRawBlock::compare_size_inverted); } } @@ -108,7 +108,7 @@ void FieldGroup::sort_by_size() { FieldLayout::FieldLayout(Array* fields, ConstantPool* cp) : _fields(fields), _cp(cp), - _blocks(NULL), + _blocks(nullptr), _start(_blocks), _last(_blocks) {} @@ -128,7 +128,7 @@ void FieldLayout::initialize_static_layout() { } void FieldLayout::initialize_instance_layout(const InstanceKlass* super_klass) { - if (super_klass == NULL) { + if (super_klass == nullptr) { _blocks = new LayoutRawBlock(LayoutRawBlock::EMPTY, INT_MAX); _blocks->set_offset(0); _last = _blocks; @@ -161,15 +161,15 @@ LayoutRawBlock* FieldLayout::first_field_block() { // add the field at the end of the layout. // Fields cannot be inserted before the block specified in the "start" argument void FieldLayout::add(GrowableArray* list, LayoutRawBlock* start) { - if (list == NULL) return; - if (start == NULL) start = this->_start; + if (list == nullptr) return; + if (start == nullptr) start = this->_start; bool last_search_success = false; int last_size = 0; int last_alignment = 0; for (int i = 0; i < list->length(); i ++) { LayoutRawBlock* b = list->at(i); - LayoutRawBlock* cursor = NULL; - LayoutRawBlock* candidate = NULL; + LayoutRawBlock* cursor = nullptr; + LayoutRawBlock* candidate = nullptr; // if start is the last block, just append the field if (start == last_block()) { @@ -186,21 +186,21 @@ void FieldLayout::add(GrowableArray* list, LayoutRawBlock* star last_size = b->size(); last_alignment = b->alignment(); cursor = last_block()->prev_block(); - assert(cursor != NULL, "Sanity check"); + assert(cursor != nullptr, "Sanity check"); last_search_success = true; while (cursor != start) { if (cursor->kind() == LayoutRawBlock::EMPTY && cursor->fit(b->size(), b->alignment())) { - if (candidate == NULL || cursor->size() < candidate->size()) { + if (candidate == nullptr || cursor->size() < candidate->size()) { candidate = cursor; } } cursor = cursor->prev_block(); } - if (candidate == NULL) { + if (candidate == nullptr) { candidate = last_block(); last_search_success = false; } - assert(candidate != NULL, "Candidate must not be null"); + assert(candidate != nullptr, "Candidate must not be null"); assert(candidate->kind() == LayoutRawBlock::EMPTY, "Candidate must be an empty block"); assert(candidate->fit(b->size(), b->alignment()), "Candidate must be able to store the block"); } @@ -211,13 +211,13 @@ void FieldLayout::add(GrowableArray* list, LayoutRawBlock* star // Used for classes with hard coded field offsets, insert a field at the specified offset */ void FieldLayout::add_field_at_offset(LayoutRawBlock* block, int offset, LayoutRawBlock* start) { - assert(block != NULL, "Sanity check"); + assert(block != nullptr, "Sanity check"); block->set_offset(offset); - if (start == NULL) { + if (start == nullptr) { start = this->_start; } LayoutRawBlock* slot = start; - while (slot != NULL) { + while (slot != nullptr) { if ((slot->offset() <= block->offset() && (slot->offset() + slot->size()) > block->offset()) || slot == _last){ assert(slot->kind() == LayoutRawBlock::EMPTY, "Matching slot must be an empty slot"); @@ -243,8 +243,8 @@ void FieldLayout::add_field_at_offset(LayoutRawBlock* block, int offset, LayoutR // in the first empty slot big enough to contain the whole set ((including padding // to fit alignment constraints). void FieldLayout::add_contiguously(GrowableArray* list, LayoutRawBlock* start) { - if (list == NULL) return; - if (start == NULL) { + if (list == nullptr) return; + if (start == nullptr) { start = _start; } // This code assumes that if the first block is well aligned, the following @@ -254,7 +254,7 @@ void FieldLayout::add_contiguously(GrowableArray* list, LayoutR size += list->at(i)->size(); } - LayoutRawBlock* candidate = NULL; + LayoutRawBlock* candidate = nullptr; if (start == last_block()) { candidate = last_block(); } else { @@ -267,7 +267,7 @@ void FieldLayout::add_contiguously(GrowableArray* list, LayoutR } candidate = candidate->prev_block(); } - assert(candidate != NULL, "Candidate must not be null"); + assert(candidate != nullptr, "Candidate must not be null"); assert(candidate->kind() == LayoutRawBlock::EMPTY, "Candidate must be an empty block"); assert(candidate->fit(size, first->alignment()), "Candidate must be able to store the whole contiguous block"); } @@ -297,7 +297,7 @@ LayoutRawBlock* FieldLayout::insert_field_block(LayoutRawBlock* slot, LayoutRawB bool FieldLayout::reconstruct_layout(const InstanceKlass* ik) { bool has_instance_fields = false; GrowableArray* all_fields = new GrowableArray(32); - while (ik != NULL) { + while (ik != nullptr) { for (AllFieldStream fs(ik->fields(), ik->constants()); !fs.done(); fs.next()) { BasicType type = Signature::basic_type(fs.signature()); // distinction between static and non-static fields is missing @@ -309,7 +309,7 @@ bool FieldLayout::reconstruct_layout(const InstanceKlass* ik) { block->set_offset(fs.offset()); all_fields->append(block); } - ik = ik->super() == NULL ? NULL : InstanceKlass::cast(ik->super()); + ik = ik->super() == nullptr ? nullptr : InstanceKlass::cast(ik->super()); } all_fields->sort(LayoutRawBlock::compare_offset); @@ -334,11 +334,11 @@ bool FieldLayout::reconstruct_layout(const InstanceKlass* ik) { // by inserting PADDING blocks instead of EMPTY block to prevent subclasses' // fields to interfere with contended fields/classes. void FieldLayout::fill_holes(const InstanceKlass* super_klass) { - assert(_blocks != NULL, "Sanity check"); + assert(_blocks != nullptr, "Sanity check"); assert(_blocks->offset() == 0, "first block must be at offset zero"); LayoutRawBlock::Kind filling_type = super_klass->has_contended_annotations() ? LayoutRawBlock::PADDING: LayoutRawBlock::EMPTY; LayoutRawBlock* b = _blocks; - while (b->next_block() != NULL) { + while (b->next_block() != nullptr) { if (b->next_block()->offset() > (b->offset() + b->size())) { int size = b->next_block()->offset() - (b->offset() + b->size()); LayoutRawBlock* empty = new LayoutRawBlock(filling_type, size); @@ -350,7 +350,7 @@ void FieldLayout::fill_holes(const InstanceKlass* super_klass) { } b = b->next_block(); } - assert(b->next_block() == NULL, "Invariant at this point"); + assert(b->next_block() == nullptr, "Invariant at this point"); assert(b->kind() != LayoutRawBlock::EMPTY, "Sanity check"); // If the super class has @Contended annotation, a padding block is @@ -397,7 +397,7 @@ LayoutRawBlock* FieldLayout::insert(LayoutRawBlock* slot, LayoutRawBlock* block) block->set_prev_block(slot->prev_block()); block->set_next_block(slot); slot->set_prev_block(block); - if (block->prev_block() != NULL) { + if (block->prev_block() != nullptr) { block->prev_block()->set_next_block(block); } if (_blocks == slot) { @@ -407,15 +407,15 @@ LayoutRawBlock* FieldLayout::insert(LayoutRawBlock* slot, LayoutRawBlock* block) } void FieldLayout::remove(LayoutRawBlock* block) { - assert(block != NULL, "Sanity check"); + assert(block != nullptr, "Sanity check"); assert(block != _last, "Sanity check"); if (_blocks == block) { _blocks = block->next_block(); - if (_blocks != NULL) { - _blocks->set_prev_block(NULL); + if (_blocks != nullptr) { + _blocks->set_prev_block(nullptr); } } else { - assert(block->prev_block() != NULL, "_prev should be set for non-head blocks"); + assert(block->prev_block() != nullptr, "_prev should be set for non-head blocks"); block->prev_block()->set_next_block(block->next_block()); block->next_block()->set_prev_block(block->prev_block()); } @@ -460,10 +460,10 @@ void FieldLayout::print(outputStream* output, bool is_static, const InstanceKlas } case LayoutRawBlock::INHERITED: { assert(!is_static, "Static fields are not inherited in layouts"); - assert(super != NULL, "super klass must be provided to retrieve inherited fields info"); + assert(super != nullptr, "super klass must be provided to retrieve inherited fields info"); bool found = false; const InstanceKlass* ik = super; - while (!found && ik != NULL) { + while (!found && ik != nullptr) { for (AllFieldStream fs(ik->fields(), ik->constants()); !fs.done(); fs.next()) { if (fs.offset() == b->offset()) { output->print_cr(" @%d \"%s\" %s %d/%d %s", @@ -505,11 +505,11 @@ FieldLayoutBuilder::FieldLayoutBuilder(const Symbol* classname, const InstanceKl _constant_pool(constant_pool), _fields(fields), _info(info), - _root_group(NULL), + _root_group(nullptr), _contended_groups(GrowableArray(8)), - _static_fields(NULL), - _layout(NULL), - _static_layout(NULL), + _static_fields(nullptr), + _layout(nullptr), + _static_layout(nullptr), _nonstatic_oopmap_count(0), _alignment(-1), _has_nonstatic_fields(false), @@ -518,7 +518,7 @@ FieldLayoutBuilder::FieldLayoutBuilder(const Symbol* classname, const InstanceKl FieldGroup* FieldLayoutBuilder::get_or_create_contended_group(int g) { assert(g > 0, "must only be called for named contended groups"); - FieldGroup* fg = NULL; + FieldGroup* fg = nullptr; for (int i = 0; i < _contended_groups.length(); i++) { fg = _contended_groups.at(i); if (fg->contended_group() == g) return fg; @@ -532,7 +532,7 @@ void FieldLayoutBuilder::prologue() { _layout = new FieldLayout(_fields, _constant_pool); const InstanceKlass* super_klass = _super_klass; _layout->initialize_instance_layout(super_klass); - if (super_klass != NULL) { + if (super_klass != nullptr) { _has_nonstatic_fields = super_klass->has_nonstatic_fields(); } _static_layout = new FieldLayout(_fields, _constant_pool); @@ -548,7 +548,7 @@ void FieldLayoutBuilder::prologue() { // - @Contended annotation is ignored for static fields void FieldLayoutBuilder::regular_field_sorting() { for (AllFieldStream fs(_fields, _constant_pool); !fs.done(); fs.next()) { - FieldGroup* group = NULL; + FieldGroup* group = nullptr; if (fs.access_flags().is_static()) { group = _static_fields; } else { @@ -565,7 +565,7 @@ void FieldLayoutBuilder::regular_field_sorting() { group = _root_group; } } - assert(group != NULL, "invariant"); + assert(group != nullptr, "invariant"); BasicType type = Signature::basic_type(fs.signature()); switch(type) { case T_BYTE: @@ -646,7 +646,7 @@ void FieldLayoutBuilder::compute_regular_layout() { void FieldLayoutBuilder::epilogue() { // Computing oopmaps - int super_oop_map_count = (_super_klass == NULL) ? 0 :_super_klass->nonstatic_oop_map_count(); + int super_oop_map_count = (_super_klass == nullptr) ? 0 :_super_klass->nonstatic_oop_map_count(); int max_oop_map_count = super_oop_map_count + _nonstatic_oopmap_count; OopMapBlocksBuilder* nonstatic_oop_maps = @@ -656,7 +656,7 @@ void FieldLayoutBuilder::epilogue() { _super_klass->nonstatic_oop_map_count()); } - if (_root_group->oop_fields() != NULL) { + if (_root_group->oop_fields() != nullptr) { for (int i = 0; i < _root_group->oop_fields()->length(); i++) { LayoutRawBlock* b = _root_group->oop_fields()->at(i); nonstatic_oop_maps->add(b->offset(), 1); @@ -667,7 +667,7 @@ void FieldLayoutBuilder::epilogue() { for (int i = 0; i < _contended_groups.length(); i++) { FieldGroup* cg = _contended_groups.at(i); if (cg->oop_count() > 0) { - assert(cg->oop_fields() != NULL && cg->oop_fields()->at(0) != NULL, "oop_count > 0 but no oop fields found"); + assert(cg->oop_fields() != nullptr && cg->oop_fields()->at(0) != nullptr, "oop_count > 0 but no oop fields found"); nonstatic_oop_maps->add(cg->oop_fields()->at(0)->offset(), cg->oop_count()); } } @@ -695,7 +695,7 @@ void FieldLayoutBuilder::epilogue() { tty->print_cr("Instance fields:"); _layout->print(tty, false, _super_klass); tty->print_cr("Static fields:"); - _static_layout->print(tty, true, NULL); + _static_layout->print(tty, true, nullptr); tty->print_cr("Instance size = %d bytes", _info->_instance_size * wordSize); tty->print_cr("---"); } diff --git a/src/hotspot/share/classfile/fieldLayoutBuilder.hpp b/src/hotspot/share/classfile/fieldLayoutBuilder.hpp index 462ba7d5ff5..63a9337f674 100644 --- a/src/hotspot/share/classfile/fieldLayoutBuilder.hpp +++ b/src/hotspot/share/classfile/fieldLayoutBuilder.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, 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 @@ -188,9 +188,9 @@ class FieldLayout : public ResourceObj { LayoutRawBlock* last_block() { return _last; } LayoutRawBlock* first_field_block(); - void add(GrowableArray* list, LayoutRawBlock* start = NULL); - void add_field_at_offset(LayoutRawBlock* blocks, int offset, LayoutRawBlock* start = NULL); - void add_contiguously(GrowableArray* list, LayoutRawBlock* start = NULL); + void add(GrowableArray* list, LayoutRawBlock* start = nullptr); + void add_field_at_offset(LayoutRawBlock* blocks, int offset, LayoutRawBlock* start = nullptr); + void add_contiguously(GrowableArray* list, LayoutRawBlock* start = nullptr); LayoutRawBlock* insert_field_block(LayoutRawBlock* slot, LayoutRawBlock* block); bool reconstruct_layout(const InstanceKlass* ik); void fill_holes(const InstanceKlass* ik); diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 6d966208860..664323effec 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -124,7 +124,7 @@ InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) { vmSymbolID sid = vmSymbols::find_sid(class_name); if (sid == vmSymbolID::NO_SID) { // Only well known classes can inject fields - return NULL; + return nullptr; } int count = 0; @@ -144,7 +144,7 @@ InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) { *field_count = count; return _injected_fields + start; } - return NULL; + return nullptr; } @@ -155,7 +155,7 @@ void JavaClasses::compute_offset(int &dest_offset, InstanceKlass* ik, Symbol* name_symbol, Symbol* signature_symbol, bool is_static) { fieldDescriptor fd; - if (ik == NULL) { + if (ik == nullptr) { ResourceMark rm; log_error(class)("Mismatch JDK version for field: %s type: %s", name_symbol->as_C_string(), signature_symbol->as_C_string()); vm_exit_during_initialization("Invalid layout of well-known class"); @@ -181,7 +181,7 @@ void JavaClasses::compute_offset(int& dest_offset, InstanceKlass* ik, const char* name_string, Symbol* signature_symbol, bool is_static) { TempNewSymbol name = SymbolTable::probe(name_string, (int)strlen(name_string)); - if (name == NULL) { + if (name == nullptr) { ResourceMark rm; log_error(class)("Name %s should be in the SymbolTable since its class is loaded", name_string); vm_exit_during_initialization("Invalid layout of well-known class", ik->external_name()); @@ -249,7 +249,7 @@ public: if (fd->name() == vmSymbols::compact_strings_name()) { oop mirror = fd->field_holder()->java_mirror(); assert(fd->field_holder() == vmClasses::String_klass(), "Should be String"); - assert(mirror != NULL, "String must have mirror already"); + assert(mirror != nullptr, "String must have mirror already"); mirror->bool_field_put(fd->offset(), _value); } } @@ -318,7 +318,7 @@ oop java_lang_String::create_oop_from_unicode(const jchar* unicode, int length, } Handle java_lang_String::create_from_str(const char* utf8_str, TRAPS) { - if (utf8_str == NULL) { + if (utf8_str == nullptr) { return Handle(); } bool has_multibyte, is_latin1; @@ -400,26 +400,26 @@ Handle java_lang_String::create_from_symbol(Symbol* symbol, TRAPS) { // Converts a C string to a Java String based on current encoding Handle java_lang_String::create_from_platform_dependent_str(const char* str, TRAPS) { - assert(str != NULL, "bad arguments"); + assert(str != nullptr, "bad arguments"); typedef jstring (JNICALL *to_java_string_fn_t)(JNIEnv*, const char *); - static to_java_string_fn_t _to_java_string_fn = NULL; + static to_java_string_fn_t _to_java_string_fn = nullptr; - if (_to_java_string_fn == NULL) { + if (_to_java_string_fn == nullptr) { void *lib_handle = os::native_java_library(); _to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "JNU_NewStringPlatform")); #if defined(_WIN32) && !defined(_WIN64) - if (_to_java_string_fn == NULL) { + if (_to_java_string_fn == nullptr) { // On 32 bit Windows, also try __stdcall decorated name _to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "_JNU_NewStringPlatform@8")); } #endif - if (_to_java_string_fn == NULL) { + if (_to_java_string_fn == nullptr) { fatal("JNU_NewStringPlatform missing"); } } - jstring js = NULL; + jstring js = nullptr; { JavaThread* thread = THREAD; HandleMark hm(thread); @@ -436,12 +436,12 @@ Handle java_lang_String::create_from_platform_dependent_str(const char* str, TRA // native OS calls. char* java_lang_String::as_platform_dependent_str(Handle java_string, TRAPS) { typedef char* (*to_platform_string_fn_t)(JNIEnv*, jstring, bool*); - static to_platform_string_fn_t _to_platform_string_fn = NULL; + static to_platform_string_fn_t _to_platform_string_fn = nullptr; - if (_to_platform_string_fn == NULL) { + if (_to_platform_string_fn == nullptr) { void *lib_handle = os::native_java_library(); _to_platform_string_fn = CAST_TO_FN_PTR(to_platform_string_fn_t, os::dll_lookup(lib_handle, "GetStringPlatformChars")); - if (_to_platform_string_fn == NULL) { + if (_to_platform_string_fn == nullptr) { fatal("GetStringPlatformChars missing"); } } @@ -471,7 +471,7 @@ Handle java_lang_String::externalize_classname(Symbol* java_name, TRAPS) { jchar* java_lang_String::as_unicode_string(oop java_string, int& length, TRAPS) { jchar* result = as_unicode_string_or_null(java_string, length); - if (result == NULL) { + if (result == nullptr) { THROW_MSG_0(vmSymbols::java_lang_OutOfMemoryError(), "could not allocate Unicode string"); } return result; @@ -483,7 +483,7 @@ jchar* java_lang_String::as_unicode_string_or_null(oop java_string, int& length) bool is_latin1 = java_lang_String::is_latin1(java_string); jchar* result = NEW_RESOURCE_ARRAY_RETURN_NULL(jchar, length); - if (result != NULL) { + if (result != nullptr) { if (!is_latin1) { for (int index = 0; index < length; index++) { result[index] = value->char_at(index); @@ -548,7 +548,7 @@ char* java_lang_String::as_quoted_ascii(oop java_string) { int length = java_lang_String::length(java_string, value); bool is_latin1 = java_lang_String::is_latin1(java_string); - if (length == 0) return NULL; + if (length == 0) return nullptr; char* result; int result_length; @@ -573,12 +573,12 @@ Symbol* java_lang_String::as_symbol(oop java_string) { int length = java_lang_String::length(java_string, value); bool is_latin1 = java_lang_String::is_latin1(java_string); if (!is_latin1) { - jchar* base = (length == 0) ? NULL : value->char_at_addr(0); + jchar* base = (length == 0) ? nullptr : value->char_at_addr(0); Symbol* sym = SymbolTable::new_symbol(base, length); return sym; } else { ResourceMark rm; - jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0); + jbyte* position = (length == 0) ? nullptr : value->byte_at_addr(0); const char* base = UNICODE::as_utf8(position, length); Symbol* sym = SymbolTable::new_symbol(base, length); return sym; @@ -590,11 +590,11 @@ Symbol* java_lang_String::as_symbol_or_null(oop java_string) { int length = java_lang_String::length(java_string, value); bool is_latin1 = java_lang_String::is_latin1(java_string); if (!is_latin1) { - jchar* base = (length == 0) ? NULL : value->char_at_addr(0); + jchar* base = (length == 0) ? nullptr : value->char_at_addr(0); return SymbolTable::probe_unicode(base, length); } else { ResourceMark rm; - jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0); + jbyte* position = (length == 0) ? nullptr : value->byte_at_addr(0); const char* base = UNICODE::as_utf8(position, length); return SymbolTable::probe(base, length); } @@ -629,10 +629,10 @@ char* java_lang_String::as_utf8_string(oop java_string, int& length) { length = java_lang_String::length(java_string, value); bool is_latin1 = java_lang_String::is_latin1(java_string); if (!is_latin1) { - jchar* position = (length == 0) ? NULL : value->char_at_addr(0); + jchar* position = (length == 0) ? nullptr : value->char_at_addr(0); return UNICODE::as_utf8(position, length); } else { - jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0); + jbyte* position = (length == 0) ? nullptr : value->byte_at_addr(0); return UNICODE::as_utf8(position, length); } } @@ -644,14 +644,14 @@ char* java_lang_String::as_utf8_string_full(oop java_string, char* buf, int bufl int len = java_lang_String::length(java_string, value); bool is_latin1 = java_lang_String::is_latin1(java_string); if (!is_latin1) { - jchar *position = (len == 0) ? NULL : value->char_at_addr(0); + jchar *position = (len == 0) ? nullptr : value->char_at_addr(0); utf8_len = UNICODE::utf8_length(position, len); if (utf8_len >= buflen) { buf = NEW_RESOURCE_ARRAY(char, utf8_len + 1); } return UNICODE::as_utf8(position, len, buf, utf8_len + 1); } else { - jbyte *position = (len == 0) ? NULL : value->byte_at_addr(0); + jbyte *position = (len == 0) ? nullptr : value->byte_at_addr(0); utf8_len = UNICODE::utf8_length(position, len); if (utf8_len >= buflen) { buf = NEW_RESOURCE_ARRAY(char, utf8_len + 1); @@ -666,10 +666,10 @@ char* java_lang_String::as_utf8_string(oop java_string, typeArrayOop value, char int length = java_lang_String::length(java_string, value); bool is_latin1 = java_lang_String::is_latin1(java_string); if (!is_latin1) { - jchar* position = (length == 0) ? NULL : value->char_at_addr(0); + jchar* position = (length == 0) ? nullptr : value->char_at_addr(0); return UNICODE::as_utf8(position, length, buf, buflen); } else { - jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0); + jbyte* position = (length == 0) ? nullptr : value->byte_at_addr(0); return UNICODE::as_utf8(position, length, buf, buflen); } } @@ -752,10 +752,10 @@ void java_lang_String::print(oop java_string, outputStream* st) { assert(java_string->klass() == vmClasses::String_klass(), "must be java_string"); typeArrayOop value = java_lang_String::value_no_keepalive(java_string); - if (value == NULL) { + if (value == nullptr) { // This can happen if, e.g., printing a String // object before its initializer has been called - st->print("NULL"); + st->print("nullptr"); return; } @@ -787,8 +787,8 @@ int java_lang_Class::_classData_offset; int java_lang_Class::_classRedefinedCount_offset; bool java_lang_Class::_offsets_computed = false; -GrowableArray* java_lang_Class::_fixup_mirror_list = NULL; -GrowableArray* java_lang_Class::_fixup_module_field_list = NULL; +GrowableArray* java_lang_Class::_fixup_mirror_list = nullptr; +GrowableArray* java_lang_Class::_fixup_module_field_list = nullptr; #ifdef ASSERT inline static void assert_valid_static_string_field(fieldDescriptor* fd) { @@ -901,9 +901,9 @@ void java_lang_Class::initialize_mirror_fields(Klass* k, // Set the java.lang.Module module field in the java_lang_Class mirror void java_lang_Class::set_mirror_module_field(JavaThread* current, Klass* k, Handle mirror, Handle module) { if (module.is_null()) { - // During startup, the module may be NULL only if java.base has not been defined yet. + // During startup, the module may be null only if java.base has not been defined yet. // Put the class on the fixup_module_list to patch later when the java.lang.Module - // for java.base is known. But note that since we captured the NULL module another + // for java.base is known. But note that since we captured the null module another // thread may have completed that initialization. bool javabase_was_defined = false; @@ -911,9 +911,9 @@ void java_lang_Class::set_mirror_module_field(JavaThread* current, Klass* k, Han MutexLocker m1(current, Module_lock); // Keep list of classes needing java.base module fixup if (!ModuleEntryTable::javabase_defined()) { - assert(k->java_mirror() != NULL, "Class's mirror is null"); + assert(k->java_mirror() != nullptr, "Class's mirror is null"); k->class_loader_data()->inc_keep_alive(); - assert(fixup_module_field_list() != NULL, "fixup_module_field_list not initialized"); + assert(fixup_module_field_list() != nullptr, "fixup_module_field_list not initialized"); fixup_module_field_list()->push(k); } else { javabase_was_defined = true; @@ -923,7 +923,7 @@ void java_lang_Class::set_mirror_module_field(JavaThread* current, Klass* k, Han // If java.base was already defined then patch this particular class with java.base. if (javabase_was_defined) { ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry(); - assert(javabase_entry != NULL && javabase_entry->module() != NULL, + assert(javabase_entry != nullptr && javabase_entry->module() != nullptr, "Setting class module field, " JAVA_BASE_NAME " should be defined"); Handle javabase_handle(current, javabase_entry->module()); set_module(mirror(), javabase_handle()); @@ -974,14 +974,14 @@ void java_lang_Class::allocate_mirror(Klass* k, bool is_scratch, Handle protecti } else { assert(k->is_objArray_klass(), "Must be"); Klass* element_klass = ObjArrayKlass::cast(k)->element_klass(); - assert(element_klass != NULL, "Must have an element klass"); + assert(element_klass != nullptr, "Must have an element klass"); if (is_scratch) { comp_mirror = Handle(THREAD, HeapShared::scratch_java_mirror(element_klass)); } else { comp_mirror = Handle(THREAD, element_klass->java_mirror()); } } - assert(comp_mirror() != NULL, "must have a mirror"); + assert(comp_mirror() != nullptr, "must have a mirror"); // Two-way link between the array klass and its component mirror: // (array_klass) k -> mirror -> component_mirror -> array_klass -> k @@ -997,7 +997,7 @@ void java_lang_Class::allocate_mirror(Klass* k, bool is_scratch, Handle protecti // from the mirror so GC doesn't follow it after the klass has been deallocated. // This mirror looks like a primitive type, which logically it is because it // it represents no class. - set_klass(mirror(), NULL); + set_klass(mirror(), nullptr); return; } } @@ -1006,8 +1006,8 @@ void java_lang_Class::allocate_mirror(Klass* k, bool is_scratch, Handle protecti void java_lang_Class::create_mirror(Klass* k, Handle class_loader, Handle module, Handle protection_domain, Handle classData, TRAPS) { - assert(k != NULL, "Use create_basic_type_mirror for primitive types"); - assert(k->java_mirror() == NULL, "should only assign mirror once"); + assert(k != nullptr, "Use create_basic_type_mirror for primitive types"); + assert(k->java_mirror() == nullptr, "should only assign mirror once"); // Use this moment of initialization to cache modifier_flags also, // to support Class.getModifiers(). Instance classes recalculate @@ -1035,7 +1035,7 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader, // after the mirror is set. set_mirror_module_field(THREAD, k, mirror, module); - if (comp_mirror() != NULL) { + if (comp_mirror() != nullptr) { // Set after k->java_mirror() is published, because compiled code running // concurrently doesn't expect a k to have a null java_mirror. release_set_array_klass(comp_mirror(), k); @@ -1044,7 +1044,7 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader, create_scratch_mirror(k, CHECK); } } else { - assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized"); + assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized"); fixup_mirror_list()->push(k); } } @@ -1062,19 +1062,19 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader, // latter may contain dumptime-specific information that cannot be archived // (e.g., ClassLoaderData*, or static fields that are modified by Java code execution). void java_lang_Class::create_scratch_mirror(Klass* k, TRAPS) { - if (k->class_loader() != NULL && + if (k->class_loader() != nullptr && k->class_loader() != SystemDictionary::java_platform_loader() && k->class_loader() != SystemDictionary::java_system_loader()) { // We only archive the mirrors of classes loaded by the built-in loaders return; } - Handle protection_domain, classData; // set to NULL. Will be reinitialized at runtime + Handle protection_domain, classData; // set to null. Will be reinitialized at runtime Handle mirror; Handle comp_mirror; allocate_mirror(k, /*is_scratch=*/true, protection_domain, classData, mirror, comp_mirror, CHECK); - if (comp_mirror() != NULL) { + if (comp_mirror() != nullptr) { release_set_array_klass(comp_mirror(), k); } @@ -1090,13 +1090,13 @@ bool java_lang_Class::restore_archived_mirror(Klass *k, // Postpone restoring archived mirror until java.lang.Class is loaded. Please // see more details in vmClasses::resolve_all(). if (!vmClasses::Class_klass_loaded()) { - assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized"); + assert(fixup_mirror_list() != nullptr, "fixup_mirror_list not initialized"); fixup_mirror_list()->push(k); return true; } oop m = k->archived_java_mirror(); - assert(m != NULL, "must have stored non-null archived mirror"); + assert(m != nullptr, "must have stored non-null archived mirror"); // Sanity: clear it now to prevent re-initialization if any of the following fails k->clear_archived_mirror_index(); @@ -1217,7 +1217,7 @@ void java_lang_Class::set_module(oop java_class, oop module) { oop java_lang_Class::name(Handle java_class, TRAPS) { assert(_name_offset != 0, "must be set"); oop o = java_class->obj_field(_name_offset); - if (o == NULL) { + if (o == nullptr) { o = StringTable::intern(as_external_name(java_class()), THREAD); java_class->obj_field_put(_name_offset, o); } @@ -1237,10 +1237,10 @@ void java_lang_Class::set_source_file(oop java_class, oop source_file) { oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { // This should be improved by adding a field at the Java level or by // introducing a new VM klass (see comment in ClassFileParser) - oop java_class = InstanceMirrorKlass::cast(vmClasses::Class_klass())->allocate_instance(NULL, CHECK_NULL); + oop java_class = InstanceMirrorKlass::cast(vmClasses::Class_klass())->allocate_instance(nullptr, CHECK_NULL); if (type != T_VOID) { Klass* aklass = Universe::typeArrayKlassObj(type); - assert(aklass != NULL, "correct bootstrap"); + assert(aklass != nullptr, "correct bootstrap"); release_set_array_klass(java_class, aklass); } #ifdef ASSERT @@ -1258,7 +1258,7 @@ void java_lang_Class::set_klass(oop java_class, Klass* klass) { void java_lang_Class::print_signature(oop java_class, outputStream* st) { assert(is_instance(java_class), "must be a Class object"); - Symbol* name = NULL; + Symbol* name = nullptr; bool is_instance = false; if (is_primitive(java_class)) { name = vmSymbols::type_signature(primitive_type(java_class)); @@ -1267,7 +1267,7 @@ void java_lang_Class::print_signature(oop java_class, outputStream* st) { is_instance = k->is_instance_klass(); name = k->name(); } - if (name == NULL) { + if (name == nullptr) { st->print(""); return; } @@ -1309,13 +1309,13 @@ Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found) // For primitive type Java mirrors, its type name is returned. const char* java_lang_Class::as_external_name(oop java_class) { assert(is_instance(java_class), "must be a Class object"); - const char* name = NULL; + const char* name = nullptr; if (is_primitive(java_class)) { name = type2name(primitive_type(java_class)); } else { name = as_Klass(java_class)->external_name(); } - if (name == NULL) { + if (name == nullptr) { name = ""; } return name; @@ -1323,7 +1323,7 @@ const char* java_lang_Class::as_external_name(oop java_class) { Klass* java_lang_Class::array_klass_acquire(oop java_class) { Klass* k = ((Klass*)java_class->metadata_field_acquire(_array_klass_offset)); - assert(k == NULL || k->is_klass() && k->is_array_klass(), "should be array klass"); + assert(k == nullptr || k->is_klass() && k->is_array_klass(), "should be array klass"); return k; } @@ -1338,7 +1338,7 @@ BasicType java_lang_Class::primitive_type(oop java_class) { assert(is_primitive(java_class), "just checking"); Klass* ak = ((Klass*)java_class->metadata_field(_array_klass_offset)); BasicType type = T_VOID; - if (ak != NULL) { + if (ak != nullptr) { // Note: create_basic_type_mirror above initializes ak to a non-null value. type = ArrayKlass::cast(ak)->element_type(); } else { @@ -1351,11 +1351,11 @@ BasicType java_lang_Class::primitive_type(oop java_class) { BasicType java_lang_Class::as_BasicType(oop java_class, Klass** reference_klass) { assert(is_instance(java_class), "must be a Class object"); if (is_primitive(java_class)) { - if (reference_klass != NULL) - (*reference_klass) = NULL; + if (reference_klass != nullptr) + (*reference_klass) = nullptr; return primitive_type(java_class); } else { - if (reference_klass != NULL) + if (reference_klass != nullptr) (*reference_klass) = as_Klass(java_class); return T_OBJECT; } @@ -1364,7 +1364,7 @@ BasicType java_lang_Class::as_BasicType(oop java_class, Klass** reference_klass) oop java_lang_Class::primitive_mirror(BasicType t) { oop mirror = Universe::java_mirror(t); - assert(mirror != NULL && mirror->is_a(vmClasses::Class_klass()), "must be a Class"); + assert(mirror != nullptr && mirror->is_a(vmClasses::Class_klass()), "must be a Class"); assert(is_primitive(mirror), "must be primitive"); return mirror; } @@ -1567,8 +1567,8 @@ void java_lang_Thread::set_jvmti_thread_state(oop java_thread, JvmtiThreadState* } void java_lang_Thread::clear_scopedValueBindings(oop java_thread) { - assert(java_thread != NULL, "need a java_lang_Thread pointer here"); - java_thread->obj_field_put(_scopedValueBindings_offset, NULL); + assert(java_thread != nullptr, "need a java_lang_Thread pointer here"); + java_thread->obj_field_put(_scopedValueBindings_offset, nullptr); } oop java_lang_Thread::holder(oop java_thread) { @@ -1606,41 +1606,41 @@ void java_lang_Thread::set_name(oop java_thread, oop name) { ThreadPriority java_lang_Thread::priority(oop java_thread) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); return java_lang_Thread_FieldHolder::priority(holder); } void java_lang_Thread::set_priority(oop java_thread, ThreadPriority priority) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); java_lang_Thread_FieldHolder::set_priority(holder, priority); } oop java_lang_Thread::threadGroup(oop java_thread) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); return java_lang_Thread_FieldHolder::threadGroup(holder); } bool java_lang_Thread::is_alive(oop java_thread) { JavaThread* thr = java_lang_Thread::thread(java_thread); - return (thr != NULL); + return (thr != nullptr); } bool java_lang_Thread::is_daemon(oop java_thread) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); return java_lang_Thread_FieldHolder::is_daemon(holder); } void java_lang_Thread::set_daemon(oop java_thread) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); java_lang_Thread_FieldHolder::set_daemon(holder); } @@ -1655,14 +1655,14 @@ oop java_lang_Thread::inherited_access_control_context(oop java_thread) { jlong java_lang_Thread::stackSize(oop java_thread) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); return java_lang_Thread_FieldHolder::stackSize(holder); } // Write the thread status value to threadStatus field in java.lang.Thread java class. void java_lang_Thread::set_thread_status(oop java_thread, JavaThreadStatus status) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); java_lang_Thread_FieldHolder::set_thread_status(holder, status); } @@ -1674,7 +1674,7 @@ JavaThreadStatus java_lang_Thread::get_thread_status(oop java_thread) { JavaThread::current()->thread_state() == _thread_in_vm, "Java Thread is not running in vm"); oop holder = java_lang_Thread::holder(java_thread); - if (holder == NULL) { + if (holder == nullptr) { return JavaThreadStatus::NEW; // Java Thread not initialized } else { return java_lang_Thread_FieldHolder::get_thread_status(holder); @@ -1695,15 +1695,15 @@ oop java_lang_Thread::async_get_stack_trace(oop java_thread, TRAPS) { bool is_virtual = java_lang_VirtualThread::is_instance(java_thread); if (is_virtual) { oop carrier_thread = java_lang_VirtualThread::carrier_thread(java_thread); - if (carrier_thread == NULL) { - return NULL; + if (carrier_thread == nullptr) { + return nullptr; } thread = java_lang_Thread::thread(carrier_thread); } else { thread = java_lang_Thread::thread(java_thread); } - if (thread == NULL) { - return NULL; + if (thread == nullptr) { + return nullptr; } class GetStackTraceClosure : public HandshakeClosure { @@ -1751,7 +1751,7 @@ oop java_lang_Thread::async_get_stack_trace(oop java_thread, TRAPS) { return; // not mounted } } else { - carrier = (thread->vthread_continuation() != NULL); + carrier = (thread->vthread_continuation() != nullptr); } const int max_depth = MaxJavaStackTraceDepth; @@ -1791,12 +1791,12 @@ oop java_lang_Thread::async_get_stack_trace(oop java_thread, TRAPS) { // Stop if no stack trace is found. if (gstc._depth == 0) { - return NULL; + return nullptr; } // Convert to StackTraceElement array InstanceKlass* k = vmClasses::StackTraceElement_klass(); - assert(k != NULL, "must be loaded in 1.4+"); + assert(k != nullptr, "must be loaded in 1.4+"); if (k->should_be_initialized()) { k->initialize(CHECK_NULL); } @@ -1815,7 +1815,7 @@ oop java_lang_Thread::async_get_stack_trace(oop java_thread, TRAPS) { const char* java_lang_Thread::thread_status_name(oop java_thread) { oop holder = java_lang_Thread::holder(java_thread); - assert(holder != NULL, "Java Thread not initialized"); + assert(holder != nullptr, "Java Thread not initialized"); JavaThreadStatus status = java_lang_Thread_FieldHolder::get_thread_status(holder); switch (status) { case JavaThreadStatus::NEW : return "NEW"; @@ -1845,10 +1845,10 @@ oop java_lang_ThreadGroup::parent(oop java_thread_group) { const char* java_lang_ThreadGroup::name(oop java_thread_group) { oop name = java_thread_group->obj_field(_name_offset); // ThreadGroup.name can be null - if (name != NULL) { + if (name != nullptr) { return java_lang_String::as_utf8_string(name); } - return NULL; + return nullptr; } ThreadPriority java_lang_ThreadGroup::maxPriority(oop java_thread_group) { @@ -1912,7 +1912,7 @@ void java_lang_VirtualThread::init_static_notify_jvmti_events() { } bool java_lang_VirtualThread::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } oop java_lang_VirtualThread::carrier_thread(oop vthread) { @@ -2031,14 +2031,14 @@ oop java_lang_Throwable::cause(oop throwable) { return throwable->obj_field(_cause_offset); } -// Return Symbol for detailed_message or NULL +// Return Symbol for detailed_message or null Symbol* java_lang_Throwable::detail_message(oop throwable) { PreserveExceptionMark pm(Thread::current()); oop detailed_message = java_lang_Throwable::message(throwable); - if (detailed_message != NULL) { + if (detailed_message != nullptr) { return java_lang_String::as_symbol(detailed_message); } - return NULL; + return nullptr; } void java_lang_Throwable::set_message(oop throwable, oop value) { @@ -2051,17 +2051,17 @@ void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) { } void java_lang_Throwable::clear_stacktrace(oop throwable) { - set_stacktrace(throwable, NULL); + set_stacktrace(throwable, nullptr); } void java_lang_Throwable::print(oop throwable, outputStream* st) { ResourceMark rm; Klass* k = throwable->klass(); - assert(k != NULL, "just checking"); + assert(k != nullptr, "just checking"); st->print("%s", k->external_name()); oop msg = message(throwable); - if (msg != NULL) { + if (msg != nullptr) { st->print(": %s", java_lang_String::as_utf8_string(msg)); } } @@ -2071,7 +2071,7 @@ const int MAX_VERSION = USHRT_MAX; static inline bool version_matches(Method* method, int version) { assert(version < MAX_VERSION, "version is too big"); - return method != NULL && (method->constants()->version() == version); + return method != nullptr && (method->constants()->version() == version); } // This class provides a simple wrapper over the internal structure of @@ -2108,33 +2108,33 @@ class BacktraceBuilder: public StackObj { // get info out of chunks static typeArrayOop get_methods(objArrayHandle chunk) { typeArrayOop methods = typeArrayOop(chunk->obj_at(trace_methods_offset)); - assert(methods != NULL, "method array should be initialized in backtrace"); + assert(methods != nullptr, "method array should be initialized in backtrace"); return methods; } static typeArrayOop get_bcis(objArrayHandle chunk) { typeArrayOop bcis = typeArrayOop(chunk->obj_at(trace_bcis_offset)); - assert(bcis != NULL, "bci array should be initialized in backtrace"); + assert(bcis != nullptr, "bci array should be initialized in backtrace"); return bcis; } static objArrayOop get_mirrors(objArrayHandle chunk) { objArrayOop mirrors = objArrayOop(chunk->obj_at(trace_mirrors_offset)); - assert(mirrors != NULL, "mirror array should be initialized in backtrace"); + assert(mirrors != nullptr, "mirror array should be initialized in backtrace"); return mirrors; } static typeArrayOop get_names(objArrayHandle chunk) { typeArrayOop names = typeArrayOop(chunk->obj_at(trace_names_offset)); - assert(names != NULL, "names array should be initialized in backtrace"); + assert(names != nullptr, "names array should be initialized in backtrace"); return names; } static bool has_hidden_top_frame(objArrayHandle chunk) { oop hidden = chunk->obj_at(trace_hidden_offset); - return hidden != NULL; + return hidden != nullptr; } public: // constructor for new backtrace - BacktraceBuilder(TRAPS): _head(NULL), _methods(NULL), _bcis(NULL), _mirrors(NULL), _names(NULL), _has_hidden_top_frame(false) { + BacktraceBuilder(TRAPS): _head(nullptr), _methods(nullptr), _bcis(nullptr), _mirrors(nullptr), _names(nullptr), _has_hidden_top_frame(false) { expand(CHECK); _backtrace = Handle(THREAD, _head); _index = 0; @@ -2183,7 +2183,7 @@ class BacktraceBuilder: public StackObj { new_head->obj_at_put(trace_bcis_offset, new_bcis()); new_head->obj_at_put(trace_mirrors_offset, new_mirrors()); new_head->obj_at_put(trace_names_offset, new_names()); - new_head->obj_at_put(trace_hidden_offset, NULL); + new_head->obj_at_put(trace_hidden_offset, nullptr); _head = new_head(); _methods = new_methods(); @@ -2219,7 +2219,7 @@ class BacktraceBuilder: public StackObj { // We need to save the mirrors in the backtrace to keep the class // from being unloaded while we still have this stack trace. - assert(method->method_holder()->java_mirror() != NULL, "never push null for mirror"); + assert(method->method_holder()->java_mirror() != nullptr, "never push null for mirror"); _mirrors->obj_at_put(_index, method->method_holder()->java_mirror()); _index++; @@ -2232,7 +2232,7 @@ class BacktraceBuilder: public StackObj { // But this code is used before TRUE is allocated. // Therefore let's just use an arbitrary legal oop // available right here. _methods is a short[]. - assert(_methods != NULL, "we need a legal oop"); + assert(_methods != nullptr, "we need a legal oop"); _has_hidden_top_frame = true; _head->obj_at_put(trace_hidden_offset, _methods); } @@ -2292,7 +2292,7 @@ class BacktraceIterator : public StackObj { } bool repeat() { - return _result.not_null() && _mirrors->obj_at(_index) != NULL; + return _result.not_null() && _mirrors->obj_at(_index) != nullptr; } }; @@ -2310,19 +2310,19 @@ static void print_stack_element_to_stream(outputStream* st, Handle mirror, int m char* method_name = name->as_C_string(); buf_len += (int)strlen(method_name); - char* source_file_name = NULL; + char* source_file_name = nullptr; Symbol* source = Backtrace::get_source_file_name(holder, version); - if (source != NULL) { + if (source != nullptr) { source_file_name = source->as_C_string(); buf_len += (int)strlen(source_file_name); } - char *module_name = NULL, *module_version = NULL; + char *module_name = nullptr, *module_version = nullptr; ModuleEntry* module = holder->module(); if (module->is_named()) { module_name = module->name()->as_C_string(); buf_len += (int)strlen(module_name); - if (module->version() != NULL) { + if (module->version() != nullptr) { module_version = module->version()->as_C_string(); buf_len += (int)strlen(module_version); } @@ -2336,15 +2336,15 @@ static void print_stack_element_to_stream(outputStream* st, Handle mirror, int m size_t buf_off = os::snprintf_checked(buf, buf_size, "\tat %s.%s(", klass_name, method_name); // Print module information - if (module_name != NULL) { - if (module_version != NULL) { + if (module_name != nullptr) { + if (module_version != nullptr) { buf_off += os::snprintf_checked(buf + buf_off, buf_size - buf_off, "%s@%s/", module_name, module_version); } else { buf_off += os::snprintf_checked(buf + buf_off, buf_size - buf_off, "%s/", module_name); } } - // The method can be NULL if the requested class version is gone + // The method can be null if the requested class version is gone Method* method = holder->method_with_orig_idnum(method_id, version); if (!version_matches(method, version)) { strcat(buf, "Redefined)"); @@ -2353,10 +2353,10 @@ static void print_stack_element_to_stream(outputStream* st, Handle mirror, int m if (line_number == -2) { strcat(buf, "Native Method)"); } else { - if (source_file_name != NULL && (line_number != -1)) { + if (source_file_name != nullptr && (line_number != -1)) { // Sourcename and linenumber buf_off += os::snprintf_checked(buf + buf_off, buf_size - buf_off, "%s:%d)", source_file_name, line_number); - } else if (source_file_name != NULL) { + } else if (source_file_name != nullptr) { // Just sourcename buf_off += os::snprintf_checked(buf + buf_off, buf_size - buf_off, "%s)", source_file_name); } else { @@ -2364,7 +2364,7 @@ static void print_stack_element_to_stream(outputStream* st, Handle mirror, int m buf_off += os::snprintf_checked(buf + buf_off, buf_size - buf_off, "Unknown Source)"); } CompiledMethod* nm = method->code(); - if (WizardMode && nm != NULL) { + if (WizardMode && nm != nullptr) { os::snprintf_checked(buf + buf_off, buf_size - buf_off, "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm); } } @@ -2449,7 +2449,7 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand // Start out by clearing the backtrace for this object, in case the VM // runs out of memory while allocating the stack trace - set_backtrace(throwable(), NULL); + set_backtrace(throwable(), nullptr); // Clear lazily constructed Java level stacktrace if refilling occurs // This is unnecessary in 1.7+ but harmless clear_stacktrace(throwable()); @@ -2462,7 +2462,7 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand // If there is no Java frame just return the method that was being called // with bci 0 if (!thread->has_last_Java_frame()) { - if (max_depth >= 1 && method() != NULL) { + if (max_depth >= 1 && method() != nullptr) { bt.push(method(), 0, CHECK); log_info(stacktrace)("%s, %d", throwable->klass()->external_name(), 1); set_depth(throwable(), 1); @@ -2486,14 +2486,14 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand RegisterMap::ProcessFrames::skip, RegisterMap::WalkContinuation::include); int decode_offset = 0; - CompiledMethod* nm = NULL; + CompiledMethod* nm = nullptr; bool skip_fillInStackTrace_check = false; bool skip_throwableInit_check = false; bool skip_hidden = !ShowHiddenFrames; bool show_carrier = ShowCarrierFrames; ContinuationEntry* cont_entry = thread->last_continuation(); for (frame fr = thread->last_frame(); max_depth == 0 || max_depth != total_count;) { - Method* method = NULL; + Method* method = nullptr; int bci = 0; // Compiled java method case. @@ -2527,14 +2527,14 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand fr = fr.sender(&map); } else { CodeBlob* cb = fr.cb(); - // HMMM QQQ might be nice to have frame return nm as NULL if cb is non-NULL + // HMMM QQQ might be nice to have frame return nm as null if cb is non-null // but non nmethod fr = fr.sender(&map); - if (cb == NULL || !cb->is_compiled()) { + if (cb == nullptr || !cb->is_compiled()) { continue; } nm = cb->as_compiled_method(); - assert(nm->method() != NULL, "must be"); + assert(nm->method() != nullptr, "must be"); if (nm->method()->is_native()) { method = nm->method(); bci = 0; @@ -2667,7 +2667,7 @@ void java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(Handle t // We support the Throwable immutability protocol defined for Java 7. java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace()); - assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized"); + assert(java_lang_Throwable::unassigned_stacktrace() != nullptr, "not initialized"); } void java_lang_Throwable::get_stack_trace_elements(int depth, Handle backtrace, @@ -2732,7 +2732,7 @@ Handle java_lang_Throwable::get_cause_with_stack_trace(Handle throwable, TRAPS) stringStream st; st.print("Exception %s%s ", throwable()->klass()->name()->as_klass_external_name(), message == nullptr ? "" : ":"); - if (message == NULL) { + if (message == nullptr) { st.print("[in thread \"%s\"]", THREAD->name()); } else { st.print("%s [in thread \"%s\"]", message->as_C_string(), THREAD->name()); @@ -2749,7 +2749,7 @@ Handle java_lang_Throwable::get_cause_with_stack_trace(Handle throwable, TRAPS) } java_lang_Throwable::set_stacktrace(h_cause(), stack_trace()); // Clear backtrace because the stacktrace should be used instead. - set_backtrace(h_cause(), NULL); + set_backtrace(h_cause(), nullptr); return h_cause; } @@ -2763,7 +2763,7 @@ bool java_lang_Throwable::get_top_method_and_bci(oop throwable, Method** method, // If the exception happened in a frame that has been hidden, i.e., // omitted from the back trace, we can not compute the message. oop hidden = ((objArrayOop)backtrace(throwable))->obj_at(trace_hidden_offset); - if (hidden != NULL) { + if (hidden != nullptr) { return false; } @@ -2771,11 +2771,11 @@ bool java_lang_Throwable::get_top_method_and_bci(oop throwable, Method** method, BacktraceElement bte = iter.next(current); InstanceKlass* holder = InstanceKlass::cast(java_lang_Class::as_Klass(bte._mirror())); - assert(holder != NULL, "first element should be non-null"); + assert(holder != nullptr, "first element should be non-null"); Method* m = holder->method_with_orig_idnum(bte._method_id, bte._version); // Original version is no longer available. - if (m == NULL || !version_matches(m, bte._version)) { + if (m == nullptr || !version_matches(m, bte._version)) { return false; } @@ -2787,7 +2787,7 @@ bool java_lang_Throwable::get_top_method_and_bci(oop throwable, Method** method, oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRAPS) { // Allocate java.lang.StackTraceElement instance InstanceKlass* k = vmClasses::StackTraceElement_klass(); - assert(k != NULL, "must be loaded in 1.4+"); + assert(k != nullptr, "must be loaded in 1.4+"); if (k->should_be_initialized()) { k->initialize(CHECK_NULL); } @@ -2814,9 +2814,9 @@ void java_lang_StackTraceElement::fill_in(Handle element, java_lang_StackTraceElement::set_declaringClassObject(element(), java_class()); oop loader = holder->class_loader(); - if (loader != NULL) { + if (loader != nullptr) { oop loader_name = java_lang_ClassLoader::name(loader); - if (loader_name != NULL) + if (loader_name != nullptr) java_lang_StackTraceElement::set_classLoaderName(element(), loader_name); } @@ -2830,17 +2830,17 @@ void java_lang_StackTraceElement::fill_in(Handle element, oop module_name = StringTable::intern(module->name(), CHECK); java_lang_StackTraceElement::set_moduleName(element(), module_name); oop module_version; - if (module->version() != NULL) { + if (module->version() != nullptr) { module_version = StringTable::intern(module->version(), CHECK); } else { - module_version = NULL; + module_version = nullptr; } java_lang_StackTraceElement::set_moduleVersion(element(), module_version); } - if (method() == NULL || !version_matches(method(), version)) { + if (method() == nullptr || !version_matches(method(), version)) { // The method was redefined, accurate line number information isn't available - java_lang_StackTraceElement::set_fileName(element(), NULL); + java_lang_StackTraceElement::set_fileName(element(), nullptr); java_lang_StackTraceElement::set_lineNumber(element(), -1); } else { Symbol* source; @@ -2864,17 +2864,17 @@ void java_lang_StackTraceElement::decode_file_and_line(Handle java_class, // Fill in source file name and line number. source = Backtrace::get_source_file_name(holder, version); source_file = java_lang_Class::source_file(java_class()); - if (source != NULL) { + if (source != nullptr) { // Class was not redefined. We can trust its cache if set, // else we have to initialize it. - if (source_file == NULL) { + if (source_file == nullptr) { source_file = StringTable::intern(source, CHECK); java_lang_Class::set_source_file(java_class(), source_file); } } else { // Class was redefined. Dump the cache if it was set. - if (source_file != NULL) { - source_file = NULL; + if (source_file != nullptr) { + source_file = nullptr; java_lang_Class::set_source_file(java_class(), source_file); } } @@ -2887,7 +2887,7 @@ void java_lang_StackTraceElement::decode(const methodHandle& method, int bci, ResourceMark rm(THREAD); HandleMark hm(THREAD); - filename = NULL; + filename = nullptr; line_number = -1; oop source_file; @@ -2947,7 +2947,7 @@ void java_lang_StackFrameInfo::set_method_and_bci(Handle stackFrame, const metho assert((jushort)version == version, "version should be short"); java_lang_StackFrameInfo::set_version(stackFrame(), (short)version); - oop contScope = cont_h() != NULL ? jdk_internal_vm_Continuation::scope(cont_h()) : (oop)NULL; + oop contScope = cont_h() != nullptr ? jdk_internal_vm_Continuation::scope(cont_h()) : (oop)nullptr; java_lang_StackFrameInfo::set_contScope(stackFrame(), contScope); } @@ -3330,7 +3330,7 @@ oop java_lang_reflect_RecordComponent::create(InstanceKlass* holder, RecordCompo // Allocate java.lang.reflect.RecordComponent instance HandleMark hm(THREAD); InstanceKlass* ik = vmClasses::RecordComponent_klass(); - assert(ik != NULL, "must be loaded"); + assert(ik != nullptr, "must be loaded"); ik->initialize(CHECK_NULL); Handle element = ik->allocate_instance_handle(CHECK_NULL); @@ -3347,7 +3347,7 @@ oop java_lang_reflect_RecordComponent::create(InstanceKlass* holder, RecordCompo SystemDictionary::find_java_mirror_for_type(type, holder, SignatureStream::NCDFError, CHECK_NULL); java_lang_reflect_RecordComponent::set_type(element(), component_type_h()); - Method* accessor_method = NULL; + Method* accessor_method = nullptr; { // Prepend "()" to type to create the full method signature. ResourceMark rm(THREAD); @@ -3358,12 +3358,12 @@ oop java_lang_reflect_RecordComponent::create(InstanceKlass* holder, RecordCompo accessor_method = holder->find_instance_method(name, full_sig, Klass::PrivateLookupMode::find); } - if (accessor_method != NULL) { + if (accessor_method != nullptr) { methodHandle method(THREAD, accessor_method); oop m = Reflection::new_method(method, false, CHECK_NULL); java_lang_reflect_RecordComponent::set_accessor(element(), m); } else { - java_lang_reflect_RecordComponent::set_accessor(element(), NULL); + java_lang_reflect_RecordComponent::set_accessor(element(), nullptr); } int sig_index = component->generic_signature_index(); @@ -3372,7 +3372,7 @@ oop java_lang_reflect_RecordComponent::create(InstanceKlass* holder, RecordCompo oop component_sig = StringTable::intern(sig, CHECK_NULL); java_lang_reflect_RecordComponent::set_signature(element(), component_sig); } else { - java_lang_reflect_RecordComponent::set_signature(element(), NULL); + java_lang_reflect_RecordComponent::set_signature(element(), nullptr); } typeArrayOop annotation_oop = Annotations::make_java_array(component->annotations(), CHECK_NULL); @@ -3513,7 +3513,7 @@ void java_lang_Module::set_name(oop module, oop value) { ModuleEntry* java_lang_Module::module_entry_raw(oop module) { assert(_module_entry_offset != 0, "Uninitialized module_entry_offset"); - assert(module != NULL, "module can't be null"); + assert(module != nullptr, "module can't be null"); assert(oopDesc::is_oop(module), "module must be oop"); ModuleEntry* module_entry = (ModuleEntry*)module->address_field(_module_entry_offset); @@ -3522,7 +3522,7 @@ ModuleEntry* java_lang_Module::module_entry_raw(oop module) { ModuleEntry* java_lang_Module::module_entry(oop module) { ModuleEntry* module_entry = module_entry_raw(module); - if (module_entry == NULL) { + if (module_entry == nullptr) { // If the inject field containing the ModuleEntry* is null then return the // class loader's unnamed module. oop loader = java_lang_Module::loader(module); @@ -3535,7 +3535,7 @@ ModuleEntry* java_lang_Module::module_entry(oop module) { void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) { assert(_module_entry_offset != 0, "Uninitialized module_entry_offset"); - assert(module != NULL, "module can't be null"); + assert(module != nullptr, "module can't be null"); assert(oopDesc::is_oop(module), "module must be oop"); module->address_field_put(_module_entry_offset, (address)module_entry); } @@ -3617,7 +3617,7 @@ void java_lang_ref_Reference::serialize_offsets(SerializeClosure* f) { #endif bool java_lang_ref_Reference::is_referent_field(oop obj, ptrdiff_t offset) { - assert(obj != NULL, "sanity"); + assert(obj != nullptr, "sanity"); if (offset != _referent_offset) { return false; } @@ -3654,7 +3654,7 @@ void java_lang_boxing_object::serialize_offsets(SerializeClosure* f) { oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) { Klass* k = vmClasses::box_klass(type); - if (k == NULL) return NULL; + if (k == nullptr) return nullptr; InstanceKlass* ik = InstanceKlass::cast(k); if (!ik->is_initialized()) { ik->initialize(CHECK_NULL); @@ -3665,7 +3665,7 @@ oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) { oop java_lang_boxing_object::create(BasicType type, jvalue* value, TRAPS) { oop box = initialize_and_allocate(type, CHECK_NULL); - if (box == NULL) return NULL; + if (box == nullptr) return nullptr; switch (type) { case T_BOOLEAN: box->bool_field_put(_value_offset, value->z); @@ -3692,14 +3692,14 @@ oop java_lang_boxing_object::create(BasicType type, jvalue* value, TRAPS) { box->long_field_put(_long_value_offset, value->j); break; default: - return NULL; + return nullptr; } return box; } BasicType java_lang_boxing_object::basic_type(oop box) { - if (box == NULL) return T_ILLEGAL; + if (box == nullptr) return T_ILLEGAL; BasicType type = vmClasses::box_klass_type(box->klass()); if (type == T_OBJECT) // 'unknown' value returned by SD::bkt return T_ILLEGAL; @@ -3832,7 +3832,7 @@ void java_lang_ref_SoftReference::set_clock(jlong value) { int java_lang_invoke_DirectMethodHandle::_member_offset; oop java_lang_invoke_DirectMethodHandle::member(oop dmh) { - oop member_name = NULL; + oop member_name = nullptr; assert(oopDesc::is_oop(dmh) && java_lang_invoke_DirectMethodHandle::is_instance(dmh), "a DirectMethodHandle oop is expected"); return dmh->obj_field(_member_offset); @@ -3906,7 +3906,7 @@ void java_lang_invoke_MemberName::serialize_offsets(SerializeClosure* f) { void java_lang_invoke_ResolvedMethodName::compute_offsets() { InstanceKlass* k = vmClasses::ResolvedMethodName_klass(); - assert(k != NULL, "jdk mismatch"); + assert(k != nullptr, "jdk mismatch"); RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); } @@ -3921,7 +3921,7 @@ void java_lang_invoke_ResolvedMethodName::serialize_offsets(SerializeClosure* f) void java_lang_invoke_LambdaForm::compute_offsets() { InstanceKlass* k = vmClasses::LambdaForm_klass(); - assert (k != NULL, "jdk mismatch"); + assert (k != nullptr, "jdk mismatch"); LAMBDAFORM_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3932,7 +3932,7 @@ void java_lang_invoke_LambdaForm::serialize_offsets(SerializeClosure* f) { #endif bool java_lang_invoke_LambdaForm::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } int jdk_internal_foreign_abi_NativeEntryPoint::_method_type_offset; @@ -3943,7 +3943,7 @@ int jdk_internal_foreign_abi_NativeEntryPoint::_downcall_stub_address_offset; macro(_downcall_stub_address_offset, k, "downcallStubAddress", long_signature, false); bool jdk_internal_foreign_abi_NativeEntryPoint::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } void jdk_internal_foreign_abi_NativeEntryPoint::compute_offsets() { @@ -3983,7 +3983,7 @@ int jdk_internal_foreign_abi_ABIDescriptor::_scratch2_offset; macro(_scratch2_offset, k, "scratch2", jdk_internal_foreign_abi_VMStorage_signature, false); bool jdk_internal_foreign_abi_ABIDescriptor::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } void jdk_internal_foreign_abi_ABIDescriptor::compute_offsets() { @@ -4037,7 +4037,7 @@ int jdk_internal_foreign_abi_VMStorage::_debugName_offset; macro(_debugName_offset, k, "debugName", string_signature, false); \ bool jdk_internal_foreign_abi_VMStorage::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } void jdk_internal_foreign_abi_VMStorage::compute_offsets() { @@ -4075,7 +4075,7 @@ int jdk_internal_foreign_abi_CallConv::_retRegs_offset; macro(_retRegs_offset, k, "retRegs", jdk_internal_foreign_abi_VMStorage_array_signature, false); \ bool jdk_internal_foreign_abi_CallConv::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } void jdk_internal_foreign_abi_CallConv::compute_offsets() { @@ -4162,7 +4162,7 @@ void java_lang_invoke_MemberName::set_flags(oop mname, int flags) { Method* java_lang_invoke_MemberName::vmtarget(oop mname) { assert(is_instance(mname), "wrong type"); oop method = mname->obj_field(_method_offset); - return method == NULL ? NULL : java_lang_invoke_ResolvedMethodName::vmtarget(method); + return method == nullptr ? nullptr : java_lang_invoke_ResolvedMethodName::vmtarget(method); } bool java_lang_invoke_MemberName::is_method(oop mname) { @@ -4209,7 +4209,7 @@ oop java_lang_invoke_ResolvedMethodName::find_resolved_method(const methodHandle // lookup ResolvedMethod oop in the table, or create a new one and intern it oop resolved_method = ResolvedMethodTable::find_method(method); - if (resolved_method != NULL) { + if (resolved_method != nullptr) { return resolved_method; } @@ -4272,19 +4272,19 @@ void java_lang_invoke_MethodType::serialize_offsets(SerializeClosure* f) { void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) { st->print("("); objArrayOop pts = ptypes(mt); - if (pts != NULL) { + if (pts != nullptr) { for (int i = 0, limit = pts->length(); i < limit; i++) { java_lang_Class::print_signature(pts->obj_at(i), st); } } else { - st->print("NULL"); + st->print("null"); } st->print(")"); oop rt = rtype(mt); - if (rt != NULL) { + if (rt != nullptr) { java_lang_Class::print_signature(rt, st); } else { - st->print("NULL"); + st->print("null"); } } @@ -4472,19 +4472,19 @@ int java_lang_ClassLoader::_unnamedModule_offset; int java_lang_ClassLoader::_parent_offset; ClassLoaderData* java_lang_ClassLoader::loader_data_acquire(oop loader) { - assert(loader != NULL, "loader must not be NULL"); + assert(loader != nullptr, "loader must not be null"); assert(oopDesc::is_oop(loader), "loader must be oop"); return Atomic::load_acquire(loader->field_addr(_loader_data_offset)); } ClassLoaderData* java_lang_ClassLoader::loader_data(oop loader) { - assert(loader != NULL, "loader must not be NULL"); + assert(loader != nullptr, "loader must not be null"); assert(oopDesc::is_oop(loader), "loader must be oop"); return *loader->field_addr(_loader_data_offset); } void java_lang_ClassLoader::release_set_loader_data(oop loader, ClassLoaderData* new_data) { - assert(loader != NULL, "loader must not be NULL"); + assert(loader != nullptr, "loader must not be null"); assert(oopDesc::is_oop(loader), "loader must be oop"); Atomic::release_store(loader->field_addr(_loader_data_offset), new_data); } @@ -4540,7 +4540,7 @@ oop java_lang_ClassLoader::nameAndId(oop loader) { bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) { assert(is_instance(loader), "loader must be oop"); - assert(cl == NULL || is_instance(cl), "cl argument must be oop"); + assert(cl == nullptr || is_instance(cl), "cl argument must be oop"); oop acl = loader; debug_only(jint loop_count = 0); // This loop taken verbatim from ClassLoader.java: @@ -4550,12 +4550,12 @@ bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) { return true; } assert(++loop_count > 0, "loop_count overflow"); - } while (acl != NULL); + } while (acl != nullptr); return false; } bool java_lang_ClassLoader::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } @@ -4564,7 +4564,7 @@ bool java_lang_ClassLoader::is_instance(oop obj) { // Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it bool java_lang_ClassLoader::parallelCapable(oop class_loader) { assert(_parallelCapable_offset != 0, "offsets should have been initialized"); - return (class_loader->obj_field(_parallelCapable_offset) != NULL); + return (class_loader->obj_field(_parallelCapable_offset) != nullptr); } bool java_lang_ClassLoader::is_trusted_loader(oop loader) { @@ -4572,7 +4572,7 @@ bool java_lang_ClassLoader::is_trusted_loader(oop loader) { loader = non_reflection_class_loader(loader); oop cl = SystemDictionary::java_system_loader(); - while(cl != NULL) { + while(cl != nullptr) { if (cl == loader) return true; cl = parent(cl); } @@ -4582,10 +4582,10 @@ bool java_lang_ClassLoader::is_trusted_loader(oop loader) { // Return true if this is one of the class loaders associated with // the generated bytecodes for reflection. bool java_lang_ClassLoader::is_reflection_class_loader(oop loader) { - if (loader != NULL) { + if (loader != nullptr) { Klass* delegating_cl_class = vmClasses::reflect_DelegatingClassLoader_klass(); // This might be null in non-1.4 JDKs - return (delegating_cl_class != NULL && loader->is_a(delegating_cl_class)); + return (delegating_cl_class != nullptr && loader->is_a(delegating_cl_class)); } return false; } @@ -4646,7 +4646,7 @@ bool java_lang_System::allow_security_manager() { // This field tells us that a security manager is installed. bool java_lang_System::has_security_manager() { oop base = vmClasses::System_klass()->static_field_base_raw(); - return base->obj_field(_static_security_offset) != NULL; + return base->obj_field(_static_security_offset) != nullptr; } #if INCLUDE_CDS @@ -4676,7 +4676,7 @@ public: void do_field(fieldDescriptor* fd) { oop mirror = fd->field_holder()->java_mirror(); - assert(mirror != NULL, "UnsafeConstants must have mirror already"); + assert(mirror != nullptr, "UnsafeConstants must have mirror already"); assert(fd->field_holder() == vmClasses::UnsafeConstants_klass(), "Should be UnsafeConstants"); assert(fd->is_final(), "fields of UnsafeConstants must be final"); assert(fd->is_static(), "fields of UnsafeConstants must be static"); @@ -4857,7 +4857,7 @@ void vector_VectorPayload::set_payload(oop o, oop val) { } bool vector_VectorPayload::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } int java_lang_Integer_IntegerCache::_static_cache_offset; @@ -4870,7 +4870,7 @@ int java_lang_Byte_ByteCache::_static_cache_offset; macro(_static_cache_offset, k, "cache", java_lang_Integer_array_signature, true) void java_lang_Integer_IntegerCache::compute_offsets(InstanceKlass *k) { - guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized"); + guarantee(k != nullptr && k->is_initialized(), "must be loaded and initialized"); INTEGER_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4900,7 +4900,7 @@ jint java_lang_Integer::value(oop obj) { macro(_static_cache_offset, k, "cache", java_lang_Long_array_signature, true) void java_lang_Long_LongCache::compute_offsets(InstanceKlass *k) { - guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized"); + guarantee(k != nullptr && k->is_initialized(), "must be loaded and initialized"); LONG_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4930,7 +4930,7 @@ jlong java_lang_Long::value(oop obj) { macro(_static_cache_offset, k, "cache", java_lang_Character_array_signature, true) void java_lang_Character_CharacterCache::compute_offsets(InstanceKlass *k) { - guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized"); + guarantee(k != nullptr && k->is_initialized(), "must be loaded and initialized"); CHARACTER_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4960,7 +4960,7 @@ jchar java_lang_Character::value(oop obj) { macro(_static_cache_offset, k, "cache", java_lang_Short_array_signature, true) void java_lang_Short_ShortCache::compute_offsets(InstanceKlass *k) { - guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized"); + guarantee(k != nullptr && k->is_initialized(), "must be loaded and initialized"); SHORT_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4990,7 +4990,7 @@ jshort java_lang_Short::value(oop obj) { macro(_static_cache_offset, k, "cache", java_lang_Byte_array_signature, true) void java_lang_Byte_ByteCache::compute_offsets(InstanceKlass *k) { - guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized"); + guarantee(k != nullptr && k->is_initialized(), "must be loaded and initialized"); BYTE_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -5025,7 +5025,7 @@ int java_lang_Boolean::_static_FALSE_offset; void java_lang_Boolean::compute_offsets(InstanceKlass *k) { - guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized"); + guarantee(k != nullptr && k->is_initialized(), "must be loaded and initialized"); BOOLEAN_FIELDS_DO(FIELD_COMPUTE_OFFSET); } diff --git a/src/hotspot/share/classfile/javaClasses.hpp b/src/hotspot/share/classfile/javaClasses.hpp index 9c0a77b06e3..f02ca41a0f1 100644 --- a/src/hotspot/share/classfile/javaClasses.hpp +++ b/src/hotspot/share/classfile/javaClasses.hpp @@ -268,7 +268,7 @@ class java_lang_Class : AllStatic { // Conversion static Klass* as_Klass(oop java_class); static void set_klass(oop java_class, Klass* klass); - static BasicType as_BasicType(oop java_class, Klass** reference_klass = NULL); + static BasicType as_BasicType(oop java_class, Klass** reference_klass = nullptr); static Symbol* as_signature(oop java_class, bool intern_if_not_found); static void print_signature(oop java_class, outputStream *st); static const char* as_external_name(oop java_class); @@ -911,7 +911,7 @@ class java_lang_boxing_object: AllStatic { static void compute_offsets(); static oop initialize_and_allocate(BasicType type, TRAPS); public: - // Allocation. Returns a boxed value, or NULL for invalid type. + // Allocation. Returns a boxed value, or null for invalid type. static oop create(BasicType type, jvalue* value, TRAPS); // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. static BasicType get_value(oop box, jvalue* value); @@ -1072,7 +1072,7 @@ class java_lang_invoke_LambdaForm: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return vmClasses::LambdaForm_klass() != NULL && + return vmClasses::LambdaForm_klass() != nullptr && klass->is_subclass_of(vmClasses::LambdaForm_klass()); } static bool is_instance(oop obj); @@ -1102,7 +1102,7 @@ class jdk_internal_foreign_abi_NativeEntryPoint: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return vmClasses::NativeEntryPoint_klass() != NULL && + return vmClasses::NativeEntryPoint_klass() != nullptr && klass->is_subclass_of(vmClasses::NativeEntryPoint_klass()); } static bool is_instance(oop obj); @@ -1140,7 +1140,7 @@ class jdk_internal_foreign_abi_ABIDescriptor: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return vmClasses::ABIDescriptor_klass() != NULL && + return vmClasses::ABIDescriptor_klass() != nullptr && klass->is_subclass_of(vmClasses::ABIDescriptor_klass()); } static bool is_instance(oop obj); @@ -1168,7 +1168,7 @@ class jdk_internal_foreign_abi_VMStorage: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return vmClasses::VMStorage_klass() != NULL && + return vmClasses::VMStorage_klass() != nullptr && klass->is_subclass_of(vmClasses::VMStorage_klass()); } static bool is_instance(oop obj); @@ -1192,7 +1192,7 @@ class jdk_internal_foreign_abi_CallConv: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return vmClasses::CallConv_klass() != NULL && + return vmClasses::CallConv_klass() != nullptr && klass->is_subclass_of(vmClasses::CallConv_klass()); } static bool is_instance(oop obj); diff --git a/src/hotspot/share/classfile/javaClasses.inline.hpp b/src/hotspot/share/classfile/javaClasses.inline.hpp index 386f3094279..960d5d224c5 100644 --- a/src/hotspot/share/classfile/javaClasses.inline.hpp +++ b/src/hotspot/share/classfile/javaClasses.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, 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 @@ -108,7 +108,7 @@ int java_lang_String::length(oop java_string, typeArrayOop value) { assert(is_instance(java_string), "must be java_string"); assert(value_equals(value, java_lang_String::value(java_string)), "value must be equal to java_lang_String::value(java_string)"); - if (value == NULL) { + if (value == nullptr) { return 0; } int arr_length = value->length(); @@ -127,7 +127,7 @@ int java_lang_String::length(oop java_string) { } bool java_lang_String::is_instance(oop obj) { - return obj != NULL && obj->klass() == vmClasses::String_klass(); + return obj != nullptr && obj->klass() == vmClasses::String_klass(); } // Accessors @@ -248,7 +248,7 @@ inline void java_lang_invoke_CallSite::set_target(oop site, oop target) { } inline bool java_lang_invoke_CallSite::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } inline jboolean java_lang_invoke_ConstantCallSite::is_frozen(oop site) { @@ -256,50 +256,50 @@ inline jboolean java_lang_invoke_ConstantCallSite::is_frozen(oop site) { } inline bool java_lang_invoke_ConstantCallSite::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } inline bool java_lang_invoke_MethodHandleNatives_CallSiteContext::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } inline bool java_lang_invoke_MemberName::is_instance(oop obj) { - return obj != NULL && obj->klass() == vmClasses::MemberName_klass(); + return obj != nullptr && obj->klass() == vmClasses::MemberName_klass(); } inline bool java_lang_invoke_ResolvedMethodName::is_instance(oop obj) { - return obj != NULL && obj->klass() == vmClasses::ResolvedMethodName_klass(); + return obj != nullptr && obj->klass() == vmClasses::ResolvedMethodName_klass(); } inline bool java_lang_invoke_MethodType::is_instance(oop obj) { - return obj != NULL && obj->klass() == vmClasses::MethodType_klass(); + return obj != nullptr && obj->klass() == vmClasses::MethodType_klass(); } inline bool java_lang_invoke_MethodHandle::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } inline bool java_lang_Class::is_instance(oop obj) { - return obj != NULL && obj->klass() == vmClasses::Class_klass(); + return obj != nullptr && obj->klass() == vmClasses::Class_klass(); } inline Klass* java_lang_Class::as_Klass(oop java_class) { //%note memory_2 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); Klass* k = ((Klass*)java_class->metadata_field(_klass_offset)); - assert(k == NULL || k->is_klass(), "type check"); + assert(k == nullptr || k->is_klass(), "type check"); return k; } inline bool java_lang_Class::is_primitive(oop java_class) { // should assert: //assert(java_lang_Class::is_instance(java_class), "must be a Class object"); - bool is_primitive = (java_class->metadata_field(_klass_offset) == NULL); + bool is_primitive = (java_class->metadata_field(_klass_offset) == nullptr); #ifdef ASSERT if (is_primitive) { Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset)); - assert(k == NULL || is_java_primitive(ArrayKlass::cast(k)->element_type()), + assert(k == nullptr || is_java_primitive(ArrayKlass::cast(k)->element_type()), "Should be either the T_VOID primitive or a java primitive"); } #endif @@ -315,11 +315,11 @@ inline size_t java_lang_Class::oop_size(oop java_class) { } inline bool java_lang_invoke_DirectMethodHandle::is_instance(oop obj) { - return obj != NULL && is_subclass(obj->klass()); + return obj != nullptr && is_subclass(obj->klass()); } inline bool java_lang_Module::is_instance(oop obj) { - return obj != NULL && obj->klass() == vmClasses::Module_klass(); + return obj != nullptr && obj->klass() == vmClasses::Module_klass(); } inline int Backtrace::merge_bci_and_version(int bci, int version) { @@ -373,7 +373,7 @@ inline Symbol* Backtrace::get_source_file_name(InstanceKlass* holder, int versio // the source_file_name_index for any older constant pool version // to be unstable so we shouldn't try to use it. if (holder->constants()->version() != version) { - return NULL; + return nullptr; } else { return holder->source_file_name(); } diff --git a/src/hotspot/share/classfile/klassFactory.cpp b/src/hotspot/share/classfile/klassFactory.cpp index eba09c7016b..420587dd78c 100644 --- a/src/hotspot/share/classfile/klassFactory.cpp +++ b/src/hotspot/share/classfile/klassFactory.cpp @@ -51,13 +51,13 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook( const ClassFileStream *cfs, TRAPS) { #if INCLUDE_CDS && INCLUDE_JVMTI - assert(ik != NULL, "sanity"); + assert(ik != nullptr, "sanity"); assert(ik->is_shared(), "expecting a shared class"); if (JvmtiExport::should_post_class_file_load_hook()) { // Post the CFLH - JvmtiCachedClassFileData* cached_class_file = NULL; - if (cfs == NULL) { + JvmtiCachedClassFileData* cached_class_file = nullptr; + if (cfs == nullptr) { cfs = FileMapInfo::open_stream_for_jvmti(ik, class_loader, CHECK_NULL); } unsigned char* ptr = (unsigned char*)cfs->buffer(); @@ -91,7 +91,7 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook( *cl_inst_info, // dynamic_nest_host and classData CHECK_NULL); - if (cached_class_file != NULL) { + if (cached_class_file != nullptr) { new_ik->set_cached_class_file(cached_class_file); } @@ -104,7 +104,7 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook( } #endif - return NULL; + return nullptr; } @@ -115,7 +115,7 @@ static ClassFileStream* check_class_file_load_hook(ClassFileStream* stream, JvmtiCachedClassFileData** cached_class_file, TRAPS) { - assert(stream != NULL, "invariant"); + assert(stream != nullptr, "invariant"); if (JvmtiExport::should_post_class_file_load_hook()) { const JavaThread* jt = THREAD; @@ -133,9 +133,9 @@ static ClassFileStream* check_class_file_load_hook(ClassFileStream* stream, JvmtiThreadState* state = jt->jvmti_thread_state(); - if (state != NULL) { + if (state != nullptr) { Klass* k = state->get_class_being_redefined(); - if (k != NULL && state->get_class_load_kind() == jvmti_class_load_kind_retransform) { + if (k != nullptr && state->get_class_load_kind() == jvmti_class_load_kind_retransform) { InstanceKlass* class_being_redefined = InstanceKlass::cast(k); *cached_class_file = class_being_redefined->get_cached_class_file(); } @@ -170,13 +170,13 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream, ClassLoaderData* loader_data, const ClassLoadInfo& cl_info, TRAPS) { - assert(stream != NULL, "invariant"); - assert(loader_data != NULL, "invariant"); + assert(stream != nullptr, "invariant"); + assert(loader_data != nullptr, "invariant"); ResourceMark rm(THREAD); HandleMark hm(THREAD); - JvmtiCachedClassFileData* cached_class_file = NULL; + JvmtiCachedClassFileData* cached_class_file = nullptr; ClassFileStream* old_stream = stream; @@ -202,9 +202,9 @@ InstanceKlass* KlassFactory::create_from_stream(ClassFileStream* stream, const ClassInstanceInfo* cl_inst_info = cl_info.class_hidden_info_ptr(); InstanceKlass* result = parser.create_instance_klass(old_stream != stream, *cl_inst_info, CHECK_NULL); - assert(result != NULL, "result cannot be null with no pending exception"); + assert(result != nullptr, "result cannot be null with no pending exception"); - if (cached_class_file != NULL) { + if (cached_class_file != nullptr) { // JVMTI: we have an InstanceKlass now, tell it about the cached bytes result->set_cached_class_file(cached_class_file); } diff --git a/src/hotspot/share/classfile/klassFactory.hpp b/src/hotspot/share/classfile/klassFactory.hpp index b1584b3e2ca..9a64023572b 100644 --- a/src/hotspot/share/classfile/klassFactory.hpp +++ b/src/hotspot/share/classfile/klassFactory.hpp @@ -43,17 +43,17 @@ class Symbol; * Output: a VM runtime representation of a Java class * * Pre-conditions: - * a non-NULL ClassFileStream* // the classfile bytestream - * a non-NULL Symbol* // the name of the class - * a non-NULL ClassLoaderData* // the metaspace allocator + * a non-null ClassFileStream* // the classfile bytestream + * a non-null Symbol* // the name of the class + * a non-null ClassLoaderData* // the metaspace allocator * (no pending exceptions) * * Returns: - * if the returned value is non-NULL, that value is an indirection (pointer/handle) + * if the returned value is non-null, that value is an indirection (pointer/handle) * to a Klass. The caller will not have a pending exception. * * On broken invariants and/or runtime errors the returned value will be - * NULL (or a NULL handle) and the caller *might* now have a pending exception. + * null (or a null handle) and the caller *might* now have a pending exception. * */ diff --git a/src/hotspot/share/classfile/loaderConstraints.cpp b/src/hotspot/share/classfile/loaderConstraints.cpp index 32ac2e07d00..a4b327edee4 100644 --- a/src/hotspot/share/classfile/loaderConstraints.cpp +++ b/src/hotspot/share/classfile/loaderConstraints.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -118,12 +118,12 @@ void LoaderConstraint::extend_loader_constraint(Symbol* class_name, lt.print("extending constraint for name %s by adding loader: %s %s", class_name->as_C_string(), loader->loader_name_and_id(), - _klass == NULL ? " and setting class object" : ""); + _klass == nullptr ? " and setting class object" : ""); } - if (_klass == NULL) { + if (_klass == nullptr) { set_klass(klass); } else { - assert(klass == NULL || _klass == klass, "constraints corrupted"); + assert(klass == nullptr || _klass == klass, "constraints corrupted"); } } @@ -181,9 +181,9 @@ class PurgeUnloadedConstraints : public StackObj { LoaderConstraint* probe = set.constraint_at(i); InstanceKlass* klass = probe->klass(); // Remove klass that is no longer alive - if (klass != NULL && + if (klass != nullptr && !klass->is_loader_alive()) { - probe->set_klass(NULL); + probe->set_klass(nullptr); if (lt.is_enabled()) { ResourceMark rm; lt.print("purging class object from constraint for name %s," @@ -228,7 +228,7 @@ class PurgeUnloadedConstraints : public StackObj { set.remove_constraint(probe); } else { #ifdef ASSERT - if (probe->klass() != NULL) { + if (probe->klass() != nullptr) { assert(probe->klass()->is_loader_alive(), "klass should be live"); } #endif @@ -268,7 +268,7 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, InstanceKlass* klass2, ClassLoaderData* loader2) { LogTarget(Info, class, loader, constraints) lt; - if (klass1 != NULL && klass2 != NULL) { + if (klass1 != nullptr && klass2 != nullptr) { if (klass1 == klass2) { // Same type already loaded in both places. There is no need for any constraint. return true; @@ -281,10 +281,10 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, } } - InstanceKlass* klass = klass1 != NULL ? klass1 : klass2; + InstanceKlass* klass = klass1 != nullptr ? klass1 : klass2; LoaderConstraint* pp1 = find_loader_constraint(class_name, loader1); - if (pp1 != NULL && pp1->klass() != NULL) { - if (klass != NULL) { + if (pp1 != nullptr && pp1->klass() != nullptr) { + if (klass != nullptr) { if (klass != pp1->klass()) { log_ldr_constraint_msg(class_name, "The class object presented by loader[0] does not match " @@ -298,8 +298,8 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, } LoaderConstraint* pp2 = find_loader_constraint(class_name, loader2); - if (pp2 != NULL && pp2->klass() != NULL) { - if (klass != NULL) { + if (pp2 != nullptr && pp2->klass() != nullptr) { + if (klass != nullptr) { if (klass != pp2->klass()) { log_ldr_constraint_msg(class_name, "The class object presented by loader[1] does not match " @@ -312,7 +312,7 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, } } - if (pp1 == NULL && pp2 == NULL) { + if (pp1 == nullptr && pp2 == nullptr) { add_loader_constraint(class_name, klass, loader1, loader2); if (lt.is_enabled()) { @@ -325,7 +325,7 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, } } else if (pp1 == pp2) { /* constraint already imposed */ - if (pp1->klass() == NULL) { + if (pp1->klass() == nullptr) { pp1->set_klass(klass); if (lt.is_enabled()) { ResourceMark rm; @@ -337,9 +337,9 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, } else { assert(pp1->klass() == klass, "loader constraints corrupted"); } - } else if (pp1 == NULL) { + } else if (pp1 == nullptr) { pp2->extend_loader_constraint(class_name, loader1, klass); - } else if (pp2 == NULL) { + } else if (pp2 == nullptr) { pp1->extend_loader_constraint(class_name, loader1, klass); } else { merge_loader_constraints(class_name, pp1, pp2, klass); @@ -355,7 +355,7 @@ bool LoaderConstraintTable::check_or_update(InstanceKlass* k, Symbol* name) { LogTarget(Info, class, loader, constraints) lt; LoaderConstraint* p = find_loader_constraint(name, loader); - if (p && p->klass() != NULL && p->klass() != k) { + if (p && p->klass() != nullptr && p->klass() != k) { if (lt.is_enabled()) { ResourceMark rm; lt.print("constraint check failed for name %s, loader %s: " @@ -365,7 +365,7 @@ bool LoaderConstraintTable::check_or_update(InstanceKlass* k, } return false; } else { - if (p && p->klass() == NULL) { + if (p && p->klass() == nullptr) { p->set_klass(k); if (lt.is_enabled()) { ResourceMark rm; @@ -382,18 +382,18 @@ bool LoaderConstraintTable::check_or_update(InstanceKlass* k, InstanceKlass* LoaderConstraintTable::find_constrained_klass(Symbol* name, ClassLoaderData* loader) { LoaderConstraint *p = find_loader_constraint(name, loader); - if (p != NULL && p->klass() != NULL) { + if (p != nullptr && p->klass() != nullptr) { assert(p->klass()->is_instance_klass(), "sanity"); if (!p->klass()->is_loaded()) { // Only return fully loaded classes. Classes found through the // constraints might still be in the process of loading. - return NULL; + return nullptr; } return p->klass(); } // No constraints, or else no klass loaded yet. - return NULL; + return nullptr; } void LoaderConstraintTable::merge_loader_constraints(Symbol* class_name, @@ -418,20 +418,20 @@ void LoaderConstraintTable::merge_loader_constraints(Symbol* class_name, for (int i = 0; i < dest->num_loaders(); i++) { lt.print(" [%d]: %s", i, dest->loader_data(i)->loader_name_and_id()); } - if (dest->klass() == NULL) { + if (dest->klass() == nullptr) { lt.print("... and setting class object"); } } - // dest->klass() will hold NULL if klass, src->klass(), and old - // dest->klass() are all NULL. In addition, all three must have - // matching non-NULL values, otherwise either the constraints would + // dest->klass() will hold null if klass, src->klass(), and old + // dest->klass() are all null. In addition, all three must have + // matching non-null values, otherwise either the constraints would // have been violated, or the constraints had been corrupted (and an // assertion would fail). - if (src->klass() != NULL) { + if (src->klass() != nullptr) { assert(src->klass() == klass, "constraints corrupted"); } - if (dest->klass() == NULL) { + if (dest->klass() == nullptr) { dest->set_klass(klass); } else { assert(dest->klass() == klass, "constraints corrupted"); @@ -449,14 +449,14 @@ void LoaderConstraintTable::verify() { int len = set.num_constraints(); for (int i = 0; i < len; i++) { LoaderConstraint* probe = set.constraint_at(i); - if (probe->klass() != NULL) { + if (probe->klass() != nullptr) { InstanceKlass* ik = probe->klass(); guarantee(key == ik->name(), "name should match"); Symbol* name = ik->name(); ClassLoaderData* loader_data = ik->class_loader_data(); Dictionary* dictionary = loader_data->dictionary(); InstanceKlass* k = dictionary->find_class(thread, name); - if (k != NULL) { + if (k != nullptr) { // We found the class in the dictionary, so we should // make sure that the Klass* matches what we already have. guarantee(k == probe->klass(), "klass should be in dictionary"); @@ -468,7 +468,7 @@ void LoaderConstraintTable::verify() { // The InstanceKlass might not be on the entry, so the only // thing we can check here is whether we were successful in // finding the class in the placeholders table. - guarantee(entry != NULL, "klass should be in the placeholders"); + guarantee(entry != nullptr, "klass should be in the placeholders"); } } for (int n = 0; n< probe->num_loaders(); n++) { diff --git a/src/hotspot/share/classfile/metadataOnStackMark.cpp b/src/hotspot/share/classfile/metadataOnStackMark.cpp index 57c258f7666..faf1053dd87 100644 --- a/src/hotspot/share/classfile/metadataOnStackMark.cpp +++ b/src/hotspot/share/classfile/metadataOnStackMark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, 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 @@ -36,10 +36,10 @@ #include "jvmci/jvmci.hpp" #endif -MetadataOnStackBuffer* MetadataOnStackMark::_used_buffers = NULL; -MetadataOnStackBuffer* MetadataOnStackMark::_free_buffers = NULL; +MetadataOnStackBuffer* MetadataOnStackMark::_used_buffers = nullptr; +MetadataOnStackBuffer* MetadataOnStackMark::_free_buffers = nullptr; -MetadataOnStackBuffer* MetadataOnStackMark::_current_buffer = NULL; +MetadataOnStackBuffer* MetadataOnStackMark::_current_buffer = nullptr; NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;) class MetadataOnStackClosure : public MetadataClosure { @@ -52,7 +52,7 @@ class MetadataOnStackClosure : public MetadataClosure { // in metadata Handles. MetadataOnStackMark::MetadataOnStackMark(bool walk_all_metadata, bool redefinition_walk) { assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); - assert(_used_buffers == NULL, "sanity check"); + assert(_used_buffers == nullptr, "sanity check"); assert(!_is_active, "MetadataOnStackMarks do not nest"); assert(!redefinition_walk || walk_all_metadata, "walk_all_metadata must be true for redefinition_walk"); @@ -85,7 +85,7 @@ MetadataOnStackMark::~MetadataOnStackMark() { retire_current_buffer(); MetadataOnStackBuffer* buffer = _used_buffers; - while (buffer != NULL) { + while (buffer != nullptr) { // Clear on stack state for all metadata. size_t size = buffer->size(); for (size_t i = 0; i < size; i++) { @@ -97,7 +97,7 @@ MetadataOnStackMark::~MetadataOnStackMark() { // Move the buffer to the free list. buffer->clear(); - buffer->set_next_used(NULL); + buffer->set_next_used(nullptr); buffer->set_next_free(_free_buffers); _free_buffers = buffer; @@ -105,13 +105,13 @@ MetadataOnStackMark::~MetadataOnStackMark() { buffer = next; } - _used_buffers = NULL; + _used_buffers = nullptr; NOT_PRODUCT(_is_active = false;) } void MetadataOnStackMark::retire_buffer(MetadataOnStackBuffer* buffer) { - if (buffer == NULL) { + if (buffer == nullptr) { return; } buffer->set_next_used(_used_buffers); @@ -121,18 +121,18 @@ void MetadataOnStackMark::retire_buffer(MetadataOnStackBuffer* buffer) { // Current buffer is full or we're ready to walk them, add it to the used list. void MetadataOnStackMark::retire_current_buffer() { retire_buffer(_current_buffer); - _current_buffer = NULL; + _current_buffer = nullptr; } // Get buffer off free list. MetadataOnStackBuffer* MetadataOnStackMark::allocate_buffer() { MetadataOnStackBuffer* allocated = _free_buffers; - if (allocated != NULL) { + if (allocated != nullptr) { _free_buffers = allocated->next_free(); } - if (allocated == NULL) { + if (allocated == nullptr) { allocated = new MetadataOnStackBuffer(); } @@ -147,12 +147,12 @@ void MetadataOnStackMark::record(Metadata* m) { MetadataOnStackBuffer* buffer = _current_buffer; - if (buffer != NULL && buffer->is_full()) { + if (buffer != nullptr && buffer->is_full()) { retire_buffer(buffer); - buffer = NULL; + buffer = nullptr; } - if (buffer == NULL) { + if (buffer == nullptr) { buffer = allocate_buffer(); _current_buffer = buffer; } diff --git a/src/hotspot/share/classfile/moduleEntry.cpp b/src/hotspot/share/classfile/moduleEntry.cpp index 28f865be2aa..b636976d096 100644 --- a/src/hotspot/share/classfile/moduleEntry.cpp +++ b/src/hotspot/share/classfile/moduleEntry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -47,7 +47,7 @@ #include "utilities/quickSort.hpp" #include "utilities/resourceHash.hpp" -ModuleEntry* ModuleEntryTable::_javabase_module = NULL; +ModuleEntry* ModuleEntryTable::_javabase_module = nullptr; oop ModuleEntry::module() const { return _module.resolve(); } @@ -58,7 +58,7 @@ void ModuleEntry::set_location(Symbol* location) { _location = location; - if (location != NULL) { + if (location != nullptr) { location->increment_refcount(); CDS_ONLY(if (UseSharedSpaces) { _shared_path_index = FileMapInfo::get_module_shared_path_index(location); @@ -76,9 +76,9 @@ void ModuleEntry::set_location(Symbol* location) { // and its version is the same as module java.base's version // The above check is imprecise but should work in almost all cases. bool ModuleEntry::should_show_version() { - if (version() == NULL || !is_named()) return false; + if (version() == nullptr || !is_named()) return false; - if (location() != NULL) { + if (location() != nullptr) { ResourceMark rm; const char* loc = location()->as_C_string(); ClassLoaderData* cld = loader_data(); @@ -121,7 +121,7 @@ void ModuleEntry::set_shared_protection_domain(ClassLoaderData *loader_data, // Returns true if this module can read module m bool ModuleEntry::can_read(ModuleEntry* m) const { - assert(m != NULL, "No module to lookup in this module's reads list"); + assert(m != nullptr, "No module to lookup in this module's reads list"); // Unnamed modules read everyone and all modules // read java.base. If either of these conditions @@ -160,10 +160,10 @@ void ModuleEntry::add_read(ModuleEntry* m) { } MutexLocker m1(Module_lock); - if (m == NULL) { + if (m == nullptr) { set_can_read_all_unnamed(); } else { - if (_reads == NULL) { + if (_reads == nullptr) { // Lazily create a module's reads list _reads = new (mtModule) GrowableArray(MODULE_READS_SIZE, mtModule); } @@ -192,7 +192,7 @@ void ModuleEntry::set_read_walk_required(ClassLoaderData* m_loader_data) { if (log_is_enabled(Trace, module)) { ResourceMark rm; log_trace(module)("ModuleEntry::set_read_walk_required(): module %s reads list must be walked", - (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE); + (name() != nullptr) ? name()->as_C_string() : UNNAMED_MODULE); } } } @@ -207,7 +207,7 @@ void ModuleEntry::set_is_open(bool is_open) { // module will return false. bool ModuleEntry::has_reads_list() const { assert_locked_or_safepoint(Module_lock); - return ((_reads != NULL) && !_reads->is_empty()); + return ((_reads != nullptr) && !_reads->is_empty()); } // Purge dead module entries out of reads list. @@ -222,7 +222,7 @@ void ModuleEntry::purge_reads() { if (log_is_enabled(Trace, module)) { ResourceMark rm; log_trace(module)("ModuleEntry::purge_reads(): module %s reads list being walked", - (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE); + (name() != nullptr) ? name()->as_C_string() : UNNAMED_MODULE); } // Go backwards because this removes entries that are dead. @@ -242,7 +242,7 @@ void ModuleEntry::purge_reads() { void ModuleEntry::module_reads_do(ModuleClosure* f) { assert_locked_or_safepoint(Module_lock); - assert(f != NULL, "invariant"); + assert(f != nullptr, "invariant"); if (has_reads_list()) { int reads_len = _reads->length(); @@ -254,7 +254,7 @@ void ModuleEntry::module_reads_do(ModuleClosure* f) { void ModuleEntry::delete_reads() { delete _reads; - _reads = NULL; + _reads = nullptr; } ModuleEntry::ModuleEntry(Handle module_handle, @@ -295,7 +295,7 @@ ModuleEntry::ModuleEntry(Handle module_handle, if (log_is_enabled(Trace, module, patch)) { ResourceMark rm; log_trace(module, patch)("Marked module %s as patched from --patch-module", - name != NULL ? name->as_C_string() : UNNAMED_MODULE); + name != nullptr ? name->as_C_string() : UNNAMED_MODULE); } } @@ -335,7 +335,7 @@ ModuleEntry* ModuleEntry::create_boot_unnamed_module(ClassLoaderData* cld) { // is not known until a call to JVM_SetBootLoaderUnnamedModule is made. At // this point initially create the ModuleEntry for the unnamed module. ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(), cld); - assert(unnamed_module != NULL, "boot loader unnamed module should not be null"); + assert(unnamed_module != nullptr, "boot loader unnamed module should not be null"); return unnamed_module; } @@ -386,7 +386,7 @@ typedef ResourceHashtable< ModuleEntry*, 557, // prime number AnyObj::C_HEAP> ArchivedModuleEntries; -static ArchivedModuleEntries* _archive_modules_entries = NULL; +static ArchivedModuleEntries* _archive_modules_entries = nullptr; #ifndef PRODUCT static int _num_archived_module_entries = 0; @@ -399,10 +399,10 @@ ModuleEntry* ModuleEntry::allocate_archived_entry() const { memcpy((void*)archived_entry, (void*)this, sizeof(ModuleEntry)); archived_entry->_archived_module_index = -1; - if (_archive_modules_entries == NULL) { + if (_archive_modules_entries == nullptr) { _archive_modules_entries = new (mtClass)ArchivedModuleEntries(); } - assert(_archive_modules_entries->get(this) == NULL, "Each ModuleEntry must not be shared across ModuleEntryTables"); + assert(_archive_modules_entries->get(this) == nullptr, "Each ModuleEntry must not be shared across ModuleEntryTables"); _archive_modules_entries->put(this, archived_entry); DEBUG_ONLY(_num_archived_module_entries++); @@ -422,7 +422,7 @@ bool ModuleEntry::has_been_archived() { ModuleEntry* ModuleEntry::get_archived_entry(ModuleEntry* orig_entry) { ModuleEntry** ptr = _archive_modules_entries->get(orig_entry); - assert(ptr != NULL && *ptr != NULL, "must have been allocated"); + assert(ptr != nullptr && *ptr != nullptr, "must have been allocated"); return *ptr; } @@ -430,8 +430,8 @@ ModuleEntry* ModuleEntry::get_archived_entry(ModuleEntry* orig_entry) { // GrowableArray cannot be directly archived, as it needs to be expandable at runtime. // Write it out as an Array, and convert it back to GrowableArray at runtime. Array* ModuleEntry::write_growable_array(GrowableArray* array) { - Array* archived_array = NULL; - int length = (array == NULL) ? 0 : array->length(); + Array* archived_array = nullptr; + int length = (array == nullptr) ? 0 : array->length(); if (length > 0) { archived_array = ArchiveBuilder::new_ro_array(length); for (int i = 0; i < length; i++) { @@ -445,8 +445,8 @@ Array* ModuleEntry::write_growable_array(GrowableArray* ModuleEntry::restore_growable_array(Array* archived_array) { - GrowableArray* array = NULL; - int length = (archived_array == NULL) ? 0 : archived_array->length(); + GrowableArray* array = nullptr; + int length = (archived_array == nullptr) ? 0 : archived_array->length(); if (length > 0) { array = new (mtModule) GrowableArray(length, mtModule); for (int i = 0; i < length; i++) { @@ -467,17 +467,17 @@ void ModuleEntry::iterate_symbols(MetaspaceClosure* closure) { void ModuleEntry::init_as_archived_entry() { Array* archived_reads = write_growable_array(_reads); - _loader_data = NULL; // re-init at runtime + _loader_data = nullptr; // re-init at runtime _shared_path_index = FileMapInfo::get_module_shared_path_index(_location); - if (name() != NULL) { + if (name() != nullptr) { _name = ArchiveBuilder::get_buffered_symbol(_name); ArchivePtrMarker::mark_pointer((address*)&_name); } _reads = (GrowableArray*)archived_reads; - if (_version != NULL) { + if (_version != nullptr) { _version = ArchiveBuilder::get_buffered_symbol(_version); } - if (_location != NULL) { + if (_location != nullptr) { _location = ArchiveBuilder::get_buffered_symbol(_location); } JFR_ONLY(set_trace_id(0));// re-init at runtime @@ -494,7 +494,7 @@ void ModuleEntry::update_oops_in_archived_module(int root_oop_index) { _archived_module_index = root_oop_index; - assert(shared_protection_domain() == NULL, "never set during -Xshare:dump"); + assert(shared_protection_domain() == nullptr, "never set during -Xshare:dump"); // Clear handles and restore at run time. Handles cannot be archived. OopHandle null_handle; _module = null_handle; @@ -612,9 +612,9 @@ ModuleEntry* ModuleEntryTable::locked_create_entry(Handle module_handle, Symbol* module_version, Symbol* module_location, ClassLoaderData* loader_data) { - assert(module_name != NULL, "ModuleEntryTable locked_create_entry should never be called for unnamed module."); + assert(module_name != nullptr, "ModuleEntryTable locked_create_entry should never be called for unnamed module."); assert(Module_lock->owned_by_self(), "should have the Module_lock"); - assert(lookup_only(module_name) == NULL, "Module already exists"); + assert(lookup_only(module_name) == nullptr, "Module already exists"); ModuleEntry* entry = new ModuleEntry(module_handle, is_open, module_name, module_version, module_location, loader_data); bool created = _table.put(module_name, entry); @@ -625,7 +625,7 @@ ModuleEntry* ModuleEntryTable::locked_create_entry(Handle module_handle, // lookup_only by Symbol* to find a ModuleEntry. ModuleEntry* ModuleEntryTable::lookup_only(Symbol* name) { assert_locked_or_safepoint(Module_lock); - assert(name != NULL, "name cannot be NULL"); + assert(name != nullptr, "name cannot be nullptr"); ModuleEntry** entry = _table.get(name); return (entry == nullptr) ? nullptr : *entry; } @@ -645,7 +645,7 @@ void ModuleEntryTable::finalize_javabase(Handle module_handle, Symbol* version, ClassLoaderData* boot_loader_data = ClassLoaderData::the_null_class_loader_data(); ModuleEntryTable* module_table = boot_loader_data->modules(); - assert(module_table != NULL, "boot loader's ModuleEntryTable not defined"); + assert(module_table != nullptr, "boot loader's ModuleEntryTable not defined"); if (module_handle.is_null()) { fatal("Unable to finalize module definition for " JAVA_BASE_NAME); @@ -653,7 +653,7 @@ void ModuleEntryTable::finalize_javabase(Handle module_handle, Symbol* version, // Set java.lang.Module, version and location for java.base ModuleEntry* jb_module = javabase_moduleEntry(); - assert(jb_module != NULL, JAVA_BASE_NAME " ModuleEntry not defined"); + assert(jb_module != nullptr, JAVA_BASE_NAME " ModuleEntry not defined"); jb_module->set_version(version); jb_module->set_location(location); // Once java.base's ModuleEntry _module field is set with the known @@ -707,7 +707,7 @@ void ModuleEntryTable::patch_javabase_entries(JavaThread* current, Handle module } delete java_lang_Class::fixup_module_field_list(); - java_lang_Class::set_fixup_module_field_list(NULL); + java_lang_Class::set_fixup_module_field_list(nullptr); } void ModuleEntryTable::print(outputStream* st) { @@ -740,11 +740,11 @@ void ModuleEntryTable::modules_do(ModuleClosure* closure) { void ModuleEntry::print(outputStream* st) { st->print_cr("entry " PTR_FORMAT " name %s module " PTR_FORMAT " loader %s version %s location %s strict %s", p2i(this), - name() == NULL ? UNNAMED_MODULE : name()->as_C_string(), + name() == nullptr ? UNNAMED_MODULE : name()->as_C_string(), p2i(module()), loader_data()->loader_name_and_id(), - version() != NULL ? version()->as_C_string() : "NULL", - location() != NULL ? location()->as_C_string() : "NULL", + version() != nullptr ? version()->as_C_string() : "nullptr", + location() != nullptr ? location()->as_C_string() : "nullptr", BOOL_TO_STR(!can_read_all_unnamed())); } @@ -757,5 +757,5 @@ void ModuleEntryTable::verify() { } void ModuleEntry::verify() { - guarantee(loader_data() != NULL, "A module entry must be associated with a loader."); + guarantee(loader_data() != nullptr, "A module entry must be associated with a loader."); } diff --git a/src/hotspot/share/classfile/moduleEntry.hpp b/src/hotspot/share/classfile/moduleEntry.hpp index 45973c9d833..62a0ba2a0b7 100644 --- a/src/hotspot/share/classfile/moduleEntry.hpp +++ b/src/hotspot/share/classfile/moduleEntry.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -121,7 +121,7 @@ public: bool is_open() const { return _is_open; } void set_is_open(bool is_open); - bool is_named() const { return (_name != NULL); } + bool is_named() const { return (_name != nullptr); } bool can_read_all_unnamed() const { assert(is_named() || _can_read_all_unnamed == true, @@ -233,12 +233,12 @@ public: // Special handling for java.base static ModuleEntry* javabase_moduleEntry() { return _javabase_module; } static void set_javabase_moduleEntry(ModuleEntry* java_base) { - assert(_javabase_module == NULL, "_javabase_module is already defined"); + assert(_javabase_module == nullptr, "_javabase_module is already defined"); _javabase_module = java_base; } - static bool javabase_defined() { return ((_javabase_module != NULL) && - (_javabase_module->module() != NULL)); } + static bool javabase_defined() { return ((_javabase_module != nullptr) && + (_javabase_module->module() != nullptr)); } static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location); static void patch_javabase_entries(JavaThread* current, Handle module_handle); diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index 027ecc646fc..e770f97555c 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/src/hotspot/share/classfile/modules.cpp @@ -54,12 +54,12 @@ #include "utilities/utf8.hpp" static bool verify_module_name(const char *module_name, int len) { - assert(module_name != NULL, "invariant"); + assert(module_name != nullptr, "invariant"); return (len > 0 && len <= Symbol::max_length()); } static bool verify_package_name(const char* package_name, int len) { - assert(package_name != NULL, "Package name derived from non-null jstring can't be NULL"); + assert(package_name != nullptr, "Package name derived from non-null jstring can't be null"); return (len > 0 && len <= Symbol::max_length() && ClassFileParser::verify_unqualified_name(package_name, len, ClassFileParser::LegalClass)); @@ -67,7 +67,7 @@ static bool verify_package_name(const char* package_name, int len) { static char* get_module_name(oop module, int& len, TRAPS) { oop name_oop = java_lang_Module::name(module); - if (name_oop == NULL) { + if (name_oop == nullptr) { THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "Null module name"); } char* module_name = java_lang_String::as_utf8_string(name_oop, len); @@ -79,8 +79,8 @@ static char* get_module_name(oop module, int& len, TRAPS) { } static Symbol* as_symbol(jstring str_object) { - if (str_object == NULL) { - return NULL; + if (str_object == nullptr) { + return nullptr; } int len; char* str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(str_object), len); @@ -112,28 +112,28 @@ static ModuleEntry* get_module_entry(Handle module, TRAPS) { static PackageEntry* get_locked_package_entry(ModuleEntry* module_entry, const char* package_name, int len) { assert(Module_lock->owned_by_self(), "should have the Module_lock"); - assert(package_name != NULL, "Precondition"); + assert(package_name != nullptr, "Precondition"); TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, len); PackageEntryTable* package_entry_table = module_entry->loader_data()->packages(); - assert(package_entry_table != NULL, "Unexpected null package entry table"); + assert(package_entry_table != nullptr, "Unexpected null package entry table"); PackageEntry* package_entry = package_entry_table->locked_lookup_only(pkg_symbol); - assert(package_entry == NULL || package_entry->module() == module_entry, "Unexpectedly found a package linked to another module"); + assert(package_entry == nullptr || package_entry->module() == module_entry, "Unexpectedly found a package linked to another module"); return package_entry; } static PackageEntry* get_package_entry_by_name(Symbol* package, Handle h_loader) { - if (package != NULL) { + if (package != nullptr) { PackageEntryTable* const package_entry_table = get_package_entry_table(h_loader); - assert(package_entry_table != NULL, "Unexpected null package entry table"); + assert(package_entry_table != nullptr, "Unexpected null package entry table"); return package_entry_table->lookup_only(package); } - return NULL; + return nullptr; } bool Modules::is_package_defined(Symbol* package, Handle h_loader) { PackageEntry* res = get_package_entry_by_name(package, h_loader); - return res != NULL; + return res != nullptr; } // Converts the String oop to an internal package @@ -168,7 +168,7 @@ static void define_javabase_module(Handle module_handle, jstring version, jstrin for (int x = 0; x < num_packages; x++) { oop pkg_str = pkgs->obj_at(x); - if (pkg_str == NULL || pkg_str->klass() != vmClasses::String_klass()) { + if (pkg_str == nullptr || pkg_str->klass() != vmClasses::String_klass()) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Bad package name")); } @@ -185,7 +185,7 @@ static void define_javabase_module(Handle module_handle, jstring version, jstrin // Validate java_base's loader is the boot loader. oop loader = java_lang_Module::loader(module_handle()); - if (loader != NULL) { + if (loader != nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Class loader must be the boot class loader"); } @@ -193,10 +193,10 @@ static void define_javabase_module(Handle module_handle, jstring version, jstrin // Ensure the boot loader's PackageEntryTable has been created PackageEntryTable* package_table = get_package_entry_table(h_loader); - assert(pkg_list->length() == 0 || package_table != NULL, "Bad package_table"); + assert(pkg_list->length() == 0 || package_table != nullptr, "Bad package_table"); // Ensure java.base's ModuleEntry has been created - assert(ModuleEntryTable::javabase_moduleEntry() != NULL, "No ModuleEntry for " JAVA_BASE_NAME); + assert(ModuleEntryTable::javabase_moduleEntry() != nullptr, "No ModuleEntry for " JAVA_BASE_NAME); bool duplicate_javabase = false; { @@ -216,7 +216,7 @@ static void define_javabase_module(Handle module_handle, jstring version, jstrin // Some of java.base's packages were added early in bootstrapping, ignore duplicates. package_table->locked_create_entry_if_absent(pkg_list->at(x), ModuleEntryTable::javabase_moduleEntry()); - assert(package_table->locked_lookup_only(pkg_list->at(x)) != NULL, + assert(package_table->locked_lookup_only(pkg_list->at(x)) != nullptr, "Unable to create a " JAVA_BASE_NAME " package entry"); // Unable to have a GrowableArray of TempNewSymbol. Must decrement the refcount of // the Symbol* that was created above for each package. The refcount was incremented @@ -240,11 +240,11 @@ static void define_javabase_module(Handle module_handle, jstring version, jstrin ModuleEntryTable::patch_javabase_entries(THREAD, module_handle); log_info(module, load)(JAVA_BASE_NAME " location: %s", - location_symbol != NULL ? location_symbol->as_C_string() : "NULL"); + location_symbol != nullptr ? location_symbol->as_C_string() : "nullptr"); log_debug(module)("define_javabase_module(): Definition of module: " JAVA_BASE_NAME ", version: %s, location: %s, package #: %d", - version_symbol != NULL ? version_symbol->as_C_string() : "NULL", - location_symbol != NULL ? location_symbol->as_C_string() : "NULL", + version_symbol != nullptr ? version_symbol->as_C_string() : "nullptr", + location_symbol != nullptr ? location_symbol->as_C_string() : "nullptr", pkg_list->length()); // packages defined to java.base @@ -286,7 +286,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, int module_name_len; char* module_name = get_module_name(module(), module_name_len, CHECK); - if (module_name == NULL) { + if (module_name == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Module name cannot be null"); } @@ -312,7 +312,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, // define_module can be called during start-up, before the class loader's ClassLoaderData // has been created. SystemDictionary::register_loader ensures creation, if needed. ClassLoaderData* loader_data = SystemDictionary::register_loader(h_loader); - assert(loader_data != NULL, "class loader data shouldn't be null"); + assert(loader_data != nullptr, "class loader data shouldn't be null"); // Only modules defined to either the boot or platform class loader, can define a "java/" package. bool java_pkg_disallowed = !h_loader.is_null() && @@ -324,7 +324,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, GrowableArray* pkg_list = new GrowableArray(num_packages); for (int x = 0; x < num_packages; x++) { oop pkg_str = packages_h->obj_at(x); - if (pkg_str == NULL || pkg_str->klass() != vmClasses::String_klass()) { + if (pkg_str == nullptr || pkg_str->klass() != vmClasses::String_klass()) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Bad package name")); } @@ -359,7 +359,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, } ModuleEntryTable* module_table = get_module_entry_table(h_loader); - assert(module_table != NULL, "module entry table shouldn't be null"); + assert(module_table != nullptr, "module entry table shouldn't be null"); // Create symbol* entry for module name. TempNewSymbol module_symbol = SymbolTable::new_symbol(module_name, module_name_len); @@ -372,22 +372,22 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, // Create symbol* entry for module location. TempNewSymbol location_symbol = as_symbol(location); - PackageEntryTable* package_table = NULL; - PackageEntry* existing_pkg = NULL; + PackageEntryTable* package_table = nullptr; + PackageEntry* existing_pkg = nullptr; { MutexLocker ml(THREAD, Module_lock); if (num_packages > 0) { package_table = get_package_entry_table(h_loader); - assert(package_table != NULL, "Missing package_table"); + assert(package_table != nullptr, "Missing package_table"); // Check that none of the packages exist in the class loader's package table. for (int x = 0; x < pkg_list->length(); x++) { existing_pkg = package_table->locked_lookup_only(pkg_list->at(x)); - if (existing_pkg != NULL) { + if (existing_pkg != nullptr) { // This could be because the module was already defined. If so, // report that error instead of the package error. - if (module_table->lookup_only(module_symbol) != NULL) { + if (module_table->lookup_only(module_symbol) != nullptr) { dupl_modules = true; } break; @@ -396,16 +396,16 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, } // if (num_packages > 0)... // Add the module and its packages. - if (!dupl_modules && existing_pkg == NULL) { - if (module_table->lookup_only(module_symbol) == NULL) { + if (!dupl_modules && existing_pkg == nullptr) { + if (module_table->lookup_only(module_symbol) == nullptr) { // Create the entry for this module in the class loader's module entry table. ModuleEntry* module_entry = module_table->locked_create_entry(module, (is_open == JNI_TRUE), module_symbol, version_symbol, location_symbol, loader_data); - assert(module_entry != NULL, "module_entry creation failed"); + assert(module_entry != nullptr, "module_entry creation failed"); // Add the packages. - assert(pkg_list->length() == 0 || package_table != NULL, "Bad package table"); + assert(pkg_list->length() == 0 || package_table != nullptr, "Bad package table"); for (int y = 0; y < pkg_list->length(); y++) { package_table->locked_create_entry(pkg_list->at(y), module_entry); @@ -427,18 +427,18 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, if (dupl_modules) { THROW_MSG(vmSymbols::java_lang_IllegalStateException(), err_msg("Module %s is already defined", module_name)); - } else if (existing_pkg != NULL) { + } else if (existing_pkg != nullptr) { throw_dup_pkg_exception(module_name, existing_pkg, CHECK); } log_info(module, load)("%s location: %s", module_name, - location_symbol != NULL ? location_symbol->as_C_string() : "NULL"); + location_symbol != nullptr ? location_symbol->as_C_string() : "null"); LogTarget(Debug, module) lt; if (lt.is_enabled()) { LogStream ls(lt); ls.print("define_module(): creation of module: %s, version: %s, location: %s, ", - module_name, version_symbol != NULL ? version_symbol->as_C_string() : "NULL", - location_symbol != NULL ? location_symbol->as_C_string() : "NULL"); + module_name, version_symbol != nullptr ? version_symbol->as_C_string() : "null", + location_symbol != nullptr ? location_symbol->as_C_string() : "null"); loader_data->print_value_on(&ls); ls.print_cr(", package #: %d", pkg_list->length()); for (int y = 0; y < pkg_list->length(); y++) { @@ -590,7 +590,7 @@ void Modules::define_archived_modules(Handle h_platform_loader, Handle h_system_ // system_loader_data here is always an instance of jdk.internal.loader.ClassLoader$AppClassLoader. // However, if -Djava.system.class.loader=xxx is specified, java_platform_loader() would // be an instance of a user-defined class, so make sure this never happens. - assert(Arguments::get_property("java.system.class.loader") == NULL, + assert(Arguments::get_property("java.system.class.loader") == nullptr, "archived full module should have been disabled if -Djava.system.class.loader is specified"); ClassLoaderDataShared::restore_java_system_loader_from_archive(system_loader_data); } @@ -616,14 +616,14 @@ void Modules::set_bootloader_unnamed_module(Handle module, TRAPS) { // Ensure that this is an unnamed module oop name = java_lang_Module::name(module()); - if (name != NULL) { + if (name != nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "boot loader's unnamed module's java.lang.Module has a name"); } // Validate java_base's loader is the boot loader. oop loader = java_lang_Module::loader(module()); - if (loader != NULL) { + if (loader != nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Class loader must be the boot class loader"); } @@ -633,7 +633,7 @@ void Modules::set_bootloader_unnamed_module(Handle module, TRAPS) { // Set java.lang.Module for the boot loader's unnamed module ClassLoaderData* boot_loader_data = ClassLoaderData::the_null_class_loader_data(); ModuleEntry* unnamed_module = boot_loader_data->unnamed_module(); - assert(unnamed_module != NULL, "boot loader's unnamed ModuleEntry not defined"); + assert(unnamed_module != nullptr, "boot loader's unnamed ModuleEntry not defined"); unnamed_module->set_module(boot_loader_data->add_handle(module)); // Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object. java_lang_Module::set_module_entry(module(), unnamed_module); @@ -642,7 +642,7 @@ void Modules::set_bootloader_unnamed_module(Handle module, TRAPS) { void Modules::add_module_exports(Handle from_module, jstring package_name, Handle to_module, TRAPS) { check_cds_restrictions(CHECK); - if (package_name == NULL) { + if (package_name == nullptr) { THROW_MSG(vmSymbols::java_lang_NullPointerException(), "package is null"); } @@ -651,7 +651,7 @@ void Modules::add_module_exports(Handle from_module, jstring package_name, Handl "from_module is null"); } ModuleEntry* from_module_entry = get_module_entry(from_module, CHECK); - if (from_module_entry == NULL) { + if (from_module_entry == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "from_module cannot be found"); } @@ -661,16 +661,16 @@ void Modules::add_module_exports(Handle from_module, jstring package_name, Handl ModuleEntry* to_module_entry; if (to_module.is_null()) { - to_module_entry = NULL; // It's an unqualified export. + to_module_entry = nullptr; // It's an unqualified export. } else { to_module_entry = get_module_entry(to_module, CHECK); - if (to_module_entry == NULL) { + if (to_module_entry == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "to_module is invalid"); } } - PackageEntry* package_entry = NULL; + PackageEntry* package_entry = nullptr; char buf[128]; int package_len; @@ -682,16 +682,16 @@ void Modules::add_module_exports(Handle from_module, jstring package_name, Handl // Do nothing if modules are the same // If the package is not found we'll throw an exception later if (from_module_entry != to_module_entry && - package_entry != NULL) { + package_entry != nullptr) { package_entry->set_exported(to_module_entry); } } // Handle errors and logging outside locked section - if (package_entry == NULL) { + if (package_entry == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Package %s not found in from_module %s", - pkg != NULL ? pkg : "", + pkg != nullptr ? pkg : "", from_module_entry->name()->as_C_string())); } @@ -699,7 +699,7 @@ void Modules::add_module_exports(Handle from_module, jstring package_name, Handl log_debug(module)("add_module_exports(): package %s in module %s is exported to module %s", package_entry->name()->as_C_string(), from_module_entry->name()->as_C_string(), - to_module_entry == NULL ? "NULL" : + to_module_entry == nullptr ? "null" : to_module_entry->is_named() ? to_module_entry->name()->as_C_string() : UNNAMED_MODULE); } @@ -724,7 +724,7 @@ void Modules::add_reads_module(Handle from_module, Handle to_module, TRAPS) { } ModuleEntry* from_module_entry = get_module_entry(from_module, CHECK); - if (from_module_entry == NULL) { + if (from_module_entry == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "from_module is not valid"); } @@ -732,19 +732,19 @@ void Modules::add_reads_module(Handle from_module, Handle to_module, TRAPS) { ModuleEntry* to_module_entry; if (!to_module.is_null()) { to_module_entry = get_module_entry(to_module, CHECK); - if (to_module_entry == NULL) { + if (to_module_entry == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "to_module is invalid"); } } else { - to_module_entry = NULL; + to_module_entry = nullptr; } ResourceMark rm(THREAD); log_debug(module)("add_reads_module(): Adding read from module %s to module %s", from_module_entry->is_named() ? from_module_entry->name()->as_C_string() : UNNAMED_MODULE, - to_module_entry == NULL ? "all unnamed" : + to_module_entry == nullptr ? "all unnamed" : (to_module_entry->is_named() ? to_module_entry->name()->as_C_string() : UNNAMED_MODULE)); @@ -759,14 +759,14 @@ jobject Modules::get_module(jclass clazz, TRAPS) { assert(ModuleEntryTable::javabase_defined(), "Attempt to call get_module before " JAVA_BASE_NAME " is defined"); - if (clazz == NULL) { + if (clazz == nullptr) { THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "class is null", JNI_FALSE); } oop mirror = JNIHandles::resolve_non_null(clazz); - if (mirror == NULL) { - log_debug(module)("get_module(): no mirror, returning NULL"); - return NULL; + if (mirror == nullptr) { + log_debug(module)("get_module(): no mirror, returning nullptr"); + return nullptr; } if (!java_lang_Class::is_instance(mirror)) { THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), @@ -775,7 +775,7 @@ jobject Modules::get_module(jclass clazz, TRAPS) { oop module = java_lang_Class::module(mirror); - assert(module != NULL, "java.lang.Class module field not set"); + assert(module != nullptr, "java.lang.Class module field not set"); assert(java_lang_Module::is_instance(module), "module is not an instance of type java.lang.Module"); LogTarget(Debug,module) lt; @@ -784,13 +784,13 @@ jobject Modules::get_module(jclass clazz, TRAPS) { LogStream ls(lt); Klass* klass = java_lang_Class::as_Klass(mirror); oop module_name = java_lang_Module::name(module); - if (module_name != NULL) { + if (module_name != nullptr) { ls.print("get_module(): module "); java_lang_String::print(module_name, tty); } else { ls.print("get_module(): Unnamed Module"); } - if (klass != NULL) { + if (klass != nullptr) { ls.print_cr(" for class %s", klass->external_name()); } else { ls.print_cr(" for primitive class"); @@ -805,20 +805,20 @@ oop Modules::get_named_module(Handle h_loader, const char* package_name) { "Attempt to call get_named_module before " JAVA_BASE_NAME " is defined"); assert(h_loader.is_null() || java_lang_ClassLoader::is_subclass(h_loader->klass()), "Class loader is not a subclass of java.lang.ClassLoader"); - assert(package_name != NULL, "the package_name should not be NULL"); + assert(package_name != nullptr, "the package_name should not be null"); if (strlen(package_name) == 0) { - return NULL; + return nullptr; } TempNewSymbol package_sym = SymbolTable::new_symbol(package_name); const PackageEntry* const pkg_entry = get_package_entry_by_name(package_sym, h_loader); - const ModuleEntry* const module_entry = (pkg_entry != NULL ? pkg_entry->module() : NULL); + const ModuleEntry* const module_entry = (pkg_entry != nullptr ? pkg_entry->module() : nullptr); - if (module_entry != NULL && module_entry->module() != NULL && module_entry->is_named()) { + if (module_entry != nullptr && module_entry->module() != nullptr && module_entry->is_named()) { return module_entry->module(); } - return NULL; + return nullptr; } // Export package in module to all unnamed modules. @@ -828,12 +828,12 @@ void Modules::add_module_exports_to_all_unnamed(Handle module, jstring package_n THROW_MSG(vmSymbols::java_lang_NullPointerException(), "module is null"); } - if (package_name == NULL) { + if (package_name == nullptr) { THROW_MSG(vmSymbols::java_lang_NullPointerException(), "package is null"); } ModuleEntry* module_entry = get_module_entry(module, CHECK); - if (module_entry == NULL) { + if (module_entry == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "module is invalid"); } @@ -846,22 +846,22 @@ void Modules::add_module_exports_to_all_unnamed(Handle module, jstring package_n char buf[128]; int pkg_len; const char* pkg = as_internal_package(JNIHandles::resolve_non_null(package_name), buf, sizeof(buf), pkg_len); - PackageEntry* package_entry = NULL; + PackageEntry* package_entry = nullptr; { MutexLocker m1(THREAD, Module_lock); package_entry = get_locked_package_entry(module_entry, pkg, pkg_len); // Mark package as exported to all unnamed modules. - if (package_entry != NULL) { + if (package_entry != nullptr) { package_entry->set_is_exported_allUnnamed(); } } // Handle errors and logging outside locked section - if (package_entry == NULL) { + if (package_entry == nullptr) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Package %s not found in module %s", - pkg != NULL ? pkg : "", + pkg != nullptr ? pkg : "", module_entry->name()->as_C_string())); } diff --git a/src/hotspot/share/classfile/modules.hpp b/src/hotspot/share/classfile/modules.hpp index d444ea3bb82..787f5dd4b52 100644 --- a/src/hotspot/share/classfile/modules.hpp +++ b/src/hotspot/share/classfile/modules.hpp @@ -105,8 +105,8 @@ public: static jobject get_module(jclass clazz, TRAPS); // Return the java.lang.Module object for this class loader and package. - // Returns NULL if the package name is empty, if the resulting package - // entry is NULL, if the module is not found or is unnamed. + // Returns null if the package name is empty, if the resulting package + // entry is null, if the module is not found or is unnamed. // The package should contain /'s, not .'s, as in java/lang, not java.lang. static oop get_named_module(Handle h_loader, const char* package); diff --git a/src/hotspot/share/classfile/packageEntry.cpp b/src/hotspot/share/classfile/packageEntry.cpp index b3161ab558f..1b315bc24be 100644 --- a/src/hotspot/share/classfile/packageEntry.cpp +++ b/src/hotspot/share/classfile/packageEntry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -47,7 +47,7 @@ PackageEntry::PackageEntry(Symbol* name, ModuleEntry* module) : _export_flags(0), _classpath_index(-1), _must_walk_exports(false), - _qualified_exports(NULL), + _qualified_exports(nullptr), _defined_by_cds_in_class_path(0) { // name can't be null @@ -64,7 +64,7 @@ PackageEntry::~PackageEntry() { // Returns true if this package specifies m as a qualified export, including through an unnamed export bool PackageEntry::is_qexported_to(ModuleEntry* m) const { assert(Module_lock->owned_by_self(), "should have the Module_lock"); - assert(m != NULL, "No module to lookup in this package's qualified exports list"); + assert(m != nullptr, "No module to lookup in this package's qualified exports list"); if (is_exported_allUnnamed() && !m->is_named()) { return true; } else if (!has_qual_exports_list()) { @@ -100,15 +100,15 @@ void PackageEntry::set_export_walk_required(ClassLoaderData* m_loader_data) { assert_locked_or_safepoint(Module_lock); ModuleEntry* this_pkg_mod = module(); if (!_must_walk_exports && - (this_pkg_mod == NULL || this_pkg_mod->loader_data() != m_loader_data) && + (this_pkg_mod == nullptr || this_pkg_mod->loader_data() != m_loader_data) && !m_loader_data->is_builtin_class_loader_data()) { _must_walk_exports = true; if (log_is_enabled(Trace, module)) { ResourceMark rm; - assert(name() != NULL, "PackageEntry without a valid name"); + assert(name() != nullptr, "PackageEntry without a valid name"); log_trace(module)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked", name()->as_C_string(), - (this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ? + (this_pkg_mod == nullptr || this_pkg_mod->name() == nullptr) ? UNNAMED_MODULE : this_pkg_mod->name()->as_C_string()); } } @@ -123,8 +123,8 @@ void PackageEntry::set_exported(ModuleEntry* m) { return; } - if (m == NULL) { - // NULL indicates the package is being unqualifiedly exported. Clean up + if (m == nullptr) { + // null indicates the package is being unqualifiedly exported. Clean up // the qualified list at the next safepoint. set_unqual_exported(); } else { @@ -150,7 +150,7 @@ void PackageEntry::set_is_exported_allUnnamed() { void PackageEntry::purge_qualified_exports() { assert_locked_or_safepoint(Module_lock); if (_must_walk_exports && - _qualified_exports != NULL && + _qualified_exports != nullptr && !_qualified_exports->is_empty()) { // This package's _must_walk_exports flag will be reset based @@ -159,11 +159,11 @@ void PackageEntry::purge_qualified_exports() { if (log_is_enabled(Trace, module)) { ResourceMark rm; - assert(name() != NULL, "PackageEntry without a valid name"); + assert(name() != nullptr, "PackageEntry without a valid name"); ModuleEntry* pkg_mod = module(); log_trace(module)("PackageEntry::purge_qualified_exports(): package %s defined in module %s, exports list being walked", name()->as_C_string(), - (pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string()); + (pkg_mod == nullptr || pkg_mod->name() == nullptr) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string()); } // Go backwards because this removes entries that are dead. @@ -182,10 +182,10 @@ void PackageEntry::purge_qualified_exports() { } void PackageEntry::delete_qualified_exports() { - if (_qualified_exports != NULL) { + if (_qualified_exports != nullptr) { delete _qualified_exports; } - _qualified_exports = NULL; + _qualified_exports = nullptr; } PackageEntryTable::PackageEntryTable() { } @@ -216,17 +216,17 @@ typedef ResourceHashtable< PackageEntry*, 557, // prime number AnyObj::C_HEAP> ArchivedPackageEntries; -static ArchivedPackageEntries* _archived_packages_entries = NULL; +static ArchivedPackageEntries* _archived_packages_entries = nullptr; PackageEntry* PackageEntry::allocate_archived_entry() const { assert(!in_unnamed_module(), "unnamed packages/modules are not archived"); PackageEntry* archived_entry = (PackageEntry*)ArchiveBuilder::rw_region_alloc(sizeof(PackageEntry)); memcpy((void*)archived_entry, (void*)this, sizeof(PackageEntry)); - if (_archived_packages_entries == NULL) { + if (_archived_packages_entries == nullptr) { _archived_packages_entries = new (mtClass)ArchivedPackageEntries(); } - assert(_archived_packages_entries->get(this) == NULL, "Each PackageEntry must not be shared across PackageEntryTables"); + assert(_archived_packages_entries->get(this) == nullptr, "Each PackageEntry must not be shared across PackageEntryTables"); _archived_packages_entries->put(this, archived_entry); return archived_entry; @@ -234,10 +234,10 @@ PackageEntry* PackageEntry::allocate_archived_entry() const { PackageEntry* PackageEntry::get_archived_entry(PackageEntry* orig_entry) { PackageEntry** ptr = _archived_packages_entries->get(orig_entry); - if (ptr != NULL) { + if (ptr != nullptr) { return *ptr; } else { - return NULL; + return nullptr; } } @@ -331,7 +331,7 @@ void PackageEntryTable::load_archived_entries(Array* archived_pac // was taken by caller. void PackageEntryTable::locked_create_entry(Symbol* name, ModuleEntry* module) { assert(Module_lock->owned_by_self(), "should have the Module_lock"); - assert(locked_lookup_only(name) == NULL, "Package entry already exists"); + assert(locked_lookup_only(name) == nullptr, "Package entry already exists"); PackageEntry* entry = new PackageEntry(name, module); bool created = _table.put(name, entry); assert(created, "must be"); @@ -376,8 +376,8 @@ void PackageEntryTable::verify_javabase_packages(GrowableArray *pkg_lis assert_lock_strong(Module_lock); auto verifier = [&] (const SymbolHandle& name, PackageEntry*& entry) { ModuleEntry* m = entry->module(); - Symbol* module_name = (m == NULL ? NULL : m->name()); - if (module_name != NULL && + Symbol* module_name = (m == nullptr ? nullptr : m->name()); + if (module_name != nullptr && (module_name->fast_compare(vmSymbols::java_base()) == 0) && !pkg_list->contains(entry->name())) { ResourceMark rm; @@ -391,7 +391,7 @@ void PackageEntryTable::verify_javabase_packages(GrowableArray *pkg_lis // iteration of qualified exports void PackageEntry::package_exports_do(ModuleClosure* f) { assert_locked_or_safepoint(Module_lock); - assert(f != NULL, "invariant"); + assert(f != nullptr, "invariant"); if (has_qual_exports_list()) { int qe_len = _qualified_exports->length(); @@ -404,7 +404,7 @@ void PackageEntry::package_exports_do(ModuleClosure* f) { bool PackageEntry::exported_pending_delete() const { assert_locked_or_safepoint(Module_lock); - return (is_unqual_exported() && _qualified_exports != NULL); + return (is_unqual_exported() && _qualified_exports != nullptr); } // Remove dead entries from all packages' exported list diff --git a/src/hotspot/share/classfile/packageEntry.hpp b/src/hotspot/share/classfile/packageEntry.hpp index ac48abdd29f..6fefd208ad6 100644 --- a/src/hotspot/share/classfile/packageEntry.hpp +++ b/src/hotspot/share/classfile/packageEntry.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, 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 @@ -151,7 +151,7 @@ public: // return true. bool has_qual_exports_list() const { assert_locked_or_safepoint(Module_lock); - return (!is_unqual_exported() && _qualified_exports != NULL); + return (!is_unqual_exported() && _qualified_exports != nullptr); } bool is_exported_allUnnamed() const { assert_locked_or_safepoint(Module_lock); diff --git a/src/hotspot/share/classfile/placeholders.cpp b/src/hotspot/share/classfile/placeholders.cpp index e9fd87121c3..f6614881e0d 100644 --- a/src/hotspot/share/classfile/placeholders.cpp +++ b/src/hotspot/share/classfile/placeholders.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -69,8 +69,8 @@ private: public: SeenThread(JavaThread* thread) { _thread = thread; - _stnext = NULL; - _stprev = NULL; + _stnext = nullptr; + _stprev = nullptr; } JavaThread* thread() const { return _thread;} void set_thread(JavaThread* thread) { _thread = thread; } @@ -81,7 +81,7 @@ public: void print_action_queue(outputStream* st) { SeenThread* seen = this; - while (seen != NULL) { + while (seen != nullptr) { seen->thread()->print_value_on(st); st->print(", "); seen = seen->next(); @@ -90,7 +90,7 @@ public: }; SeenThread* PlaceholderEntry::actionToQueue(PlaceholderTable::classloadAction action) { - SeenThread* queuehead = NULL; + SeenThread* queuehead = nullptr; switch (action) { case PlaceholderTable::LOAD_INSTANCE: queuehead = _loadInstanceThreadQ; @@ -132,15 +132,15 @@ void PlaceholderEntry::add_seen_thread(JavaThread* thread, PlaceholderTable::cla SeenThread* threadEntry = new SeenThread(thread); SeenThread* seen = actionToQueue(action); - assert(action != PlaceholderTable::LOAD_INSTANCE || !EnableWaitForParallelLoad || seen == NULL, + assert(action != PlaceholderTable::LOAD_INSTANCE || !EnableWaitForParallelLoad || seen == nullptr, "Only one LOAD_INSTANCE allowed at a time"); - if (seen == NULL) { + if (seen == nullptr) { set_threadQ(threadEntry, action); return; } SeenThread* next; - while ((next = seen->next()) != NULL) { + while ((next = seen->next()) != nullptr) { seen = next; } seen->set_next(threadEntry); @@ -170,7 +170,7 @@ bool PlaceholderEntry::remove_seen_thread(JavaThread* thread, PlaceholderTable:: assert_lock_strong(SystemDictionary_lock); SeenThread* threadQ = actionToQueue(action); SeenThread* seen = threadQ; - SeenThread* prev = NULL; + SeenThread* prev = nullptr; while (seen) { if (thread == seen->thread()) { if (prev) { @@ -187,7 +187,7 @@ bool PlaceholderEntry::remove_seen_thread(JavaThread* thread, PlaceholderTable:: prev = seen; seen = seen->next(); } - return (actionToQueue(action) == NULL); + return (actionToQueue(action) == nullptr); } @@ -200,7 +200,7 @@ bool PlaceholderEntry::remove_seen_thread(JavaThread* thread, PlaceholderTable:: PlaceholderEntry* add_entry(Symbol* class_name, ClassLoaderData* loader_data, Symbol* supername){ assert_locked_or_safepoint(SystemDictionary_lock); - assert(class_name != NULL, "adding NULL obj"); + assert(class_name != nullptr, "adding nullptr obj"); PlaceholderEntry entry; entry.set_supername(supername); @@ -255,9 +255,9 @@ PlaceholderEntry* PlaceholderTable::find_and_add(Symbol* name, classloadAction action, Symbol* supername, JavaThread* thread) { - assert(action != LOAD_SUPER || supername != NULL, "must have a super class name"); + assert(action != LOAD_SUPER || supername != nullptr, "must have a super class name"); PlaceholderEntry* probe = get_entry(name, loader_data); - if (probe == NULL) { + if (probe == nullptr) { // Nothing found, add place holder probe = add_entry(name, loader_data, supername); } else { @@ -289,12 +289,12 @@ void PlaceholderTable::find_and_remove(Symbol* name, ClassLoaderData* loader_dat JavaThread* thread) { assert_locked_or_safepoint(SystemDictionary_lock); PlaceholderEntry* probe = get_entry(name, loader_data); - if (probe != NULL) { + if (probe != nullptr) { log(name, probe, "find_and_remove", action); probe->remove_seen_thread(thread, action); // If no other threads using this entry, and this thread is not using this entry for other states - if ((probe->superThreadQ() == NULL) && (probe->loadInstanceThreadQ() == NULL) - && (probe->defineThreadQ() == NULL) && (probe->definer() == NULL)) { + if ((probe->superThreadQ() == nullptr) && (probe->loadInstanceThreadQ() == nullptr) + && (probe->defineThreadQ() == nullptr) && (probe->definer() == nullptr)) { probe->clear_supername(); remove_entry(name, loader_data); } @@ -308,15 +308,15 @@ void PlaceholderKey::print_on(outputStream* st) const { } void PlaceholderEntry::print_on(outputStream* st) const { - if (supername() != NULL) { + if (supername() != nullptr) { st->print(", supername "); supername()->print_value_on(st); } - if (definer() != NULL) { + if (definer() != nullptr) { st->print(", definer "); definer()->print_value_on(st); } - if (instance_klass() != NULL) { + if (instance_klass() != nullptr) { st->print(", InstanceKlass "); instance_klass()->print_value_on(st); } diff --git a/src/hotspot/share/classfile/placeholders.hpp b/src/hotspot/share/classfile/placeholders.hpp index c44e3897b39..bc5a4c373a7 100644 --- a/src/hotspot/share/classfile/placeholders.hpp +++ b/src/hotspot/share/classfile/placeholders.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -132,15 +132,15 @@ class PlaceholderEntry { void set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; } bool super_load_in_progress() { - return (_superThreadQ != NULL); + return (_superThreadQ != nullptr); } bool instance_load_in_progress() { - return (_loadInstanceThreadQ != NULL); + return (_loadInstanceThreadQ != nullptr); } bool define_class_in_progress() { - return (_defineThreadQ != NULL); + return (_defineThreadQ != nullptr); } // Used for ClassCircularityError checking diff --git a/src/hotspot/share/classfile/protectionDomainCache.cpp b/src/hotspot/share/classfile/protectionDomainCache.cpp index eae192ec1c9..a3369f409be 100644 --- a/src/hotspot/share/classfile/protectionDomainCache.cpp +++ b/src/hotspot/share/classfile/protectionDomainCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, 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 @@ -72,13 +72,13 @@ class CleanProtectionDomainEntries : public CLDClosure { void do_cld(ClassLoaderData* data) { Dictionary* dictionary = data->dictionary(); - if (dictionary != NULL) { + if (dictionary != nullptr) { dictionary->clean_cached_protection_domains(_delete_list); } } }; -static GrowableArray* _delete_list = NULL; +static GrowableArray* _delete_list = nullptr; class HandshakeForPD : public HandshakeClosure { public: @@ -115,7 +115,7 @@ void ProtectionDomainCacheTable::unlink() { assert(java_lang_System::allow_security_manager(), "should not be called otherwise"); // Create a list for holding deleted entries - if (_delete_list == NULL) { + if (_delete_list == nullptr) { _delete_list = new (mtClass) GrowableArray(20, mtClass); } diff --git a/src/hotspot/share/classfile/resolutionErrors.cpp b/src/hotspot/share/classfile/resolutionErrors.cpp index 8a19bd8a7f1..85bb7debb4d 100644 --- a/src/hotspot/share/classfile/resolutionErrors.cpp +++ b/src/hotspot/share/classfile/resolutionErrors.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, 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 @@ -64,7 +64,7 @@ void ResolutionErrorTable::add_entry(const constantPoolHandle& pool, int cp_inde Symbol* cause, Symbol* cause_msg) { assert_locked_or_safepoint(SystemDictionary_lock); - assert(!pool.is_null() && error != NULL, "adding NULL obj"); + assert(!pool.is_null() && error != nullptr, "adding null obj"); ResolutionErrorKey key(pool(), cp_index); ResolutionErrorEntry *entry = new ResolutionErrorEntry(error, message, cause, cause_msg); @@ -76,7 +76,7 @@ void ResolutionErrorTable::add_entry(const constantPoolHandle& pool, int cp_inde const char* message) { assert_locked_or_safepoint(SystemDictionary_lock); - assert(!pool.is_null() && message != NULL, "adding NULL obj"); + assert(!pool.is_null() && message != nullptr, "adding null obj"); ResolutionErrorKey key(pool(), cp_index); ResolutionErrorEntry *entry = new ResolutionErrorEntry(message); @@ -112,7 +112,7 @@ ResolutionErrorEntry::~ResolutionErrorEntry() { Symbol::maybe_decrement_refcount(_cause); Symbol::maybe_decrement_refcount(_cause_msg); - if (nest_host_error() != NULL) { + if (nest_host_error() != nullptr) { FREE_C_HEAP_ARRAY(char, nest_host_error()); } } diff --git a/src/hotspot/share/classfile/stackMapFrame.hpp b/src/hotspot/share/classfile/stackMapFrame.hpp index 343cd65f5a2..4e0c4f68044 100644 --- a/src/hotspot/share/classfile/stackMapFrame.hpp +++ b/src/hotspot/share/classfile/stackMapFrame.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -85,7 +85,7 @@ class StackMapFrame : public ResourceObj { _stack[i] = VerificationType::bogus_type(); } } - _verifier = NULL; + _verifier = nullptr; } public: diff --git a/src/hotspot/share/classfile/stackMapTable.cpp b/src/hotspot/share/classfile/stackMapTable.cpp index 0bdd928173a..fa2a57f96b4 100644 --- a/src/hotspot/share/classfile/stackMapTable.cpp +++ b/src/hotspot/share/classfile/stackMapTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -160,7 +160,7 @@ StackMapReader::StackMapReader(ClassVerifier* v, StackMapStream* stream, char* c int32_t StackMapReader::chop( VerificationType* locals, int32_t length, int32_t chops) { - if (locals == NULL) return -1; + if (locals == nullptr) return -1; int32_t pos = length - 1; for (int32_t i=0; iklass_name_at(class_index)); } if (tag == ITEM_UninitializedThis) { - if (flags != NULL) { + if (flags != nullptr) { *flags |= FLAG_THIS_UNINIT; } return VerificationType::uninitialized_this_type(); @@ -215,7 +215,7 @@ StackMapFrame* StackMapReader::next( StackMapFrame* pre_frame, bool first, u2 max_locals, u2 max_stack, TRAPS) { StackMapFrame* frame; int offset; - VerificationType* locals = NULL; + VerificationType* locals = nullptr; u1 frame_type = _stream->get_u1(CHECK_NULL); if (frame_type < 64) { // same_frame @@ -232,8 +232,8 @@ StackMapFrame* StackMapReader::next( } frame = new StackMapFrame( offset, pre_frame->flags(), pre_frame->locals_size(), 0, - max_locals, max_stack, locals, NULL, _verifier); - if (first && locals != NULL) { + max_locals, max_stack, locals, nullptr, _verifier); + if (first && locals != nullptr) { frame->copy_locals(pre_frame); } return frame; @@ -254,17 +254,17 @@ StackMapFrame* StackMapReader::next( VerificationType* stack = NEW_RESOURCE_ARRAY_IN_THREAD( THREAD, VerificationType, 2); u2 stack_size = 1; - stack[0] = parse_verification_type(NULL, CHECK_VERIFY_(_verifier, NULL)); + stack[0] = parse_verification_type(nullptr, CHECK_VERIFY_(_verifier, nullptr)); if (stack[0].is_category2()) { stack[1] = stack[0].to_category2_2nd(); stack_size = 2; } check_verification_type_array_size( - stack_size, max_stack, CHECK_VERIFY_(_verifier, NULL)); + stack_size, max_stack, CHECK_VERIFY_(_verifier, nullptr)); frame = new StackMapFrame( offset, pre_frame->flags(), pre_frame->locals_size(), stack_size, max_locals, max_stack, locals, stack, _verifier); - if (first && locals != NULL) { + if (first && locals != nullptr) { frame->copy_locals(pre_frame); } return frame; @@ -275,7 +275,7 @@ StackMapFrame* StackMapReader::next( if (frame_type < SAME_LOCALS_1_STACK_ITEM_EXTENDED) { // reserved frame types _stream->stackmap_format_error( - "reserved frame type", CHECK_VERIFY_(_verifier, NULL)); + "reserved frame type", CHECK_VERIFY_(_verifier, nullptr)); } if (frame_type == SAME_LOCALS_1_STACK_ITEM_EXTENDED) { @@ -294,17 +294,17 @@ StackMapFrame* StackMapReader::next( VerificationType* stack = NEW_RESOURCE_ARRAY_IN_THREAD( THREAD, VerificationType, 2); u2 stack_size = 1; - stack[0] = parse_verification_type(NULL, CHECK_VERIFY_(_verifier, NULL)); + stack[0] = parse_verification_type(nullptr, CHECK_VERIFY_(_verifier, nullptr)); if (stack[0].is_category2()) { stack[1] = stack[0].to_category2_2nd(); stack_size = 2; } check_verification_type_array_size( - stack_size, max_stack, CHECK_VERIFY_(_verifier, NULL)); + stack_size, max_stack, CHECK_VERIFY_(_verifier, nullptr)); frame = new StackMapFrame( offset, pre_frame->flags(), pre_frame->locals_size(), stack_size, max_locals, max_stack, locals, stack, _verifier); - if (first && locals != NULL) { + if (first && locals != nullptr) { frame->copy_locals(pre_frame); } return frame; @@ -320,7 +320,7 @@ StackMapFrame* StackMapReader::next( if (chops != 0) { new_length = chop(locals, length, chops); check_verification_type_array_size( - new_length, max_locals, CHECK_VERIFY_(_verifier, NULL)); + new_length, max_locals, CHECK_VERIFY_(_verifier, nullptr)); // Recompute flags since uninitializedThis could have been chopped. flags = 0; for (int i=0; ioffset() + offset_delta + 1; } frame = new StackMapFrame( offset, flags, new_length, 0, max_locals, max_stack, - locals, NULL, _verifier); - if (first && locals != NULL) { + locals, nullptr, _verifier); + if (first && locals != nullptr) { frame->copy_locals(pre_frame); } return frame; @@ -370,7 +370,7 @@ StackMapFrame* StackMapReader::next( ++real_length; } check_verification_type_array_size( - real_length, max_locals, CHECK_VERIFY_(_verifier, NULL)); + real_length, max_locals, CHECK_VERIFY_(_verifier, nullptr)); if (first) { offset = offset_delta; } else { @@ -378,7 +378,7 @@ StackMapFrame* StackMapReader::next( } frame = new StackMapFrame( offset, flags, real_length, 0, max_locals, - max_stack, locals, NULL, _verifier); + max_stack, locals, nullptr, _verifier); return frame; } if (frame_type == FULL) { @@ -401,16 +401,16 @@ StackMapFrame* StackMapReader::next( ++real_locals_size; } check_verification_type_array_size( - real_locals_size, max_locals, CHECK_VERIFY_(_verifier, NULL)); + real_locals_size, max_locals, CHECK_VERIFY_(_verifier, nullptr)); u2 stack_size = _stream->get_u2(CHECK_NULL); int real_stack_size = 0; - VerificationType* stack = NULL; + VerificationType* stack = nullptr; if (stack_size > 0) { stack = NEW_RESOURCE_ARRAY_IN_THREAD( THREAD, VerificationType, stack_size*2); } for (i=0; istackmap_format_error( - "reserved frame type", CHECK_VERIFY_(pre_frame->verifier(), NULL)); - return NULL; + "reserved frame type", CHECK_VERIFY_(pre_frame->verifier(), nullptr)); + return nullptr; } diff --git a/src/hotspot/share/classfile/stackMapTable.hpp b/src/hotspot/share/classfile/stackMapTable.hpp index 41225df75c6..a8ec3fc45db 100644 --- a/src/hotspot/share/classfile/stackMapTable.hpp +++ b/src/hotspot/share/classfile/stackMapTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -88,13 +88,13 @@ class StackMapStream : StackObj { : _data(ah), _index(0) { } u1 get_u1(TRAPS) { - if (_data == NULL || _index >= _data->length()) { + if (_data == nullptr || _index >= _data->length()) { stackmap_format_error("access beyond the end of attribute", CHECK_0); } return _data->at(_index++); } u2 get_u2(TRAPS) { - if (_data == NULL || _index >= _data->length() - 1) { + if (_data == nullptr || _index >= _data->length() - 1) { stackmap_format_error("access beyond the end of attribute", CHECK_0); } u2 res = Bytes::get_Java_u2(_data->adr_at(_index)); @@ -102,7 +102,7 @@ class StackMapStream : StackObj { return res; } bool at_end() { - return (_data == NULL) || (_index == _data->length()); + return (_data == nullptr) || (_index == _data->length()); } static void stackmap_format_error(const char* msg, TRAPS); }; diff --git a/src/hotspot/share/classfile/stackMapTableFormat.hpp b/src/hotspot/share/classfile/stackMapTableFormat.hpp index eac9c8fd19c..10c7fd17222 100644 --- a/src/hotspot/share/classfile/stackMapTableFormat.hpp +++ b/src/hotspot/share/classfile/stackMapTableFormat.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2023, 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 @@ -210,7 +210,7 @@ class stack_map_frame { #define FRAME_TYPE_DECL(stackmap_frame_type, arg1, arg2) \ inline stackmap_frame_type* as_##stackmap_frame_type() const; \ bool is_##stackmap_frame_type() { \ - return as_##stackmap_frame_type() != NULL; \ + return as_##stackmap_frame_type() != nullptr; \ } FOR_EACH_STACKMAP_FRAME_TYPE(FRAME_TYPE_DECL, x, x) @@ -252,7 +252,7 @@ class same_frame : public stack_map_frame { } int number_of_types() const { return 0; } - verification_type_info* types() const { return NULL; } + verification_type_info* types() const { return nullptr; } bool is_valid_offset(int offset_delta) const { return is_frame_type(offset_delta_to_frame_type(offset_delta)); @@ -305,7 +305,7 @@ class same_frame_extended : public stack_map_frame { } int number_of_types() const { return 0; } - verification_type_info* types() const { return NULL; } + verification_type_info* types() const { return nullptr; } bool is_valid_offset(int offset) const { return true; } bool verify_subtype(address start, address end) const { @@ -344,7 +344,7 @@ class same_locals_1_stack_item_frame : public stack_map_frame { address addr, int offset_delta, verification_type_info* vti) { same_locals_1_stack_item_frame* sm = (same_locals_1_stack_item_frame*)addr; sm->set_offset_delta(offset_delta); - if (vti != NULL) { + if (vti != nullptr) { sm->set_type(vti); } return sm; @@ -421,7 +421,7 @@ class same_locals_1_stack_item_extended : public stack_map_frame { (same_locals_1_stack_item_extended*)addr; sm->set_frame_type(_frame_id); sm->set_offset_delta(offset_delta); - if (vti != NULL) { + if (vti != nullptr) { sm->set_type(vti); } return sm; @@ -521,7 +521,7 @@ class chop_frame : public stack_map_frame { } int number_of_types() const { return 0; } - verification_type_info* types() const { return NULL; } + verification_type_info* types() const { return nullptr; } bool is_valid_offset(int offset) { return true; } bool verify_subtype(address start, address end) const { @@ -568,7 +568,7 @@ class append_frame : public stack_map_frame { append_frame* sm = (append_frame*)addr; sm->set_appends(appends); sm->set_offset_delta(offset_delta); - if (types != NULL) { + if (types != nullptr) { verification_type_info* cur = sm->types(); for (int i = 0; i < appends; ++i) { cur->copy_from(types); @@ -680,7 +680,7 @@ class full_frame : public stack_map_frame { sm->set_frame_type(_frame_id); sm->set_offset_delta(offset_delta); sm->set_num_locals(num_locals); - if (locals != NULL) { + if (locals != nullptr) { verification_type_info* cur = sm->locals(); for (int i = 0; i < num_locals; ++i) { cur->copy_from(locals); @@ -822,13 +822,13 @@ class full_frame : public stack_map_frame { #define VIRTUAL_DISPATCH(stack_frame_type, func_name, args) \ stack_frame_type* item_##stack_frame_type = as_##stack_frame_type(); \ - if (item_##stack_frame_type != NULL) { \ + if (item_##stack_frame_type != nullptr) { \ return item_##stack_frame_type->func_name args; \ } #define VOID_VIRTUAL_DISPATCH(stack_frame_type, func_name, args) \ stack_frame_type* item_##stack_frame_type = as_##stack_frame_type(); \ - if (item_##stack_frame_type != NULL) { \ + if (item_##stack_frame_type != nullptr) { \ item_##stack_frame_type->func_name args; \ return; \ } @@ -855,7 +855,7 @@ int stack_map_frame::number_of_types() const { verification_type_info* stack_map_frame::types() const { FOR_EACH_STACKMAP_FRAME_TYPE(VIRTUAL_DISPATCH, types, ()); - return NULL; + return nullptr; } bool stack_map_frame::is_valid_offset(int offset) const { @@ -887,7 +887,7 @@ stack_frame_type* stack_map_frame::as_##stack_frame_type() const { \ if (stack_frame_type::is_frame_type(frame_type())) { \ return (stack_frame_type*)this; \ } else { \ - return NULL; \ + return nullptr; \ } \ } diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index a0e10376a93..159f7243252 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -99,7 +99,7 @@ static SharedStringTable _shared_table; // -------------------------------------------------------------------------- typedef ConcurrentHashTable StringTableHash; -static StringTableHash* _local_table = NULL; +static StringTableHash* _local_table = nullptr; volatile bool StringTable::_has_work = false; volatile bool StringTable::_needs_rehashing = false; @@ -124,7 +124,7 @@ class StringTableConfig : public StackObj { static uintx get_hash(Value const& value, bool* is_dead) { oop val_oop = value.peek(); - if (val_oop == NULL) { + if (val_oop == nullptr) { *is_dead = true; return 0; } @@ -133,7 +133,7 @@ class StringTableConfig : public StackObj { // All String oops are hashed as unicode int length; jchar* chars = java_lang_String::as_unicode_string_or_null(val_oop, length); - if (chars != NULL) { + if (chars != nullptr) { return hash_string(chars, length, _alt_hash); } vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "get hash from oop"); @@ -168,7 +168,7 @@ class StringTableLookupJchar : StackObj { } bool equals(WeakHandle* value, bool* is_dead) { oop val_oop = value->peek(); - if (val_oop == NULL) { + if (val_oop == nullptr) { // dead oop, mark this hash dead for cleaning *is_dead = true; return false; @@ -200,7 +200,7 @@ class StringTableLookupOop : public StackObj { bool equals(WeakHandle* value, bool* is_dead) { oop val_oop = value->peek(); - if (val_oop == NULL) { + if (val_oop == nullptr) { // dead oop, mark this hash dead for cleaning *is_dead = true; return false; @@ -262,7 +262,7 @@ oop StringTable::lookup(Symbol* symbol) { oop StringTable::lookup(const jchar* name, int len) { unsigned int hash = java_lang_String::hash_code(name, len); oop string = lookup_shared(name, len, hash); - if (string != NULL) { + if (string != nullptr) { return string; } if (_alt_hash) { @@ -278,7 +278,7 @@ class StringTableGet : public StackObj { StringTableGet(Thread* thread) : _thread(thread) {} void operator()(WeakHandle* val) { oop result = val->resolve(); - assert(result != NULL, "Result should be reachable"); + assert(result != nullptr, "Result should be reachable"); _return = Handle(_thread, result); } oop get_res_oop() { @@ -298,7 +298,7 @@ oop StringTable::do_lookup(const jchar* name, int len, uintx hash) { // Interning oop StringTable::intern(Symbol* symbol, TRAPS) { - if (symbol == NULL) return NULL; + if (symbol == nullptr) return nullptr; ResourceMark rm(THREAD); int length; jchar* chars = symbol->as_unicode(length); @@ -308,7 +308,7 @@ oop StringTable::intern(Symbol* symbol, TRAPS) { } oop StringTable::intern(oop string, TRAPS) { - if (string == NULL) return NULL; + if (string == nullptr) return nullptr; ResourceMark rm(THREAD); int length; Handle h_string (THREAD, string); @@ -319,7 +319,7 @@ oop StringTable::intern(oop string, TRAPS) { } oop StringTable::intern(const char* utf8_string, TRAPS) { - if (utf8_string == NULL) return NULL; + if (utf8_string == nullptr) return nullptr; ResourceMark rm(THREAD); int length = UTF8::unicode_length(utf8_string); jchar* chars = NEW_RESOURCE_ARRAY(jchar, length); @@ -333,14 +333,14 @@ oop StringTable::intern(Handle string_or_null_h, const jchar* name, int len, TRA // shared table always uses java_lang_String::hash_code unsigned int hash = java_lang_String::hash_code(name, len); oop found_string = lookup_shared(name, len, hash); - if (found_string != NULL) { + if (found_string != nullptr) { return found_string; } if (_alt_hash) { hash = hash_string(name, len, true); } found_string = do_lookup(name, len, hash); - if (found_string != NULL) { + if (found_string != nullptr) { return found_string; } return do_intern(string_or_null_h, name, len, hash, THREAD); @@ -424,7 +424,7 @@ struct StringTableDeleteCheck : StackObj { bool operator()(WeakHandle* val) { ++_item; oop tmp = val->peek(); - if (tmp == NULL) { + if (tmp == nullptr) { ++_count; return true; } else { @@ -549,7 +549,7 @@ void StringTable::rehash_table() { // Statistics static size_t literal_size(oop obj) { - if (obj == NULL) { + if (obj == nullptr) { return 0; } @@ -566,7 +566,7 @@ static size_t literal_size(oop obj) { struct SizeFunc : StackObj { size_t operator()(WeakHandle* val) { oop s = val->peek(); - if (s == NULL) { + if (s == nullptr) { // Dead return 0; } @@ -596,7 +596,7 @@ class VerifyStrings : StackObj { public: bool operator()(WeakHandle* val) { oop s = val->peek(); - if (s != NULL) { + if (s != nullptr) { assert(java_lang_String::length(s) >= 0, "Length on string must work."); } return true; @@ -626,7 +626,7 @@ class VerifyCompStrings : StackObj { VerifyCompStrings() : _table(unsigned(_items_count / 8) + 1), _errors(0) {} bool operator()(WeakHandle* val) { oop s = val->resolve(); - if (s == NULL) { + if (s == nullptr) { return true; } bool created; @@ -680,7 +680,7 @@ class PrintString : StackObj { PrintString(Thread* thr, outputStream* st) : _thr(thr), _st(st) {} bool operator()(WeakHandle* val) { oop s = val->peek(); - if (s == NULL) { + if (s == nullptr) { return true; } print_string(_thr, _st, s); @@ -694,7 +694,7 @@ class PrintSharedString : StackObj { public: PrintSharedString(Thread* thr, outputStream* st) : _thr(thr), _st(st) {} void do_value(oop s) { - if (s == NULL) { + if (s == nullptr) { return; } print_string(_thr, _st, s); @@ -759,15 +759,15 @@ oop StringTable::create_archived_string(oop s) { assert(java_lang_String::is_instance(s), "sanity"); assert(!HeapShared::is_archived_object_during_dumptime(s), "sanity"); - oop new_s = NULL; + oop new_s = nullptr; typeArrayOop v = java_lang_String::value_no_keepalive(s); typeArrayOop new_v = (typeArrayOop)HeapShared::archive_object(v); - if (new_v == NULL) { - return NULL; + if (new_v == nullptr) { + return nullptr; } new_s = HeapShared::archive_object(s); - if (new_s == NULL) { - return NULL; + if (new_s == nullptr) { + return nullptr; } // adjust the pointer to the 'value' field in the new String oop @@ -794,10 +794,10 @@ private: public: CopyToArchive(CompactHashtableWriter* writer) : _writer(writer) {} bool do_entry(oop s, bool value_ignored) { - assert(s != NULL, "sanity"); + assert(s != nullptr, "sanity"); unsigned int hash = java_lang_String::hash_code(s); oop new_s = StringTable::create_archived_string(s); - if (new_s == NULL) { + if (new_s == nullptr) { return true; } diff --git a/src/hotspot/share/classfile/stringTable.hpp b/src/hotspot/share/classfile/stringTable.hpp index e8af9400905..bb30aee2eb8 100644 --- a/src/hotspot/share/classfile/stringTable.hpp +++ b/src/hotspot/share/classfile/stringTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -105,11 +105,11 @@ class StringTable : public CHeapObj{ // Sharing private: - static oop lookup_shared(const jchar* name, int len, unsigned int hash) NOT_CDS_JAVA_HEAP_RETURN_(NULL); + static oop lookup_shared(const jchar* name, int len, unsigned int hash) NOT_CDS_JAVA_HEAP_RETURN_(nullptr); public: - static oop lookup_shared(const jchar* name, int len) NOT_CDS_JAVA_HEAP_RETURN_(NULL); + static oop lookup_shared(const jchar* name, int len) NOT_CDS_JAVA_HEAP_RETURN_(nullptr); static size_t shared_entry_count() NOT_CDS_JAVA_HEAP_RETURN_(0); - static oop create_archived_string(oop s) NOT_CDS_JAVA_HEAP_RETURN_(NULL); + static oop create_archived_string(oop s) NOT_CDS_JAVA_HEAP_RETURN_(nullptr); static void write_to_archive(const DumpedInternedStrings* dumped_interned_strings) NOT_CDS_JAVA_HEAP_RETURN; static void serialize_shared_table_header(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; static void transfer_shared_strings_to_local_table() NOT_CDS_JAVA_HEAP_RETURN; diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp index 8eae3255904..0c0d63204f1 100644 --- a/src/hotspot/share/classfile/symbolTable.cpp +++ b/src/hotspot/share/classfile/symbolTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -76,7 +76,7 @@ static OffsetCompactHashtable< // -------------------------------------------------------------------------- typedef ConcurrentHashTable SymbolTableHash; -static SymbolTableHash* _local_table = NULL; +static SymbolTableHash* _local_table = nullptr; volatile bool SymbolTable::_has_work = 0; volatile bool SymbolTable::_needs_rehashing = false; @@ -101,7 +101,7 @@ static THREAD_LOCAL bool _lookup_shared_first = false; #endif // Static arena for symbols that are not deallocated -Arena* SymbolTable::_arena = NULL; +Arena* SymbolTable::_arena = nullptr; static uint64_t _alt_hash_seed = 0; @@ -229,11 +229,11 @@ Symbol* SymbolTable::allocate_symbol(const char* name, int len, bool c_heap) { if (c_heap) { // refcount starts as 1 sym = new (len) Symbol((const u1*)name, len, 1); - assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted"); + assert(sym != nullptr, "new should call vm_exit_out_of_memory if C_HEAP is exhausted"); } else if (DumpSharedSpaces) { // See comments inside Symbol::operator new(size_t, int) sym = new (len) Symbol((const u1*)name, len, PERM_REFCOUNT); - assert(sym != NULL, "new should call vm_exit_out_of_memory if failed to allocate symbol during DumpSharedSpaces"); + assert(sym != nullptr, "new should call vm_exit_out_of_memory if failed to allocate symbol during DumpSharedSpaces"); } else { // Allocate to global arena MutexLocker ml(SymbolArena_lock, Mutex::_no_safepoint_check_flag); // Protect arena @@ -247,8 +247,8 @@ class SymbolsDo : StackObj { public: SymbolsDo(SymbolClosure *cl) : _cl(cl) {} bool operator()(Symbol** value) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); _cl->do_symbol(value); return true; }; @@ -286,14 +286,14 @@ void SymbolTable::shared_symbols_do(SymbolClosure *cl) { Symbol* SymbolTable::lookup_dynamic(const char* name, int len, unsigned int hash) { Symbol* sym = do_lookup(name, len, hash); - assert((sym == NULL) || sym->refcount() != 0, "refcount must not be zero"); + assert((sym == nullptr) || sym->refcount() != 0, "refcount must not be zero"); return sym; } #if INCLUDE_CDS Symbol* SymbolTable::lookup_shared(const char* name, int len, unsigned int hash) { - Symbol* sym = NULL; + Symbol* sym = nullptr; if (!_shared_table.empty()) { if (_alt_hash) { // hash_code parameter may use alternate hashing algorithm but the shared table @@ -301,7 +301,7 @@ Symbol* SymbolTable::lookup_shared(const char* name, hash = hash_shared_symbol(name, len); } sym = _shared_table.lookup(name, hash, len); - if (sym == NULL && DynamicArchive::is_mapped()) { + if (sym == nullptr && DynamicArchive::is_mapped()) { sym = _dynamic_shared_table.lookup(name, hash, len); } } @@ -314,15 +314,15 @@ Symbol* SymbolTable::lookup_common(const char* name, Symbol* sym; if (_lookup_shared_first) { sym = lookup_shared(name, len, hash); - if (sym == NULL) { + if (sym == nullptr) { _lookup_shared_first = false; sym = lookup_dynamic(name, len, hash); } } else { sym = lookup_dynamic(name, len, hash); - if (sym == NULL) { + if (sym == nullptr) { sym = lookup_shared(name, len, hash); - if (sym != NULL) { + if (sym != nullptr) { _lookup_shared_first = true; } } @@ -333,7 +333,7 @@ Symbol* SymbolTable::lookup_common(const char* name, Symbol* SymbolTable::new_symbol(const char* name, int len) { unsigned int hash = hash_symbol(name, len, _alt_hash); Symbol* sym = lookup_common(name, len, hash); - if (sym == NULL) { + if (sym == nullptr) { sym = do_add_if_needed(name, len, hash, true); } assert(sym->refcount() != 0, "lookup should have incremented the count"); @@ -348,7 +348,7 @@ Symbol* SymbolTable::new_symbol(const Symbol* sym, int begin, int end) { int len = end - begin; unsigned int hash = hash_symbol(name, len, _alt_hash); Symbol* found = lookup_common(name, len, hash); - if (found == NULL) { + if (found == nullptr) { found = do_add_if_needed(name, len, hash, true); } return found; @@ -366,8 +366,8 @@ public: return _hash; } bool equals(Symbol** value, bool* is_dead) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); Symbol *sym = *value; if (sym->equals(_str, _len)) { if (sym->try_increment_refcount()) { @@ -388,10 +388,10 @@ public: class SymbolTableGet : public StackObj { Symbol* _return; public: - SymbolTableGet() : _return(NULL) {} + SymbolTableGet() : _return(nullptr) {} void operator()(Symbol** value) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); _return = *value; } Symbol* get_res_sym() const { @@ -407,7 +407,7 @@ Symbol* SymbolTable::do_lookup(const char* name, int len, uintx hash) { _local_table->get(thread, lookup, stg, &rehash_warning); update_needs_rehash(rehash_warning); Symbol* sym = stg.get_res_sym(); - assert((sym == NULL) || sym->refcount() != 0, "found dead symbol"); + assert((sym == nullptr) || sym->refcount() != 0, "found dead symbol"); return sym; } @@ -460,7 +460,7 @@ void SymbolTable::new_symbols(ClassLoaderData* loader_data, const constantPoolHa const char *name = names[i]; int len = lengths[i]; unsigned int hash = hashValues[i]; - assert(lookup_shared(name, len, hash) == NULL, "must have checked already"); + assert(lookup_shared(name, len, hash) == nullptr, "must have checked already"); Symbol* sym = do_add_if_needed(name, len, hash, c_heap); assert(sym->refcount() != 0, "lookup should have incremented the count"); cp->symbol_at_put(cp_indices[i], sym); @@ -472,7 +472,7 @@ Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, boo SymbolTableGet stg; bool clean_hint = false; bool rehash_warning = false; - Symbol* sym = NULL; + Symbol* sym = nullptr; Thread* current = Thread::current(); do { @@ -496,7 +496,7 @@ Symbol* SymbolTable::do_add_if_needed(const char* name, int len, uintx hash, boo check_concurrent_work(); } - assert((sym == NULL) || sym->refcount() != 0, "found dead symbol"); + assert((sym == nullptr) || sym->refcount() != 0, "found dead symbol"); return sym; } @@ -504,7 +504,7 @@ Symbol* SymbolTable::new_permanent_symbol(const char* name) { unsigned int hash = 0; int len = (int)strlen(name); Symbol* sym = SymbolTable::lookup_only(name, len, hash); - if (sym == NULL) { + if (sym == nullptr) { sym = do_add_if_needed(name, len, hash, false); } if (!sym->is_permanent()) { @@ -516,8 +516,8 @@ Symbol* SymbolTable::new_permanent_symbol(const char* name) { struct SizeFunc : StackObj { size_t operator()(Symbol** value) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); return (*value)->size() * HeapWordSize; }; }; @@ -546,8 +546,8 @@ void SymbolTable::print_table_statistics(outputStream* st) { class VerifySymbols : StackObj { public: bool operator()(Symbol** value) { - guarantee(value != NULL, "expected valid value"); - guarantee(*value != NULL, "value should point to a symbol"); + guarantee(value != nullptr, "expected valid value"); + guarantee(*value != nullptr, "value should point to a symbol"); Symbol* sym = *value; guarantee(sym->equals((const char*)sym->bytes(), sym->utf8_length()), "symbol must be internally consistent"); @@ -578,8 +578,8 @@ class DumpSymbol : StackObj { public: DumpSymbol(Thread* thr, outputStream* st) : _thr(thr), _st(st) {} bool operator()(Symbol** value) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); print_symbol(_st, *value); return true; }; @@ -590,7 +590,7 @@ class DumpSharedSymbol : StackObj { public: DumpSharedSymbol(outputStream* st) : _st(st) {} void do_value(Symbol* value) { - assert(value != NULL, "value should point to a symbol"); + assert(value != nullptr, "value should point to a symbol"); print_symbol(_st, value); }; }; @@ -696,8 +696,8 @@ struct SymbolTableDoDelete : StackObj { size_t _deleted; SymbolTableDoDelete() : _deleted(0) {} void operator()(Symbol** value) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); Symbol *sym = *value; assert(sym->refcount() == 0, "refcount"); _deleted++; @@ -708,8 +708,8 @@ struct SymbolTableDeleteCheck : StackObj { size_t _processed; SymbolTableDeleteCheck() : _processed(0) {} bool operator()(Symbol** value) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); _processed++; Symbol *sym = *value; return (sym->refcount() == 0); @@ -850,8 +850,8 @@ public: } } bool operator()(Symbol** value) { - assert(value != NULL, "expected valid value"); - assert(*value != NULL, "value should point to a symbol"); + assert(value != nullptr, "expected valid value"); + assert(*value != nullptr, "value should point to a symbol"); Symbol* sym = *value; size_t size = sym->size(); size_t len = sym->utf8_length(); diff --git a/src/hotspot/share/classfile/symbolTable.hpp b/src/hotspot/share/classfile/symbolTable.hpp index 1913eb9a1bf..278e529f74e 100644 --- a/src/hotspot/share/classfile/symbolTable.hpp +++ b/src/hotspot/share/classfile/symbolTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -89,7 +89,7 @@ class SymbolTable : public AllStatic { const char** name, int* lengths, int* cp_indices, unsigned int* hashValues); - static Symbol* lookup_shared(const char* name, int len, unsigned int hash) NOT_CDS_RETURN_(NULL); + static Symbol* lookup_shared(const char* name, int len, unsigned int hash) NOT_CDS_RETURN_(nullptr); static Symbol* lookup_dynamic(const char* name, int len, unsigned int hash); static Symbol* lookup_common(const char* name, int len, unsigned int hash); @@ -122,7 +122,7 @@ public: // Probing // Needed for preloading classes in signatures when compiling. // Returns the symbol is already present in symbol table, otherwise - // NULL. NO ALLOCATION IS GUARANTEED! + // null. NO ALLOCATION IS GUARANTEED! static Symbol* probe(const char* name, int len) { unsigned int ignore_hash; return lookup_only(name, len, ignore_hash); diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 2916c8db35e..2282a3ee835 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -190,7 +190,7 @@ ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, bool cre // Add a new class loader data to the graph. return ClassLoaderDataGraph::add(class_loader, true); } else { - return (class_loader() == NULL) ? ClassLoaderData::the_null_class_loader_data() : + return (class_loader() == nullptr) ? ClassLoaderData::the_null_class_loader_data() : ClassLoaderDataGraph::find_or_create(class_loader); } } @@ -227,7 +227,7 @@ bool is_parallelDefine(Handle class_loader) { // or a custom system class loader. A customer system class loader can be // specified via -Djava.system.class.loader. bool SystemDictionary::is_system_class_loader(oop class_loader) { - if (class_loader == NULL) { + if (class_loader == nullptr) { return false; } return (class_loader->klass() == vmClasses::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() || @@ -236,14 +236,14 @@ bool SystemDictionary::is_system_class_loader(oop class_loader) { // Returns true if the passed class loader is the platform class loader. bool SystemDictionary::is_platform_class_loader(oop class_loader) { - if (class_loader == NULL) { + if (class_loader == nullptr) { return false; } return (class_loader->klass() == vmClasses::jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass()); } Handle SystemDictionary::get_loader_lock_or_null(Handle class_loader) { - // If class_loader is NULL or parallelCapable, the JVM doesn't acquire a lock while loading. + // If class_loader is null or parallelCapable, the JVM doesn't acquire a lock while loading. if (is_parallelCapable(class_loader)) { return Handle(); } else { @@ -255,7 +255,7 @@ Handle SystemDictionary::get_loader_lock_or_null(Handle class_loader) { // Resolving of classes Symbol* SystemDictionary::class_name_symbol(const char* name, Symbol* exception, TRAPS) { - if (name == NULL) { + if (name == nullptr) { THROW_MSG_0(exception, "No class name given"); } if ((int)strlen(name) > Symbol::max_length()) { @@ -265,7 +265,7 @@ Symbol* SystemDictionary::class_name_symbol(const char* name, Symbol* exception, "Class name exceeds maximum length of %d: %s", Symbol::max_length(), name); - return NULL; + return nullptr; } // Callers should ensure that the name is never an illegal UTF8 string. assert(UTF8::is_legal_utf8((const unsigned char*)name, (int)strlen(name), false), @@ -301,7 +301,7 @@ static void handle_resolution_exception(Symbol* class_name, bool throw_error, TR return; // the caller will throw the incoming exception } } - // If the class is not found, ie, caller has checked that klass is NULL, throw the appropriate + // If the class is not found, ie, caller has checked that klass is null, throw the appropriate // error or exception depending on the value of throw_error. ResourceMark rm(THREAD); if (throw_error) { @@ -317,7 +317,7 @@ Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader bool throw_error, TRAPS) { Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD); // Check for pending exception or null klass, and throw exception - if (HAS_PENDING_EXCEPTION || klass == NULL) { + if (HAS_PENDING_EXCEPTION || klass == nullptr) { handle_resolution_exception(class_name, throw_error, CHECK_NULL); } return klass; @@ -329,7 +329,7 @@ Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader if (Signature::is_array(class_name)) { return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD); } else { - assert(class_name != NULL && !Signature::is_array(class_name), "must be"); + assert(class_name != nullptr && !Signature::is_array(class_name), "must be"); if (Signature::has_envelope(class_name)) { ResourceMark rm(THREAD); // Ignore wrapping L and ;. @@ -352,7 +352,7 @@ Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, ResourceMark rm(THREAD); SignatureStream ss(class_name, false); int ndims = ss.skip_array_prefix(); // skip all '['s - Klass* k = NULL; + Klass* k = nullptr; BasicType t = ss.type(); if (ss.has_envelope()) { Symbol* obj_class = ss.as_symbol(); @@ -360,7 +360,7 @@ Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, class_loader, protection_domain, CHECK_NULL); - if (k != NULL) { + if (k != nullptr) { k = k->array_klass(ndims, CHECK_NULL); } } else { @@ -408,7 +408,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* class_name, bool is_superclass, TRAPS) { - assert(super_name != NULL, "null superclass for resolving"); + assert(super_name != nullptr, "null superclass for resolving"); assert(!Signature::is_array(super_name), "invalid superclass name"); #if INCLUDE_CDS if (DumpSharedSpaces) { @@ -438,8 +438,8 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* class_name, // To support parallel loading: if class is done loading, just return the superclass // if the super_name matches class->super()->name() and if the class loaders match. // Otherwise, a LinkageError will be thrown later. - if (klassk != NULL && is_superclass && - ((quicksuperk = klassk->java_super()) != NULL) && + if (klassk != nullptr && is_superclass && + ((quicksuperk = klassk->java_super()) != nullptr) && ((quicksuperk->name() == super_name) && (quicksuperk->class_loader() == class_loader()))) { return quicksuperk; @@ -481,7 +481,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* class_name, } // Check for pending exception or null superk, and throw exception - if (HAS_PENDING_EXCEPTION || superk == NULL) { + if (HAS_PENDING_EXCEPTION || superk == nullptr) { handle_resolution_exception(super_name, true, CHECK_NULL); } @@ -518,7 +518,7 @@ static void double_lock_wait(JavaThread* thread, Handle lockObject) { assert(EnableWaitForParallelLoad, "Only called when enabling legacy parallel class loading logic " "for non-parallel capable class loaders"); - assert(lockObject() != NULL, "lockObject must be non-NULL"); + assert(lockObject() != nullptr, "lockObject must be non-null"); bool calledholdinglock = ObjectSynchronizer::current_thread_holds_lock(thread, lockObject); assert(calledholdinglock, "must hold lock for notify"); @@ -568,17 +568,17 @@ InstanceKlass* SystemDictionary::handle_parallel_loading(JavaThread* current, Handle lockObject, bool* throw_circularity_error) { PlaceholderEntry* oldprobe = PlaceholderTable::get_entry(name, loader_data); - if (oldprobe != NULL) { + if (oldprobe != nullptr) { // only need check_seen_thread once, not on each loop // 6341374 java/lang/Instrument with -Xcomp if (oldprobe->check_seen_thread(current, PlaceholderTable::LOAD_INSTANCE)) { log_circularity_error(name, oldprobe); *throw_circularity_error = true; - return NULL; + return nullptr; } else { // Wait until the first thread has finished loading this class. Also wait until all the // threads trying to load its superclass have removed their placeholders. - while (oldprobe != NULL && + while (oldprobe != nullptr && (oldprobe->instance_load_in_progress() || oldprobe->super_load_in_progress())) { // We only get here if the application has released the @@ -599,12 +599,12 @@ InstanceKlass* SystemDictionary::handle_parallel_loading(JavaThread* current, } else if (EnableWaitForParallelLoad) { double_lock_wait(current, lockObject); } else { - return NULL; + return nullptr; } // Check if classloading completed while we were waiting InstanceKlass* check = loader_data->dictionary()->find_class(current, name); - if (check != NULL) { + if (check != nullptr) { // Klass is already loaded, so just return it return check; } @@ -613,12 +613,12 @@ InstanceKlass* SystemDictionary::handle_parallel_loading(JavaThread* current, } } } - return NULL; + return nullptr; } void SystemDictionary::post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld) { - assert(event != NULL, "invariant"); - assert(k != NULL, "invariant"); + assert(event != nullptr, "invariant"); + assert(k != nullptr, "invariant"); event->set_loadedClass(k); event->set_definingClassLoader(k->class_loader_data()); event->set_initiatingClassLoader(init_cld); @@ -629,13 +629,13 @@ void SystemDictionary::post_class_load_event(EventClassLoad* event, const Instan // After checking if the InstanceKlass already exists, it checks for ClassCircularityError and // whether the thread must wait for loading in parallel. It eventually calls load_instance_class, // which will load the class via the bootstrap loader or call ClassLoader.loadClass(). -// This can return NULL, an exception or an InstanceKlass. +// This can return null, an exception or an InstanceKlass. InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, Handle class_loader, Handle protection_domain, TRAPS) { // name must be in the form of "java/lang/Object" -- cannot be "Ljava/lang/Object;" - assert(name != NULL && !Signature::is_array(name) && + assert(name != nullptr && !Signature::is_array(name) && !Signature::has_envelope(name), "invalid class name"); EventClassLoad class_load_start_event; @@ -653,7 +653,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, // All subsequent calls use find_class, and set loaded_class so that // before we return a result, we call out to java to check for valid protection domain. InstanceKlass* probe = dictionary->find(THREAD, name, protection_domain); - if (probe != NULL) return probe; + if (probe != nullptr) return probe; // Non-bootstrap class loaders will call out to class loader and // define via jvm/jni_DefineClass which will acquire the @@ -668,8 +668,8 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, ObjectLocker ol(lockObject, THREAD); bool super_load_in_progress = false; - InstanceKlass* loaded_class = NULL; - Symbol* superclassname = NULL; + InstanceKlass* loaded_class = nullptr; + Symbol* superclassname = nullptr; assert(THREAD->can_call_java(), "can not load classes with compiler thread: class=%s, classloader=%s", @@ -680,15 +680,15 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, { MutexLocker mu(THREAD, SystemDictionary_lock); InstanceKlass* check = dictionary->find_class(THREAD, name); - if (check != NULL) { + if (check != nullptr) { // InstanceKlass is already loaded, but we still need to check protection domain below. loaded_class = check; } else { PlaceholderEntry* placeholder = PlaceholderTable::get_entry(name, loader_data); - if (placeholder != NULL && placeholder->super_load_in_progress()) { + if (placeholder != nullptr && placeholder->super_load_in_progress()) { super_load_in_progress = true; superclassname = placeholder->supername(); - assert(superclassname != NULL, "superclass has to have a name"); + assert(superclassname != nullptr, "superclass has to have a name"); } } } @@ -703,7 +703,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, } bool throw_circularity_error = false; - if (loaded_class == NULL) { + if (loaded_class == nullptr) { bool load_placeholder_added = false; // Add placeholder entry to record loading instance class @@ -735,16 +735,16 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, // Recheck if the class has been loaded for all class loader cases and // add a LOAD_INSTANCE placeholder while holding the SystemDictionary_lock. - if (!throw_circularity_error && loaded_class == NULL) { + if (!throw_circularity_error && loaded_class == nullptr) { InstanceKlass* check = dictionary->find_class(THREAD, name); - if (check != NULL) { + if (check != nullptr) { loaded_class = check; } else if (needs_load_placeholder(class_loader)) { // Add the LOAD_INSTANCE token. Threads will wait on loading to complete for this thread, // and check for ClassCircularityError with -Xcomp. PlaceholderEntry* newprobe = PlaceholderTable::find_and_add(name, loader_data, PlaceholderTable::LOAD_INSTANCE, - NULL, + nullptr, THREAD); load_placeholder_added = true; } @@ -763,7 +763,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, // you need to find_and_remove it before returning. // So be careful to not exit with a CHECK_ macro between these calls. - if (loaded_class == NULL) { + if (loaded_class == nullptr) { // Do actual loading loaded_class = load_instance_class(name, class_loader, THREAD); } @@ -778,8 +778,8 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, } } - if (HAS_PENDING_EXCEPTION || loaded_class == NULL) { - return NULL; + if (HAS_PENDING_EXCEPTION || loaded_class == nullptr) { + return nullptr; } if (class_load_start_event.should_commit()) { @@ -790,7 +790,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, DEBUG_ONLY(verify_dictionary_entry(name, loaded_class)); // Check if the protection domain is present it has the right access - if (protection_domain() != NULL) { + if (protection_domain() != nullptr) { // Verify protection domain. If it fails an exception is thrown dictionary->validate_protection_domain(loaded_class, class_loader, protection_domain, CHECK_NULL); } @@ -821,10 +821,10 @@ InstanceKlass* SystemDictionary::find_instance_klass(Thread* current, oop class_loader_oop = java_lang_ClassLoader::non_reflection_class_loader(class_loader()); ClassLoaderData* loader_data = ClassLoaderData::class_loader_data_or_null(class_loader_oop); - if (loader_data == NULL) { + if (loader_data == nullptr) { // If the ClassLoaderData has not been setup, // then the class loader has no entries in the dictionary. - return NULL; + return nullptr; } Dictionary* dictionary = loader_data->dictionary(); @@ -832,13 +832,13 @@ InstanceKlass* SystemDictionary::find_instance_klass(Thread* current, } // Look for a loaded instance or array klass by name. Do not do any loading. -// return NULL in case of error. +// return null in case of error. Klass* SystemDictionary::find_instance_or_array_klass(Thread* current, Symbol* class_name, Handle class_loader, Handle protection_domain) { - Klass* k = NULL; - assert(class_name != NULL, "class name must be non NULL"); + Klass* k = nullptr; + assert(class_name != nullptr, "class name must be non nullptr"); if (Signature::is_array(class_name)) { // The name refers to an array. Parse the name. @@ -852,7 +852,7 @@ Klass* SystemDictionary::find_instance_or_array_klass(Thread* current, } else { k = SystemDictionary::find_instance_klass(current, ss.as_symbol(), class_loader, protection_domain); } - if (k != NULL) { + if (k != nullptr) { k = k->array_klass_or_null(ndims); } } else { @@ -881,7 +881,7 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream( bool create_mirror_cld = !cl_info.is_strong_hidden(); loader_data = register_loader(class_loader, create_mirror_cld); - assert(st != NULL, "invariant"); + assert(st != nullptr, "invariant"); assert(st->need_verify(), "invariant"); // Parse stream and create a klass. @@ -890,7 +890,7 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream( loader_data, cl_info, CHECK_NULL); - assert(k != NULL, "no klass created"); + assert(k != nullptr, "no klass created"); // Hidden classes that are not strong must update ClassLoaderData holder // so that they can be unloaded when the mirror is no longer referenced. @@ -920,10 +920,10 @@ InstanceKlass* SystemDictionary::resolve_hidden_class_from_stream( // Add a klass to the system from a stream (called by jni_DefineClass and // JVM_DefineClass). -// Note: class_name can be NULL. In that case we do not know the name of +// Note: class_name can be null. In that case we do not know the name of // the class until we have parsed the stream. // This function either returns an InstanceKlass or throws an exception. It does -// not return NULL without a pending exception. +// not return null without a pending exception. InstanceKlass* SystemDictionary::resolve_class_from_stream( ClassFileStream* st, Symbol* class_name, @@ -944,7 +944,7 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream( // Note that we do this even though this klass might // already be present in the SystemDictionary, otherwise we would not // throw potential ClassFormatErrors. - InstanceKlass* k = NULL; + InstanceKlass* k = nullptr; #if INCLUDE_CDS if (!DumpSharedSpaces) { @@ -956,13 +956,13 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream( } #endif - if (k == NULL) { + if (k == nullptr) { k = KlassFactory::create_from_stream(st, class_name, loader_data, cl_info, CHECK_NULL); } - assert(k != NULL, "no klass created"); + assert(k != nullptr, "no klass created"); Symbol* h_name = k->name(); - assert(class_name == NULL || class_name == h_name, "name mismatch"); + assert(class_name == nullptr || class_name == h_name, "name mismatch"); // Add class just loaded // If a class loader supports parallel classloading, handle parallel define requests. @@ -975,9 +975,9 @@ InstanceKlass* SystemDictionary::resolve_class_from_stream( // If defining the class throws an exception register 'k' for cleanup. if (HAS_PENDING_EXCEPTION) { - assert(k != NULL, "Must have an instance klass here!"); + assert(k != nullptr, "Must have an instance klass here!"); loader_data->add_to_deallocate_list(k); - return NULL; + return nullptr; } } @@ -1012,7 +1012,7 @@ bool SystemDictionary::is_shared_class_visible(Symbol* class_name, // (1) Check if we are loading into the same loader as in dump time. if (ik->is_shared_boot_class()) { - if (class_loader() != NULL) { + if (class_loader() != nullptr) { return false; } } else if (ik->is_shared_platform_class()) { @@ -1053,7 +1053,7 @@ bool SystemDictionary::is_shared_class_visible_impl(Symbol* class_name, assert(scp_index >= 0, "must be"); SharedClassPathEntry* scp_entry = FileMapInfo::shared_path(scp_index); if (!Universe::is_module_initialized()) { - assert(scp_entry != NULL, "must be"); + assert(scp_entry != nullptr, "must be"); // At this point, no modules have been defined yet. KlassSubGraphInfo::check_allowed_klass() // has restricted the classes can be loaded at this step to be only: // [1] scp_entry->is_modules_image(): classes in java.base, or, @@ -1064,17 +1064,17 @@ bool SystemDictionary::is_shared_class_visible_impl(Symbol* class_name, return true; } - if (pkg_entry == NULL) { + if (pkg_entry == nullptr) { // We might have looked up pkg_entry before the module system was initialized. // Need to reload it now. TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name); - if (pkg_name != NULL) { + if (pkg_name != nullptr) { pkg_entry = class_loader_data(class_loader)->packages()->lookup_only(pkg_name); } } - ModuleEntry* mod_entry = (pkg_entry == NULL) ? NULL : pkg_entry->module(); - bool should_be_in_named_module = (mod_entry != NULL && mod_entry->is_named()); + ModuleEntry* mod_entry = (pkg_entry == nullptr) ? nullptr : pkg_entry->module(); + bool should_be_in_named_module = (mod_entry != nullptr && mod_entry->is_named()); bool was_archived_from_named_module = scp_entry->in_named_module(); bool visible; @@ -1111,8 +1111,8 @@ bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, Insta // Quick check if the super type has been already loaded. // + Don't do it for unregistered classes -- they can be unloaded so // super_type->class_loader_data() could be stale. - // + Don't check if loader data is NULL, ie. the super_type isn't fully loaded. - if (!super_type->is_shared_unregistered_class() && super_type->class_loader_data() != NULL) { + // + Don't check if loader data is null, ie. the super_type isn't fully loaded. + if (!super_type->is_shared_unregistered_class() && super_type->class_loader_data() != nullptr) { // Check if the superclass is loaded by the current class_loader Symbol* name = super_type->name(); InstanceKlass* check = find_instance_klass(THREAD, name, class_loader, protection_domain); @@ -1141,7 +1141,7 @@ bool SystemDictionary::check_shared_class_super_types(InstanceKlass* ik, Handle // If unexpected superclass or interfaces are found, we cannot // load from the shared archive. - if (ik->super() != NULL && + if (ik->super() != nullptr && !check_shared_class_super_type(ik, InstanceKlass::cast(ik->super()), class_loader, protection_domain, true, THREAD)) { return false; @@ -1170,14 +1170,14 @@ InstanceKlass* SystemDictionary::load_shared_lambda_proxy_class(InstanceKlass* i if (s != shared_nest_host) { // The dynamically resolved nest_host is not the same as the one we used during dump time, // so we cannot use ik. - return NULL; + return nullptr; } else { assert(s->is_shared(), "must be"); } - InstanceKlass* loaded_ik = load_shared_class(ik, class_loader, protection_domain, NULL, pkg_entry, CHECK_NULL); + InstanceKlass* loaded_ik = load_shared_class(ik, class_loader, protection_domain, nullptr, pkg_entry, CHECK_NULL); - if (loaded_ik != NULL) { + if (loaded_ik != nullptr) { assert(shared_nest_host->is_same_class_package(ik), "lambda proxy class and its nest host must be in the same package"); } @@ -1197,26 +1197,26 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik, const ClassFileStream *cfs, PackageEntry* pkg_entry, TRAPS) { - assert(ik != NULL, "sanity"); + assert(ik != nullptr, "sanity"); assert(!ik->is_unshareable_info_restored(), "shared class can be loaded only once"); Symbol* class_name = ik->name(); if (!is_shared_class_visible(class_name, ik, pkg_entry, class_loader)) { - return NULL; + return nullptr; } if (!check_shared_class_super_types(ik, class_loader, protection_domain, THREAD)) { - return NULL; + return nullptr; } - InstanceKlass* new_ik = NULL; + InstanceKlass* new_ik = nullptr; // CFLH check is skipped for VM hidden classes (see KlassFactory::create_from_stream). // It will be skipped for shared VM hidden lambda proxy classes. if (!SystemDictionaryShared::is_hidden_lambda_proxy(ik)) { new_ik = KlassFactory::check_shared_class_file_load_hook( ik, class_name, class_loader, protection_domain, cfs, CHECK_NULL); } - if (new_ik != NULL) { + if (new_ik != nullptr) { // The class is changed by CFLH. Return the new class. The shared class is // not used. return new_ik; @@ -1248,7 +1248,7 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik, } void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data) { - ik->print_class_load_logging(loader_data, NULL, NULL); + ik->print_class_load_logging(loader_data, nullptr, nullptr); // For boot loader, ensure that GetSystemPackage knows that a class in this // package was loaded. @@ -1267,12 +1267,12 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha if (class_loader.is_null()) { ResourceMark rm(THREAD); - PackageEntry* pkg_entry = NULL; + PackageEntry* pkg_entry = nullptr; bool search_only_bootloader_append = false; // Find the package in the boot loader's package entry table. TempNewSymbol pkg_name = ClassLoader::package_from_class_name(class_name); - if (pkg_name != NULL) { + if (pkg_name != nullptr) { pkg_entry = class_loader_data(class_loader)->packages()->lookup_only(pkg_name); } @@ -1284,7 +1284,7 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha // java.base packages in the boot loader's PackageEntryTable. // No class outside of java.base is allowed to be loaded during // this bootstrapping window. - if (pkg_entry == NULL || pkg_entry->in_unnamed_module()) { + if (pkg_entry == nullptr || pkg_entry->in_unnamed_module()) { // Class is either in the unnamed package or in // a named package within the unnamed module. Either // case is outside of java.base, do not attempt to @@ -1293,20 +1293,20 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha // and its package will be checked later by // ModuleEntryTable::verify_javabase_packages. if (ModuleEntryTable::javabase_defined()) { - return NULL; + return nullptr; } } else { // Check that the class' package is defined within java.base. ModuleEntry* mod_entry = pkg_entry->module(); Symbol* mod_entry_name = mod_entry->name(); if (mod_entry_name->fast_compare(vmSymbols::java_base()) != 0) { - return NULL; + return nullptr; } } } else { // After the module system has been initialized, check if the class' // package is in a module defined to the boot loader. - if (pkg_name == NULL || pkg_entry == NULL || pkg_entry->in_unnamed_module()) { + if (pkg_name == nullptr || pkg_entry == nullptr || pkg_entry->in_unnamed_module()) { // Class is either in the unnamed package, in a named package // within a module not defined to the boot loader or in a // a named package within the unnamed module. In all cases, @@ -1315,7 +1315,7 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha if (!ClassLoader::has_bootclasspath_append()) { // If there is no bootclasspath append entry, no need to continue // searching. - return NULL; + return nullptr; } search_only_bootloader_append = true; } @@ -1328,28 +1328,28 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha "Attempt to load a class outside of boot loader's module path"); // Search for classes in the CDS archive. - InstanceKlass* k = NULL; + InstanceKlass* k = nullptr; #if INCLUDE_CDS if (UseSharedSpaces) { PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time()); InstanceKlass* ik = SystemDictionaryShared::find_builtin_class(class_name); - if (ik != NULL && ik->is_shared_boot_class() && !ik->shared_loading_failed()) { + if (ik != nullptr && ik->is_shared_boot_class() && !ik->shared_loading_failed()) { SharedClassLoadingMark slm(THREAD, ik); - k = load_shared_class(ik, class_loader, Handle(), NULL, pkg_entry, CHECK_NULL); + k = load_shared_class(ik, class_loader, Handle(), nullptr, pkg_entry, CHECK_NULL); } } #endif - if (k == NULL) { + if (k == nullptr) { // Use VM class loader PerfTraceTime vmtimer(ClassLoader::perf_sys_classload_time()); k = ClassLoader::load_class(class_name, search_only_bootloader_append, CHECK_NULL); } // find_or_define_instance_class may return a different InstanceKlass - if (k != NULL) { + if (k != nullptr) { CDS_ONLY(SharedClassLoadingMark slm(THREAD, k);) k = find_or_define_instance_class(class_name, class_loader, k, CHECK_NULL); } @@ -1391,7 +1391,7 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha // Primitive classes return null since forName() can not be // used to obtain any of the Class objects representing primitives or void - if ((obj != NULL) && !(java_lang_Class::is_primitive(obj))) { + if ((obj != nullptr) && !(java_lang_Class::is_primitive(obj))) { InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(obj)); // For user defined Java class loaders, check that the name returned is // the same as that requested. This check is done for the bootstrap @@ -1400,8 +1400,8 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha return k; } } - // Class is not found or has the wrong name, return NULL - return NULL; + // Class is not found or has the wrong name, return null + return nullptr; } } @@ -1413,7 +1413,7 @@ InstanceKlass* SystemDictionary::load_instance_class(Symbol* name, // If everything was OK (no exceptions, no null return value), and // class_loader is NOT the defining loader, do a little more bookkeeping. - if (loaded_class != NULL && + if (loaded_class != nullptr && loaded_class->class_loader() != class_loader()) { ClassLoaderData* loader_data = class_loader_data(class_loader); @@ -1480,7 +1480,7 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, Handle class_load // fail with an OutOfMemoryError (if it does, we will *not* put this // class in the dictionary and will not update the class hierarchy). // JVMTI FollowReferences needs to find the classes this way. - if (k->class_loader() != NULL) { + if (k->class_loader() != nullptr) { methodHandle m(THREAD, Universe::loader_addClass_method()); JavaValue result(T_VOID); JavaCallArguments args(class_loader); @@ -1540,31 +1540,31 @@ InstanceKlass* SystemDictionary::find_or_define_helper(Symbol* class_name, Handl // First check if class already defined if (is_parallelDefine(class_loader)) { InstanceKlass* check = dictionary->find_class(THREAD, name_h); - if (check != NULL) { + if (check != nullptr) { return check; } } // Acquire define token for this class/classloader PlaceholderEntry* probe = PlaceholderTable::find_and_add(name_h, loader_data, - PlaceholderTable::DEFINE_CLASS, NULL, THREAD); + PlaceholderTable::DEFINE_CLASS, nullptr, THREAD); // Wait if another thread defining in parallel // All threads wait - even those that will throw duplicate class: otherwise // caller is surprised by LinkageError: duplicate, but findLoadedClass fails // if other thread has not finished updating dictionary - while (probe->definer() != NULL) { + while (probe->definer() != nullptr) { SystemDictionary_lock->wait(); } // Only special cases allow parallel defines and can use other thread's results // Other cases fall through, and may run into duplicate defines // caught by finding an entry in the SystemDictionary - if (is_parallelDefine(class_loader) && (probe->instance_klass() != NULL)) { + if (is_parallelDefine(class_loader) && (probe->instance_klass() != nullptr)) { InstanceKlass* ik = probe->instance_klass(); PlaceholderTable::find_and_remove(name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); SystemDictionary_lock->notify_all(); #ifdef ASSERT InstanceKlass* check = dictionary->find_class(THREAD, name_h); - assert(check != NULL, "definer missed recording success"); + assert(check != nullptr, "definer missed recording success"); #endif return ik; } else { @@ -1579,16 +1579,16 @@ InstanceKlass* SystemDictionary::find_or_define_helper(Symbol* class_name, Handl { MutexLocker mu(THREAD, SystemDictionary_lock); PlaceholderEntry* probe = PlaceholderTable::get_entry(name_h, loader_data); - assert(probe != NULL, "DEFINE_CLASS placeholder lost?"); + assert(probe != nullptr, "DEFINE_CLASS placeholder lost?"); if (!HAS_PENDING_EXCEPTION) { probe->set_instance_klass(k); } - probe->set_definer(NULL); + probe->set_definer(nullptr); PlaceholderTable::find_and_remove(name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); SystemDictionary_lock->notify_all(); } - return HAS_PENDING_EXCEPTION ? NULL : k; + return HAS_PENDING_EXCEPTION ? nullptr : k; } // If a class loader supports parallel classloading handle parallel define requests. @@ -1599,10 +1599,10 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam // Clean up original InstanceKlass if duplicate or error if (!HAS_PENDING_EXCEPTION && defined_k != k) { // If a parallel capable class loader already defined this class, register 'k' for cleanup. - assert(defined_k != NULL, "Should have a klass if there's no exception"); + assert(defined_k != nullptr, "Should have a klass if there's no exception"); k->class_loader_data()->add_to_deallocate_list(k); } else if (HAS_PENDING_EXCEPTION) { - assert(defined_k == NULL, "Should not have a klass if there's an exception"); + assert(defined_k == nullptr, "Should not have a klass if there's an exception"); k->class_loader_data()->add_to_deallocate_list(k); } return defined_k; @@ -1615,7 +1615,7 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam // before a new class is used. void SystemDictionary::add_to_hierarchy(InstanceKlass* k) { - assert(k != NULL, "just checking"); + assert(k != nullptr, "just checking"); if (Universe::is_fully_initialized()) { assert_locked_or_safepoint(Compile_lock); } @@ -1650,10 +1650,10 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer) { // First, mark for unload all ClassLoaderData referencing a dead class loader. unloading_occurred = ClassLoaderDataGraph::do_unloading(); if (unloading_occurred) { - MutexLocker ml2(is_concurrent ? Module_lock : NULL); + MutexLocker ml2(is_concurrent ? Module_lock : nullptr); JFR_ONLY(Jfr::on_unloading_classes();) MANAGEMENT_ONLY(FinalizerService::purge_unloaded();) - MutexLocker ml1(is_concurrent ? SystemDictionary_lock : NULL); + MutexLocker ml1(is_concurrent ? SystemDictionary_lock : nullptr); ClassLoaderDataGraph::clean_module_and_package_info(); LoaderConstraintTable::purge_loader_constraints(); ResolutionErrorTable::purge_resolution_errors(); @@ -1676,7 +1676,7 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer) { assert(ProtectionDomainCacheTable::number_of_entries() == 0, "should be empty"); } - MutexLocker ml(is_concurrent ? ClassInitError_lock : NULL); + MutexLocker ml(is_concurrent ? ClassInitError_lock : nullptr); InstanceKlass::clean_initialization_error_table(); } @@ -1740,7 +1740,7 @@ void SystemDictionary::check_constraints(InstanceKlass* k, MutexLocker mu(THREAD, SystemDictionary_lock); InstanceKlass* check = loader_data->dictionary()->find_class(THREAD, name); - if (check != NULL) { + if (check != nullptr) { // If different InstanceKlass - duplicate class definition, // else - ok, class loaded by a different thread in parallel. // We should only have found it if it was done loading and ok to use. @@ -1762,7 +1762,7 @@ void SystemDictionary::check_constraints(InstanceKlass* k, ss.print(" wants to load %s %s.", k->external_kind(), k->external_name()); Klass *existing_klass = LoaderConstraintTable::find_constrained_klass(name, loader_data); - if (existing_klass != NULL && existing_klass->class_loader_data() != loader_data) { + if (existing_klass != nullptr && existing_klass->class_loader_data() != loader_data) { ss.print(" A different %s with the same name was previously loaded by %s. (%s)", existing_klass->external_kind(), existing_klass->class_loader_data()->loader_name_and_id(), @@ -1795,7 +1795,7 @@ void SystemDictionary::update_dictionary(JavaThread* current, // Make a new dictionary entry. Dictionary* dictionary = loader_data->dictionary(); InstanceKlass* sd_check = dictionary->find_class(current, name); - if (sd_check == NULL) { + if (sd_check == nullptr) { dictionary->add_klass(current, name, k); } SystemDictionary_lock->notify_all(); @@ -1813,7 +1813,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass( Handle no_protection_domain; Klass* klass = find_instance_or_array_klass(current, class_name, class_loader, no_protection_domain); - if (klass != NULL) + if (klass != nullptr) return klass; // Now look to see if it has been loaded elsewhere, and is subject to @@ -1832,7 +1832,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass( klass = LoaderConstraintTable::find_constrained_klass(ss.as_symbol(), class_loader_data(class_loader)); } // If element class already loaded, allocate array klass - if (klass != NULL) { + if (klass != nullptr) { klass = klass->array_klass_or_null(ndims); } } else { @@ -1851,7 +1851,7 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_name, ClassLoaderData* loader_data1 = class_loader_data(class_loader1); ClassLoaderData* loader_data2 = class_loader_data(class_loader2); - Symbol* constraint_name = NULL; + Symbol* constraint_name = nullptr; if (!Signature::is_array(class_name)) { constraint_name = class_name; @@ -1881,7 +1881,7 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_name, bool result = LoaderConstraintTable::add_entry(constraint_name, klass1, loader_data1, klass2, loader_data2); #if INCLUDE_CDS - if (Arguments::is_dumping_archive() && klass_being_linked != NULL && + if (Arguments::is_dumping_archive() && klass_being_linked != nullptr && !klass_being_linked->is_shared()) { SystemDictionaryShared::record_linking_constraint(constraint_name, InstanceKlass::cast(klass_being_linked), @@ -1903,7 +1903,7 @@ void SystemDictionary::add_resolution_error(const constantPoolHandle& pool, int { MutexLocker ml(Thread::current(), SystemDictionary_lock); ResolutionErrorEntry* entry = ResolutionErrorTable::find_entry(pool, which); - if (entry == NULL) { + if (entry == nullptr) { ResolutionErrorTable::add_entry(pool, which, error, message, cause, cause_msg); } } @@ -1914,20 +1914,20 @@ void SystemDictionary::delete_resolution_error(ConstantPool* pool) { ResolutionErrorTable::delete_entry(pool); } -// Lookup resolution error table. Returns error if found, otherwise NULL. +// Lookup resolution error table. Returns error if found, otherwise null. Symbol* SystemDictionary::find_resolution_error(const constantPoolHandle& pool, int which, Symbol** message, Symbol** cause, Symbol** cause_msg) { { MutexLocker ml(Thread::current(), SystemDictionary_lock); ResolutionErrorEntry* entry = ResolutionErrorTable::find_entry(pool, which); - if (entry != NULL) { + if (entry != nullptr) { *message = entry->message(); *cause = entry->cause(); *cause_msg = entry->cause_msg(); return entry->error(); } else { - return NULL; + return nullptr; } } } @@ -1943,7 +1943,7 @@ void SystemDictionary::add_nest_host_error(const constantPoolHandle& pool, { MutexLocker ml(Thread::current(), SystemDictionary_lock); ResolutionErrorEntry* entry = ResolutionErrorTable::find_entry(pool, which); - if (entry != NULL && entry->nest_host_error() == NULL) { + if (entry != nullptr && entry->nest_host_error() == nullptr) { // An existing entry means we had a true resolution failure (LinkageError) with our nest host, but we // still want to add the error message for the higher-level access checks to report. We should // only reach here under the same error condition, so we can ignore the potential race with setting @@ -1960,10 +1960,10 @@ const char* SystemDictionary::find_nest_host_error(const constantPoolHandle& poo { MutexLocker ml(Thread::current(), SystemDictionary_lock); ResolutionErrorEntry* entry = ResolutionErrorTable::find_entry(pool, which); - if (entry != NULL) { + if (entry != nullptr) { return entry->nest_host_error(); } else { - return NULL; + return nullptr; } } } @@ -2016,7 +2016,7 @@ const char* SystemDictionary::find_nest_host_error(const constantPoolHandle& poo // Make sure all class components (including arrays) in the given // signature will be resolved to the same class in both loaders. // Returns the name of the type that failed a loader constraint check, or -// NULL if no constraint failed. No exception except OOME is thrown. +// null if no constraint failed. No exception except OOME is thrown. // Arrays are not added to the loader constraint table, their elements are. Symbol* SystemDictionary::check_signature_loaders(Symbol* signature, Klass* klass_being_linked, @@ -2024,7 +2024,7 @@ Symbol* SystemDictionary::check_signature_loaders(Symbol* signature, bool is_method) { // Nothing to do if loaders are the same. if (loader1() == loader2()) { - return NULL; + return nullptr; } for (SignatureStream ss(signature, is_method); !ss.is_done(); ss.next()) { @@ -2038,7 +2038,7 @@ Symbol* SystemDictionary::check_signature_loaders(Symbol* signature, } } } - return NULL; + return nullptr; } Method* SystemDictionary::find_method_handle_intrinsic(vmIntrinsicID iid, @@ -2095,7 +2095,7 @@ static Method* unpack_method_and_appendix(Handle mname, TRAPS) { if (mname.not_null()) { Method* m = java_lang_invoke_MemberName::vmtarget(mname()); - if (m != NULL) { + if (m != nullptr) { oop appendix = appendix_box->obj_at(0); LogTarget(Info, methodhandles) lt; if (lt.develop_is_enabled()) { @@ -2103,7 +2103,7 @@ static Method* unpack_method_and_appendix(Handle mname, LogStream ls(lt); ls.print("Linked method=" INTPTR_FORMAT ": ", p2i(m)); m->print_on(&ls); - if (appendix != NULL) { ls.print("appendix = "); appendix->print_on(&ls); } + if (appendix != nullptr) { ls.print("appendix = "); appendix->print_on(&ls); } ls.cr(); } @@ -2134,10 +2134,10 @@ Method* SystemDictionary::find_method_handle_invoker(Klass* klass, oop name_oop = StringTable::intern(name, CHECK_NULL); Handle name_str (THREAD, name_oop); objArrayHandle appendix_box = oopFactory::new_objArray_handle(vmClasses::Object_klass(), 1, CHECK_NULL); - assert(appendix_box->obj_at(0) == NULL, ""); + assert(appendix_box->obj_at(0) == nullptr, ""); // This should not happen. JDK code should take care of that. - if (accessing_klass == NULL || method_type.is_null()) { + if (accessing_klass == nullptr || method_type.is_null()) { THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "bad invokehandle"); } @@ -2189,27 +2189,27 @@ Handle SystemDictionary::find_java_mirror_for_type(Symbol* signature, Handle protection_domain, SignatureStream::FailureMode failure_mode, TRAPS) { - assert(accessing_klass == NULL || (class_loader.is_null() && protection_domain.is_null()), + assert(accessing_klass == nullptr || (class_loader.is_null() && protection_domain.is_null()), "one or the other, or perhaps neither"); // What we have here must be a valid field descriptor, // and all valid field descriptors are supported. // Produce the same java.lang.Class that reflection reports. - if (accessing_klass != NULL) { + if (accessing_klass != nullptr) { class_loader = Handle(THREAD, accessing_klass->class_loader()); protection_domain = Handle(THREAD, accessing_klass->protection_domain()); } ResolvingSignatureStream ss(signature, class_loader, protection_domain, false); oop mirror_oop = ss.as_java_mirror(failure_mode, CHECK_NH); - if (mirror_oop == NULL) { + if (mirror_oop == nullptr) { return Handle(); // report failure this way } Handle mirror(THREAD, mirror_oop); - if (accessing_klass != NULL) { + if (accessing_klass != nullptr) { // Check accessibility, emulating ConstantPool::verify_constant_pool_resolve. Klass* sel_klass = java_lang_Class::as_Klass(mirror()); - if (sel_klass != NULL) { + if (sel_klass != nullptr) { LinkResolver::check_klass_accessibility(accessing_klass, sel_klass, CHECK_NH); } } @@ -2241,7 +2241,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, } Handle class_loader, protection_domain; - if (accessing_klass != NULL) { + if (accessing_klass != nullptr) { class_loader = Handle(THREAD, accessing_klass->class_loader()); protection_domain = Handle(THREAD, accessing_klass->protection_domain()); } @@ -2252,12 +2252,12 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, Handle rt; // the return type from the signature ResourceMark rm(THREAD); for (SignatureStream ss(signature); !ss.is_done(); ss.next()) { - oop mirror = NULL; + oop mirror = nullptr; if (can_be_cached) { // Use neutral class loader to lookup candidate classes to be placed in the cache. mirror = ss.as_java_mirror(Handle(), Handle(), SignatureStream::ReturnNull, CHECK_(empty)); - if (mirror == NULL || (ss.is_reference() && !is_always_visible_class(mirror))) { + if (mirror == nullptr || (ss.is_reference() && !is_always_visible_class(mirror))) { // Fall back to accessing_klass context. can_be_cached = false; } @@ -2267,16 +2267,16 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, mirror = ss.as_java_mirror(class_loader, protection_domain, SignatureStream::NCDFError, CHECK_(empty)); } - assert(mirror != NULL, "%s", ss.as_symbol()->as_C_string()); + assert(mirror != nullptr, "%s", ss.as_symbol()->as_C_string()); if (ss.at_return_type()) rt = Handle(THREAD, mirror); else pts->obj_at_put(arg++, mirror); // Check accessibility. - if (!java_lang_Class::is_primitive(mirror) && accessing_klass != NULL) { + if (!java_lang_Class::is_primitive(mirror) && accessing_klass != nullptr) { Klass* sel_klass = java_lang_Class::as_Klass(mirror); - mirror = NULL; // safety + mirror = nullptr; // safety // Emulate ConstantPool::verify_constant_pool_resolve. LinkResolver::check_klass_accessibility(accessing_klass, sel_klass, CHECK_(empty)); } @@ -2298,7 +2298,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, // We can cache this MethodType inside the JVM. MutexLocker ml(THREAD, InvokeMethodTable_lock); bool created = false; - assert(method_type != NULL, "unexpected null"); + assert(method_type != nullptr, "unexpected null"); OopHandle* h = _invoke_method_type_table.get(signature); if (h == nullptr) { signature->make_permanent(); // The signature is never unloaded. @@ -2319,7 +2319,7 @@ Handle SystemDictionary::find_field_handle_type(Symbol* signature, SignatureStream ss(signature, /*is_method=*/ false); if (!ss.is_done()) { Handle class_loader, protection_domain; - if (accessing_klass != NULL) { + if (accessing_klass != nullptr) { class_loader = Handle(THREAD, accessing_klass->class_loader()); protection_domain = Handle(THREAD, accessing_klass->protection_domain()); } @@ -2340,7 +2340,7 @@ Handle SystemDictionary::link_method_handle_constant(Klass* caller, Symbol* signature, TRAPS) { Handle empty; - if (caller == NULL) { + if (caller == nullptr) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad MH constant", empty); } Handle name_str = java_lang_String::create_from_symbol(name, CHECK_(empty)); @@ -2391,7 +2391,7 @@ void SystemDictionary::invoke_bootstrap_method(BootstrapInfo& bootstrap_specifie bootstrap_specifier.resolve_bsm(CHECK); // This should not happen. JDK code should take care of that. - if (bootstrap_specifier.caller() == NULL || bootstrap_specifier.type_arg().is_null()) { + if (bootstrap_specifier.caller() == nullptr || bootstrap_specifier.type_arg().is_null()) { THROW_MSG(vmSymbols::java_lang_InternalError(), "Invalid bootstrap method invocation with no caller or type argument"); } @@ -2400,7 +2400,7 @@ void SystemDictionary::invoke_bootstrap_method(BootstrapInfo& bootstrap_specifie if (is_indy) { // Some method calls may require an appendix argument. Arrange to receive it. appendix_box = oopFactory::new_objArray_handle(vmClasses::Object_klass(), 1, CHECK); - assert(appendix_box->obj_at(0) == NULL, ""); + assert(appendix_box->obj_at(0) == nullptr, ""); } // call condy: java.lang.invoke.MethodHandleNatives::linkDynamicConstant(caller, bsm, type, info) @@ -2442,7 +2442,7 @@ void SystemDictionary::invoke_bootstrap_method(BootstrapInfo& bootstrap_specifie bool SystemDictionary::is_nonpublic_Object_method(Method* m) { - assert(m != NULL, "Unexpected NULL Method*"); + assert(m != nullptr, "Unexpected nullptr Method*"); return !m->is_public() && m->method_holder() == vmClasses::Object_klass(); } diff --git a/src/hotspot/share/classfile/systemDictionary.hpp b/src/hotspot/share/classfile/systemDictionary.hpp index 82afbcbf0fb..2807d74b88b 100644 --- a/src/hotspot/share/classfile/systemDictionary.hpp +++ b/src/hotspot/share/classfile/systemDictionary.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -36,7 +36,7 @@ // class loader -> ClassLoaderData -> [class, protection domain set] // // Classes are loaded lazily. The default VM class loader is -// represented as NULL. +// represented as null. // The underlying data structure is an open hash table (Dictionary) per // ClassLoaderData with a fixed number of buckets. During loading the @@ -95,7 +95,7 @@ class SystemDictionary : AllStatic { } // Returns a class with a given class name and class loader. - // Loads the class if needed. If not found NULL is returned. + // Loads the class if needed. If not found null is returned. static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); // Version with null loader and protection domain static Klass* resolve_or_null(Symbol* class_name, TRAPS) { @@ -139,13 +139,13 @@ class SystemDictionary : AllStatic { const ClassLoadInfo& cl_info, TRAPS); - // Lookup an already loaded class. If not found NULL is returned. + // Lookup an already loaded class. If not found null is returned. static InstanceKlass* find_instance_klass(Thread* current, Symbol* class_name, Handle class_loader, Handle protection_domain); // Lookup an already loaded instance or array class. // Do not make any queries to class loaders; consult only the cache. - // If not found NULL is returned. + // If not found null is returned. static Klass* find_instance_or_array_klass(Thread* current, Symbol* class_name, Handle class_loader, Handle protection_domain); @@ -155,7 +155,7 @@ class SystemDictionary : AllStatic { // loader that is constrained (via loader constraints) to produce // a consistent class. Do not take protection domains into account. // Do not make any queries to class loaders; consult only the cache. - // Return NULL if the class is not found. + // Return null if the class is not found. // // This function is a strict superset of find_instance_or_array_klass. // This function (the unchecked version) makes a conservative prediction @@ -273,7 +273,7 @@ public: // Record the error when the first attempt to resolve a reference from a constant // pool entry to a class fails. static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error, - Symbol* message, Symbol* cause = NULL, Symbol* cause_msg = NULL); + Symbol* message, Symbol* cause = nullptr, Symbol* cause_msg = nullptr); static void delete_resolution_error(ConstantPool* pool); static Symbol* find_resolution_error(const constantPoolHandle& pool, int which, Symbol** message, Symbol** cause, Symbol** cause_msg); @@ -354,7 +354,7 @@ protected: public: static bool is_system_class_loader(oop class_loader); static bool is_platform_class_loader(oop class_loader); - static bool is_boot_class_loader(oop class_loader) { return class_loader == NULL; } + static bool is_boot_class_loader(oop class_loader) { return class_loader == nullptr; } static bool is_builtin_class_loader(oop class_loader) { return is_boot_class_loader(class_loader) || is_platform_class_loader(class_loader) || diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 6c56fb925f1..2d608b4e2b8 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, 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 @@ -76,10 +76,10 @@ SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_static_archive; SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_dynamic_archive; -DumpTimeSharedClassTable* SystemDictionaryShared::_dumptime_table = NULL; -DumpTimeSharedClassTable* SystemDictionaryShared::_cloned_dumptime_table = NULL; -DumpTimeLambdaProxyClassDictionary* SystemDictionaryShared::_dumptime_lambda_proxy_class_dictionary = NULL; -DumpTimeLambdaProxyClassDictionary* SystemDictionaryShared::_cloned_dumptime_lambda_proxy_class_dictionary = NULL; +DumpTimeSharedClassTable* SystemDictionaryShared::_dumptime_table = nullptr; +DumpTimeSharedClassTable* SystemDictionaryShared::_cloned_dumptime_table = nullptr; +DumpTimeLambdaProxyClassDictionary* SystemDictionaryShared::_dumptime_lambda_proxy_class_dictionary = nullptr; +DumpTimeLambdaProxyClassDictionary* SystemDictionaryShared::_cloned_dumptime_lambda_proxy_class_dictionary = nullptr; // Used by NoClassLoadingMark DEBUG_ONLY(bool SystemDictionaryShared::_class_loading_may_happen = true;) @@ -89,17 +89,17 @@ InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader( assert(UseSharedSpaces, "must be"); InstanceKlass* ik = find_builtin_class(class_name); - if (ik != NULL && !ik->shared_loading_failed()) { + if (ik != nullptr && !ik->shared_loading_failed()) { if ((SystemDictionary::is_system_class_loader(class_loader()) && ik->is_shared_app_class()) || (SystemDictionary::is_platform_class_loader(class_loader()) && ik->is_shared_platform_class())) { SharedClassLoadingMark slm(THREAD, ik); PackageEntry* pkg_entry = CDSProtectionDomain::get_package_entry_from_class(ik, class_loader); Handle protection_domain = CDSProtectionDomain::init_security_info(class_loader, ik, pkg_entry, CHECK_NULL); - return load_shared_class(ik, class_loader, protection_domain, NULL, pkg_entry, THREAD); + return load_shared_class(ik, class_loader, protection_domain, nullptr, pkg_entry, THREAD); } } - return NULL; + return nullptr; } // This function is called for loading only UNREGISTERED classes @@ -109,30 +109,30 @@ InstanceKlass* SystemDictionaryShared::lookup_from_stream(Symbol* class_name, const ClassFileStream* cfs, TRAPS) { if (!UseSharedSpaces) { - return NULL; + return nullptr; } - if (class_name == NULL) { // don't do this for hidden classes - return NULL; + if (class_name == nullptr) { // don't do this for hidden classes + return nullptr; } if (class_loader.is_null() || SystemDictionary::is_system_class_loader(class_loader()) || SystemDictionary::is_platform_class_loader(class_loader())) { // Do nothing for the BUILTIN loaders. - return NULL; + return nullptr; } const RunTimeClassInfo* record = find_record(&_static_archive._unregistered_dictionary, &_dynamic_archive._unregistered_dictionary, class_name); - if (record == NULL) { - return NULL; + if (record == nullptr) { + return nullptr; } int clsfile_size = cfs->length(); int clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length()); if (!record->matches(clsfile_size, clsfile_crc32)) { - return NULL; + return nullptr; } return acquire_class_for_current_thread(record->_klass, class_loader, @@ -150,10 +150,10 @@ InstanceKlass* SystemDictionaryShared::acquire_class_for_current_thread( { MutexLocker mu(THREAD, SharedDictionary_lock); - if (ik->class_loader_data() != NULL) { + if (ik->class_loader_data() != nullptr) { // ik is already loaded (by this loader or by a different loader) // or ik is being loaded by a different thread (by this loader or by a different loader) - return NULL; + return nullptr; } // No other thread has acquired this yet, so give it to *this thread* @@ -170,15 +170,15 @@ InstanceKlass* SystemDictionaryShared::acquire_class_for_current_thread( // Load and check super/interfaces, restore unshareable info InstanceKlass* shared_klass = load_shared_class(ik, class_loader, protection_domain, cfs, pkg_entry, THREAD); - if (shared_klass == NULL || HAS_PENDING_EXCEPTION) { + if (shared_klass == nullptr || HAS_PENDING_EXCEPTION) { // TODO: clean up so it can be used again - return NULL; + return nullptr; } return shared_klass; } -// Guaranteed to return non-NULL value for non-shared classes. +// Guaranteed to return non-null value for non-shared classes. // k must not be a shared class. DumpTimeClassInfo* SystemDictionaryShared::get_info(InstanceKlass* k) { MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag); @@ -190,7 +190,7 @@ DumpTimeClassInfo* SystemDictionaryShared::get_info_locked(InstanceKlass* k) { assert_lock_strong(DumpTimeTable_lock); assert(!k->is_shared(), "sanity"); DumpTimeClassInfo* info = _dumptime_table->get_info(k); - assert(info != NULL, "must be"); + assert(info != nullptr, "must be"); return info; } @@ -202,9 +202,9 @@ bool SystemDictionaryShared::check_for_exclusion(InstanceKlass* k, DumpTimeClass return false; } - if (info == NULL) { + if (info == nullptr) { info = _dumptime_table->get(k); - assert(info != NULL, "supertypes of any classes in _dumptime_table must either be shared, or must also be in _dumptime_table"); + assert(info != nullptr, "supertypes of any classes in _dumptime_table must either be shared, or must also be in _dumptime_table"); } if (!info->has_checked_exclusion()) { @@ -236,12 +236,12 @@ bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) { bool SystemDictionaryShared::is_registered_lambda_proxy_class(InstanceKlass* ik) { DumpTimeClassInfo* info = _dumptime_table->get(ik); - return (info != NULL) ? info->_is_archived_lambda_proxy : false; + return (info != nullptr) ? info->_is_archived_lambda_proxy : false; } void SystemDictionaryShared::reset_registered_lambda_proxy_class(InstanceKlass* ik) { DumpTimeClassInfo* info = _dumptime_table->get(ik); - if (info != NULL) { + if (info != nullptr) { info->_is_archived_lambda_proxy = false; info->set_excluded(); } @@ -249,7 +249,7 @@ void SystemDictionaryShared::reset_registered_lambda_proxy_class(InstanceKlass* bool SystemDictionaryShared::is_early_klass(InstanceKlass* ik) { DumpTimeClassInfo* info = _dumptime_table->get(ik); - return (info != NULL) ? info->is_early_klass() : false; + return (info != nullptr) ? info->is_early_klass() : false; } bool SystemDictionaryShared::is_hidden_lambda_proxy(InstanceKlass* ik) { @@ -279,7 +279,7 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) { // agent during dump time). return warn_excluded(k, "Unsupported location"); } - if (k->signers() != NULL) { + if (k->signers() != nullptr) { // We cannot include signed classes in the archive because the certificates // used during dump time may be different than those used during // runtime (due to expiration, etc). @@ -316,7 +316,7 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) { } InstanceKlass* super = k->java_super(); - if (super != NULL && check_for_exclusion(super, NULL)) { + if (super != nullptr && check_for_exclusion(super, nullptr)) { ResourceMark rm; log_warning(cds)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string()); return true; @@ -326,7 +326,7 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) { int len = interfaces->length(); for (int i = 0; i < len; i++) { InstanceKlass* intf = interfaces->at(i); - if (check_for_exclusion(intf, NULL)) { + if (check_for_exclusion(intf, nullptr)) { ResourceMark rm; log_warning(cds)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string()); return true; @@ -338,7 +338,7 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) { bool SystemDictionaryShared::is_builtin_loader(ClassLoaderData* loader_data) { oop class_loader = loader_data->class_loader(); - return (class_loader == NULL || + return (class_loader == nullptr || SystemDictionary::is_system_class_loader(class_loader) || SystemDictionary::is_platform_class_loader(class_loader)); } @@ -389,10 +389,10 @@ bool SystemDictionaryShared::has_platform_or_app_classes() { InstanceKlass* SystemDictionaryShared::find_or_load_shared_class( Symbol* name, Handle class_loader, TRAPS) { - InstanceKlass* k = NULL; + InstanceKlass* k = nullptr; if (UseSharedSpaces) { if (!has_platform_or_app_classes()) { - return NULL; + return nullptr; } if (SystemDictionary::is_system_class_loader(class_loader()) || @@ -406,17 +406,17 @@ InstanceKlass* SystemDictionaryShared::find_or_load_shared_class( // Note: currently, find_or_load_shared_class is called only from // JVM_FindLoadedClass and used for PlatformClassLoader and AppClassLoader, // which are parallel-capable loaders, so a lock here is NOT taken. - assert(get_loader_lock_or_null(class_loader) == NULL, "ObjectLocker not required"); + assert(get_loader_lock_or_null(class_loader) == nullptr, "ObjectLocker not required"); { MutexLocker mu(THREAD, SystemDictionary_lock); InstanceKlass* check = dictionary->find_class(THREAD, name); - if (check != NULL) { + if (check != nullptr) { return check; } } k = load_shared_class_for_builtin_loader(name, class_loader, THREAD); - if (k != NULL) { + if (k != nullptr) { SharedClassLoadingMark slm(THREAD, k); k = find_or_define_instance_class(name, class_loader, k, CHECK_NULL); } @@ -430,7 +430,7 @@ class UnregisteredClassesTable : public ResourceHashtable< 15889, // prime number AnyObj::C_HEAP> {}; -static UnregisteredClassesTable* _unregistered_classes_table = NULL; +static UnregisteredClassesTable* _unregistered_classes_table = nullptr; // true == class was successfully added; false == a duplicated class (with the same name) already exists. bool SystemDictionaryShared::add_unregistered_class(Thread* current, InstanceKlass* klass) { @@ -440,7 +440,7 @@ bool SystemDictionaryShared::add_unregistered_class(Thread* current, InstanceKla assert(Arguments::is_dumping_archive() || ClassListWriter::is_enabled(), "sanity"); MutexLocker ml(current, UnregisteredClassesTable_lock); Symbol* name = klass->name(); - if (_unregistered_classes_table == NULL) { + if (_unregistered_classes_table == nullptr) { _unregistered_classes_table = new (mtClass)UnregisteredClassesTable(); } bool created; @@ -466,13 +466,13 @@ InstanceKlass* SystemDictionaryShared::lookup_super_for_unregistered_class( if (!ClassListParser::is_parsing_thread()) { // Unregistered classes can be created only by ClassListParser::_parsing_thread. - return NULL; + return nullptr; } ClassListParser* parser = ClassListParser::instance(); - if (parser == NULL) { + if (parser == nullptr) { // We're still loading the well-known classes, before the ClassListParser is created. - return NULL; + return nullptr; } if (class_name->equals(parser->current_class_name())) { // When this function is called, all the numbered super and interface types @@ -486,7 +486,7 @@ InstanceKlass* SystemDictionaryShared::lookup_super_for_unregistered_class( // The VM is not trying to resolve a super type of parser->current_class_name(). // Instead, it's resolving an error class (because parser->current_class_name() has // failed parsing or verification). Don't do anything here. - return NULL; + return nullptr; } } @@ -522,14 +522,14 @@ void SystemDictionaryShared::handle_class_unloading(InstanceKlass* klass) { remove_dumptime_info(klass); } - if (_unregistered_classes_table != NULL) { + if (_unregistered_classes_table != nullptr) { // Remove the class from _unregistered_classes_table: keep the entry but - // set it to NULL. This ensure no classes with the same name can be + // set it to null. This ensure no classes with the same name can be // added again. MutexLocker ml(Thread::current(), UnregisteredClassesTable_lock); InstanceKlass** v = _unregistered_classes_table->get(klass->name()); - if (v != NULL) { - *v = NULL; + if (v != nullptr) { + *v = nullptr; } } @@ -544,7 +544,7 @@ bool SystemDictionaryShared::has_been_redefined(InstanceKlass* k) { if (k->has_been_redefined()) { return true; } - if (k->java_super() != NULL && has_been_redefined(k->java_super())) { + if (k->java_super() != nullptr && has_been_redefined(k->java_super())) { return true; } Array* interfaces = k->local_interfaces(); @@ -563,7 +563,7 @@ void SystemDictionaryShared::validate_before_archiving(InstanceKlass* k) { const char* name = k->name()->as_C_string(); DumpTimeClassInfo* info = _dumptime_table->get(k); assert(!class_loading_may_happen(), "class loading must be disabled"); - guarantee(info != NULL, "Class %s must be entered into _dumptime_table", name); + guarantee(info != nullptr, "Class %s must be entered into _dumptime_table", name); guarantee(!info->is_excluded(), "Should not attempt to archive excluded class %s", name); if (is_builtin(k)) { if (k->is_hidden()) { @@ -671,7 +671,7 @@ void SystemDictionaryShared::set_class_has_failed_verification(InstanceKlass* ik bool SystemDictionaryShared::has_class_failed_verification(InstanceKlass* ik) { Arguments::assert_is_dumping_archive(); DumpTimeClassInfo* p = _dumptime_table->get(ik); - return (p == NULL) ? false : p->failed_verification(); + return (p == nullptr) ? false : p->failed_verification(); } void SystemDictionaryShared::dumptime_classes_do(class MetaspaceClosure* it) { @@ -748,17 +748,17 @@ void SystemDictionaryShared::add_lambda_proxy_class(InstanceKlass* caller_ik, assert(caller_ik->class_loader() == lambda_ik->class_loader(), "mismatched class loader"); assert(caller_ik->class_loader_data() == lambda_ik->class_loader_data(), "mismatched class loader data"); - assert(java_lang_Class::class_data(lambda_ik->java_mirror()) == NULL, "must not have class data"); + assert(java_lang_Class::class_data(lambda_ik->java_mirror()) == nullptr, "must not have class data"); MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag); lambda_ik->assign_class_loader_type(); lambda_ik->set_shared_classpath_index(caller_ik->shared_classpath_index()); InstanceKlass* nest_host = caller_ik->nest_host(CHECK); - assert(nest_host != NULL, "unexpected NULL nest_host"); + assert(nest_host != nullptr, "unexpected nullptr nest_host"); DumpTimeClassInfo* info = _dumptime_table->get(lambda_ik); - if (info != NULL && !lambda_ik->is_non_strong_hidden() && is_builtin(lambda_ik) && is_builtin(caller_ik) + if (info != nullptr && !lambda_ik->is_non_strong_hidden() && is_builtin(lambda_ik) && is_builtin(caller_ik) // Don't include the lambda proxy if its nest host is not in the "linked" state. && nest_host->is_linked()) { // Set _is_archived_lambda_proxy in DumpTimeClassInfo so that the lambda_ik @@ -786,22 +786,22 @@ InstanceKlass* SystemDictionaryShared::get_shared_lambda_proxy_class(InstanceKla LambdaProxyClassKey key(caller_ik, invoked_name, invoked_type, method_type, member_method, instantiated_method_type); const RunTimeLambdaProxyClassInfo* info = _static_archive.lookup_lambda_proxy_class(&key); - if (info == NULL) { + if (info == nullptr) { info = _dynamic_archive.lookup_lambda_proxy_class(&key); } - InstanceKlass* proxy_klass = NULL; - if (info != NULL) { + InstanceKlass* proxy_klass = nullptr; + if (info != nullptr) { InstanceKlass* curr_klass = info->proxy_klass_head(); InstanceKlass* prev_klass = curr_klass; if (curr_klass->lambda_proxy_is_available()) { - while (curr_klass->next_link() != NULL) { + while (curr_klass->next_link() != nullptr) { prev_klass = curr_klass; curr_klass = InstanceKlass::cast(curr_klass->next_link()); } assert(curr_klass->is_hidden(), "must be"); assert(curr_klass->lambda_proxy_is_available(), "must be"); - prev_klass->set_next_link(NULL); + prev_klass->set_next_link(nullptr); proxy_klass = curr_klass; proxy_klass->clear_lambda_proxy_is_available(); if (log_is_enabled(Debug, cds)) { @@ -830,18 +830,18 @@ InstanceKlass* SystemDictionaryShared::prepare_shared_lambda_proxy_class(Instanc Handle class_loader(THREAD, caller_ik->class_loader()); Handle protection_domain; PackageEntry* pkg_entry = caller_ik->package(); - if (caller_ik->class_loader() != NULL) { + if (caller_ik->class_loader() != nullptr) { protection_domain = CDSProtectionDomain::init_security_info(class_loader, caller_ik, pkg_entry, CHECK_NULL); } InstanceKlass* shared_nest_host = get_shared_nest_host(lambda_ik); - assert(shared_nest_host != NULL, "unexpected NULL _nest_host"); + assert(shared_nest_host != nullptr, "unexpected nullptr _nest_host"); InstanceKlass* loaded_lambda = SystemDictionary::load_shared_lambda_proxy_class(lambda_ik, class_loader, protection_domain, pkg_entry, CHECK_NULL); - if (loaded_lambda == NULL) { - return NULL; + if (loaded_lambda == nullptr) { + return nullptr; } // Ensures the nest host is the same as the lambda proxy's @@ -914,7 +914,7 @@ void SystemDictionaryShared::check_verification_constraints(InstanceKlass* klass static oop get_class_loader_by(char type) { if (type == (char)ClassLoader::BOOT_LOADER) { - return (oop)NULL; + return (oop)nullptr; } else if (type == (char)ClassLoader::PLATFORM_LOADER) { return SystemDictionary::java_platform_loader(); } else { @@ -964,7 +964,7 @@ void SystemDictionaryShared::record_linking_constraint(Symbol* name, InstanceKla } assert(is_builtin(klass), "must be"); - assert(klass_loader != NULL, "should not be called for boot loader"); + assert(klass_loader != nullptr, "should not be called for boot loader"); assert(loader1 != loader2, "must be"); if (DynamicDumpSharedSpaces && Thread::current()->is_VM_thread()) { @@ -991,7 +991,7 @@ bool SystemDictionaryShared::check_linking_constraints(Thread* current, Instance } if (klass->is_shared_platform_class() || klass->is_shared_app_class()) { RunTimeClassInfo* info = RunTimeClassInfo::get_for(klass); - assert(info != NULL, "Sanity"); + assert(info != nullptr, "Sanity"); if (info->_num_loader_constraints > 0) { HandleMark hm(current); for (int i = 0; i < info->_num_loader_constraints; i++) { @@ -1031,7 +1031,7 @@ bool SystemDictionaryShared::check_linking_constraints(Thread* current, Instance bool SystemDictionaryShared::is_supported_invokedynamic(BootstrapInfo* bsi) { LogTarget(Debug, cds, lambda) log; - if (bsi->arg_values() == NULL || !bsi->arg_values()->is_objArray()) { + if (bsi->arg_values() == nullptr || !bsi->arg_values()->is_objArray()) { if (log.is_enabled()) { LogStream log_stream(log); log.print("bsi check failed"); @@ -1274,11 +1274,11 @@ const RunTimeClassInfo* SystemDictionaryShared::find_record(RunTimeSharedDictionary* static_dict, RunTimeSharedDictionary* dynamic_dict, Symbol* name) { if (!UseSharedSpaces || !name->is_shared()) { // The names of all shared classes must also be a shared Symbol. - return NULL; + return nullptr; } unsigned int hash = SystemDictionaryShared::hash_for_shared_dictionary_quick(name); - const RunTimeClassInfo* record = NULL; + const RunTimeClassInfo* record = nullptr; if (DynamicArchive::is_mapped()) { // Use the regenerated holder classes in the dynamic archive as they // have more methods than those in the base archive. @@ -1299,7 +1299,7 @@ SystemDictionaryShared::find_record(RunTimeSharedDictionary* static_dict, RunTim record = static_dict->lookup(name, hash, 0); } - if (record == NULL && DynamicArchive::is_mapped()) { + if (record == nullptr && DynamicArchive::is_mapped()) { record = dynamic_dict->lookup(name, hash, 0); } @@ -1310,17 +1310,17 @@ InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) { const RunTimeClassInfo* record = find_record(&_static_archive._builtin_dictionary, &_dynamic_archive._builtin_dictionary, name); - if (record != NULL) { + if (record != nullptr) { assert(!record->_klass->is_hidden(), "hidden class cannot be looked up by name"); assert(check_alignment(record->_klass), "Address not aligned"); // We did not save the classfile data of the generated LambdaForm invoker classes, // so we cannot support CLFH for such classes. if (record->_klass->is_generated_shared_class() && JvmtiExport::should_post_class_file_load_hook()) { - return NULL; + return nullptr; } return record->_klass; } else { - return NULL; + return nullptr; } } @@ -1445,8 +1445,8 @@ class CloneDumpTimeClassTable: public StackObj { public: CloneDumpTimeClassTable(DumpTimeSharedClassTable* table, DumpTimeSharedClassTable* clone) : _table(table), _cloned_table(clone) { - assert(_table != NULL, "_dumptime_table is NULL"); - assert(_cloned_table != NULL, "_cloned_table is NULL"); + assert(_table != nullptr, "_dumptime_table is nullptr"); + assert(_cloned_table != nullptr, "_cloned_table is nullptr"); } void do_entry(InstanceKlass* k, DumpTimeClassInfo& info) { if (!info.is_excluded()) { @@ -1464,8 +1464,8 @@ class CloneDumpTimeLambdaProxyClassTable: StackObj { CloneDumpTimeLambdaProxyClassTable(DumpTimeLambdaProxyClassDictionary* table, DumpTimeLambdaProxyClassDictionary* clone) : _table(table), _cloned_table(clone) { - assert(_table != NULL, "_dumptime_table is NULL"); - assert(_cloned_table != NULL, "_cloned_table is NULL"); + assert(_table != nullptr, "_dumptime_table is nullptr"); + assert(_cloned_table != nullptr, "_cloned_table is nullptr"); } bool do_entry(LambdaProxyClassKey& key, DumpTimeLambdaProxyClassInfo& info) { @@ -1496,13 +1496,13 @@ void SystemDictionaryShared::clone_dumptime_tables() { Arguments::assert_is_dumping_archive(); assert_lock_strong(DumpTimeTable_lock); - assert(_cloned_dumptime_table == NULL, "_cloned_dumptime_table must be cleaned"); + assert(_cloned_dumptime_table == nullptr, "_cloned_dumptime_table must be cleaned"); _cloned_dumptime_table = new (mtClass) DumpTimeSharedClassTable; CloneDumpTimeClassTable copy_classes(_dumptime_table, _cloned_dumptime_table); _dumptime_table->iterate_all_live_classes(©_classes); _cloned_dumptime_table->update_counts(); - assert(_cloned_dumptime_lambda_proxy_class_dictionary == NULL, + assert(_cloned_dumptime_lambda_proxy_class_dictionary == nullptr, "_cloned_dumptime_lambda_proxy_class_dictionary must be cleaned"); _cloned_dumptime_lambda_proxy_class_dictionary = new (mtClass) DumpTimeLambdaProxyClassDictionary; @@ -1515,11 +1515,11 @@ void SystemDictionaryShared::restore_dumptime_tables() { assert_lock_strong(DumpTimeTable_lock); delete _dumptime_table; _dumptime_table = _cloned_dumptime_table; - _cloned_dumptime_table = NULL; + _cloned_dumptime_table = nullptr; delete _dumptime_lambda_proxy_class_dictionary; _dumptime_lambda_proxy_class_dictionary = _cloned_dumptime_lambda_proxy_class_dictionary; - _cloned_dumptime_lambda_proxy_class_dictionary = NULL; + _cloned_dumptime_lambda_proxy_class_dictionary = nullptr; } class CleanupDumpTimeLambdaProxyClassTable: StackObj { @@ -1531,12 +1531,12 @@ class CleanupDumpTimeLambdaProxyClassTable: StackObj { // If the caller class and/or nest_host are excluded, the associated lambda proxy // must also be excluded. - bool always_exclude = SystemDictionaryShared::check_for_exclusion(caller_ik, NULL) || - SystemDictionaryShared::check_for_exclusion(nest_host, NULL); + bool always_exclude = SystemDictionaryShared::check_for_exclusion(caller_ik, nullptr) || + SystemDictionaryShared::check_for_exclusion(nest_host, nullptr); for (int i = info._proxy_klasses->length() - 1; i >= 0; i--) { InstanceKlass* ik = info._proxy_klasses->at(i); - if (always_exclude || SystemDictionaryShared::check_for_exclusion(ik, NULL)) { + if (always_exclude || SystemDictionaryShared::check_for_exclusion(ik, nullptr)) { SystemDictionaryShared::reset_registered_lambda_proxy_class(ik); info._proxy_klasses->remove_at(i); } diff --git a/src/hotspot/share/classfile/systemDictionaryShared.hpp b/src/hotspot/share/classfile/systemDictionaryShared.hpp index acf2a64c5c9..d3bfaa1f785 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.hpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, 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 @@ -127,8 +127,8 @@ class SharedClassLoadingMark { public: SharedClassLoadingMark(Thread* current, InstanceKlass* ik) : THREAD(current), _klass(ik) {} ~SharedClassLoadingMark() { - assert(THREAD != NULL, "Current thread is NULL"); - assert(_klass != NULL, "InstanceKlass is NULL"); + assert(THREAD != nullptr, "Current thread is nullptr"); + assert(_klass != nullptr, "InstanceKlass is nullptr"); if (HAS_PENDING_EXCEPTION) { if (_klass->is_shared()) { _klass->set_shared_loading_failed(); @@ -186,7 +186,7 @@ private: const ClassFileStream* cfs, TRAPS); - // Guaranteed to return non-NULL value for non-shared classes. + // Guaranteed to return non-null value for non-shared classes. // k must not be a shared class. static DumpTimeClassInfo* get_info(InstanceKlass* k); static DumpTimeClassInfo* get_info_locked(InstanceKlass* k); @@ -278,10 +278,10 @@ public: Symbol* invoked_type, Symbol* method_type, Method* member_method, - Symbol* instantiated_method_type) NOT_CDS_RETURN_(NULL); - static InstanceKlass* get_shared_nest_host(InstanceKlass* lambda_ik) NOT_CDS_RETURN_(NULL); + Symbol* instantiated_method_type) NOT_CDS_RETURN_(nullptr); + static InstanceKlass* get_shared_nest_host(InstanceKlass* lambda_ik) NOT_CDS_RETURN_(nullptr); static InstanceKlass* prepare_shared_lambda_proxy_class(InstanceKlass* lambda_ik, - InstanceKlass* caller_ik, TRAPS) NOT_CDS_RETURN_(NULL); + InstanceKlass* caller_ik, TRAPS) NOT_CDS_RETURN_(nullptr); static bool check_linking_constraints(Thread* current, InstanceKlass* klass) NOT_CDS_RETURN_(false); static void record_linking_constraint(Symbol* name, InstanceKlass* klass, Handle loader1, Handle loader2) NOT_CDS_RETURN; diff --git a/src/hotspot/share/classfile/verificationType.cpp b/src/hotspot/share/classfile/verificationType.cpp index e3d98d1fd02..a310b638e86 100644 --- a/src/hotspot/share/classfile/verificationType.cpp +++ b/src/hotspot/share/classfile/verificationType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, 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 @@ -187,10 +187,10 @@ void VerificationType::print_on(outputStream* st) const { } else if (is_uninitialized()) { st->print("uninitialized %d", bci()); } else { - if (name() != NULL) { + if (name() != nullptr) { name()->print_value_on(st); } else { - st->print_cr("NULL"); + st->print_cr("null"); } } } diff --git a/src/hotspot/share/classfile/verifier.cpp b/src/hotspot/share/classfile/verifier.cpp index 1947df2411f..f6629e976f3 100644 --- a/src/hotspot/share/classfile/verifier.cpp +++ b/src/hotspot/share/classfile/verifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, 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 @@ -71,31 +71,31 @@ extern "C" { typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint, jint); } -static verify_byte_codes_fn_t volatile _verify_byte_codes_fn = NULL; +static verify_byte_codes_fn_t volatile _verify_byte_codes_fn = nullptr; static verify_byte_codes_fn_t verify_byte_codes_fn() { - if (_verify_byte_codes_fn != NULL) + if (_verify_byte_codes_fn != nullptr) return _verify_byte_codes_fn; MutexLocker locker(Verify_lock); - if (_verify_byte_codes_fn != NULL) + if (_verify_byte_codes_fn != nullptr) return _verify_byte_codes_fn; // Load verify dll char buffer[JVM_MAXPATHLEN]; char ebuf[1024]; if (!os::dll_locate_lib(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify")) - return NULL; // Caller will throw VerifyError + return nullptr; // Caller will throw VerifyError void *lib_handle = os::dll_load(buffer, ebuf, sizeof(ebuf)); - if (lib_handle == NULL) - return NULL; // Caller will throw VerifyError + if (lib_handle == nullptr) + return nullptr; // Caller will throw VerifyError void *fn = os::dll_lookup(lib_handle, "VerifyClassForMajorVersion"); - if (fn == NULL) - return NULL; // Caller will throw VerifyError + if (fn == nullptr) + return nullptr; // Caller will throw VerifyError return _verify_byte_codes_fn = CAST_TO_FN_PTR(verify_byte_codes_fn_t, fn); } @@ -104,7 +104,7 @@ static verify_byte_codes_fn_t verify_byte_codes_fn() { // Methods in Verifier bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) { - return (class_loader == NULL || !should_verify_class) ? + return (class_loader == nullptr || !should_verify_class) ? BytecodeVerificationLocal : BytecodeVerificationRemote; } @@ -119,14 +119,14 @@ bool Verifier::relax_access_for(oop loader) { } void Verifier::trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class) { - assert(verify_class != NULL, "Unexpected null verify_class"); + assert(verify_class != nullptr, "Unexpected null verify_class"); ResourceMark rm; Symbol* s = verify_class->source_file_name(); - const char* source_file = (s != NULL ? s->as_C_string() : NULL); + const char* source_file = (s != nullptr ? s->as_C_string() : nullptr); const char* verify = verify_class->external_name(); const char* resolve = resolve_class->external_name(); // print in a single call to reduce interleaving between threads - if (source_file != NULL) { + if (source_file != nullptr) { log_debug(class, resolve)("%s %s %s (verification)", verify, resolve, source_file); } else { log_debug(class, resolve)("%s %s (verification)", verify, resolve); @@ -135,10 +135,10 @@ void Verifier::trace_class_resolution(Klass* resolve_class, InstanceKlass* verif // Prints the end-verification message to the appropriate output. void Verifier::log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, oop pending_exception) { - if (pending_exception != NULL) { + if (pending_exception != nullptr) { st->print("Verification for %s has", klassName); oop message = java_lang_Throwable::message(pending_exception); - if (message != NULL) { + if (message != nullptr) { char* ex_msg = java_lang_String::as_utf8_string(message); st->print_cr(" exception pending '%s %s'", pending_exception->klass()->external_name(), ex_msg); @@ -146,7 +146,7 @@ void Verifier::log_end_verification(outputStream* st, const char* klassName, Sym st->print_cr(" exception pending %s ", pending_exception->klass()->external_name()); } - } else if (exception_name != NULL) { + } else if (exception_name != nullptr) { st->print_cr("Verification for %s failed", klassName); } st->print_cr("End class verification for: %s", klassName); @@ -165,7 +165,7 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) { // effect (sic!) for external_name(), but instead of doing that, we opt to // explicitly push the hashcode in here. This is signify the following block // is IMPORTANT: - if (klass->java_mirror() != NULL) { + if (klass->java_mirror() != nullptr) { klass->java_mirror()->identity_hash(); } @@ -186,10 +186,10 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) { // If the class should be verified, first see if we can use the split // verifier. If not, or if verification fails and can failover, then // call the inference verifier. - Symbol* exception_name = NULL; + Symbol* exception_name = nullptr; const size_t message_buffer_len = klass->name()->utf8_length() + 1024; - char* message_buffer = NULL; - char* exception_message = NULL; + char* message_buffer = nullptr; + char* exception_message = nullptr; log_info(class, init)("Start class verification for: %s", klass->external_name()); if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) { @@ -216,7 +216,7 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) { exception_name = inference_verify( klass, message_buffer, message_buffer_len, THREAD); } - if (exception_name != NULL) { + if (exception_name != nullptr) { exception_message = split_verifier.exception_message(); } } else { @@ -239,7 +239,7 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) { if (HAS_PENDING_EXCEPTION) { return false; // use the existing exception - } else if (exception_name == NULL) { + } else if (exception_name == nullptr) { return true; // verification succeeded } else { // VerifyError or ClassFormatError to be created and thrown Klass* kls = @@ -248,7 +248,7 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) { Verifier::trace_class_resolution(kls, klass); } - while (kls != NULL) { + while (kls != nullptr) { if (kls == klass) { // If the class being verified is the exception we're creating // or one of it's superclasses, we're in trouble and are going @@ -258,10 +258,10 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) { } kls = kls->super(); } - if (message_buffer != NULL) { + if (message_buffer != nullptr) { message_buffer[message_buffer_len - 1] = '\0'; // just to be sure } - assert(exception_message != NULL, ""); + assert(exception_message != nullptr, ""); THROW_MSG_(exception_name, exception_message, false); } } @@ -270,7 +270,7 @@ bool Verifier::is_eligible_for_verification(InstanceKlass* klass, bool should_ve Symbol* name = klass->name(); Klass* refl_magic_klass = vmClasses::reflect_MagicAccessorImpl_klass(); - bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass); + bool is_reflect = refl_magic_klass != nullptr && klass->is_subtype_of(refl_magic_klass); return (should_verify_for(klass->class_loader(), should_verify_class) && // return if the class is a bootstrapping class @@ -305,7 +305,7 @@ Symbol* Verifier::inference_verify( verify_byte_codes_fn_t verify_func = verify_byte_codes_fn(); - if (verify_func == NULL) { + if (verify_func == nullptr) { jio_snprintf(message, message_len, "Could not link verifier"); return vmSymbols::java_lang_VerifyError(); } @@ -333,14 +333,14 @@ Symbol* Verifier::inference_verify( if (result == 0) { return vmSymbols::java_lang_VerifyError(); } else if (result == 1) { - return NULL; // verified. + return nullptr; // verified. } else if (result == 2) { - THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, NULL); + THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, nullptr); } else if (result == 3) { return vmSymbols::java_lang_ClassFormatError(); } else { ShouldNotReachHere(); - return NULL; + return nullptr; } } @@ -348,36 +348,36 @@ TypeOrigin TypeOrigin::null() { return TypeOrigin(); } TypeOrigin TypeOrigin::local(u2 index, StackMapFrame* frame) { - assert(frame != NULL, "Must have a frame"); + assert(frame != nullptr, "Must have a frame"); return TypeOrigin(CF_LOCALS, index, StackMapFrame::copy(frame), frame->local_at(index)); } TypeOrigin TypeOrigin::stack(u2 index, StackMapFrame* frame) { - assert(frame != NULL, "Must have a frame"); + assert(frame != nullptr, "Must have a frame"); return TypeOrigin(CF_STACK, index, StackMapFrame::copy(frame), frame->stack_at(index)); } TypeOrigin TypeOrigin::sm_local(u2 index, StackMapFrame* frame) { - assert(frame != NULL, "Must have a frame"); + assert(frame != nullptr, "Must have a frame"); return TypeOrigin(SM_LOCALS, index, StackMapFrame::copy(frame), frame->local_at(index)); } TypeOrigin TypeOrigin::sm_stack(u2 index, StackMapFrame* frame) { - assert(frame != NULL, "Must have a frame"); + assert(frame != nullptr, "Must have a frame"); return TypeOrigin(SM_STACK, index, StackMapFrame::copy(frame), frame->stack_at(index)); } TypeOrigin TypeOrigin::bad_index(u2 index) { - return TypeOrigin(BAD_INDEX, index, NULL, VerificationType::bogus_type()); + return TypeOrigin(BAD_INDEX, index, nullptr, VerificationType::bogus_type()); } TypeOrigin TypeOrigin::cp(u2 index, VerificationType vt) { - return TypeOrigin(CONST_POOL, index, NULL, vt); + return TypeOrigin(CONST_POOL, index, nullptr, vt); } TypeOrigin TypeOrigin::signature(VerificationType vt) { - return TypeOrigin(SIG, 0, NULL, vt); + return TypeOrigin(SIG, 0, nullptr, vt); } TypeOrigin TypeOrigin::implicit(VerificationType t) { - return TypeOrigin(IMPLICIT, 0, NULL, t); + return TypeOrigin(IMPLICIT, 0, nullptr, t); } TypeOrigin TypeOrigin::frame(StackMapFrame* frame) { return TypeOrigin(FRAME_ONLY, 0, StackMapFrame::copy(frame), @@ -385,7 +385,7 @@ TypeOrigin TypeOrigin::frame(StackMapFrame* frame) { } void TypeOrigin::reset_frame() { - if (_frame != NULL) { + if (_frame != nullptr) { _frame->restore(); } } @@ -422,7 +422,7 @@ void TypeOrigin::details(outputStream* ss) const { #ifdef ASSERT void TypeOrigin::print_on(outputStream* str) const { str->print("{%d,%d,%p:", _origin, _index, _frame); - if (_frame != NULL) { + if (_frame != nullptr) { _frame->print_on(str); } else { str->print("null"); @@ -507,7 +507,7 @@ void ErrorContext::reason_details(outputStream* ss) const { } void ErrorContext::location_details(outputStream* ss, const Method* method) const { - if (_bci != -1 && method != NULL) { + if (_bci != -1 && method != nullptr) { streamIndentor si(ss); const char* bytecode_name = ""; if (method->validate_bci(_bci) != -1) { @@ -529,12 +529,12 @@ void ErrorContext::location_details(outputStream* ss, const Method* method) cons void ErrorContext::frame_details(outputStream* ss) const { streamIndentor si(ss); - if (_type.is_valid() && _type.frame() != NULL) { + if (_type.is_valid() && _type.frame() != nullptr) { ss->indent().print_cr("Current Frame:"); streamIndentor si2(ss); _type.frame()->print_on(ss); } - if (_expected.is_valid() && _expected.frame() != NULL) { + if (_expected.is_valid() && _expected.frame() != nullptr) { ss->indent().print_cr("Stackmap Frame:"); streamIndentor si2(ss); _expected.frame()->print_on(ss); @@ -542,7 +542,7 @@ void ErrorContext::frame_details(outputStream* ss) const { } void ErrorContext::bytecode_details(outputStream* ss, const Method* method) const { - if (method != NULL) { + if (method != nullptr) { streamIndentor si(ss); ss->indent().print_cr("Bytecode:"); streamIndentor si2(ss); @@ -551,7 +551,7 @@ void ErrorContext::bytecode_details(outputStream* ss, const Method* method) cons } void ErrorContext::handler_details(outputStream* ss, const Method* method) const { - if (method != NULL) { + if (method != nullptr) { streamIndentor si(ss); ExceptionTable table(method); if (table.length() > 0) { @@ -566,7 +566,7 @@ void ErrorContext::handler_details(outputStream* ss, const Method* method) const } void ErrorContext::stackmap_details(outputStream* ss, const Method* method) const { - if (method != NULL && method->has_stackmap_table()) { + if (method != nullptr && method->has_stackmap_table()) { streamIndentor si(ss); ss->indent().print_cr("Stackmap Table:"); Array* data = method->stackmap_data(); @@ -593,14 +593,14 @@ void ErrorContext::stackmap_details(outputStream* ss, const Method* method) cons // Methods in ClassVerifier ClassVerifier::ClassVerifier(JavaThread* current, InstanceKlass* klass) - : _thread(current), _previous_symbol(NULL), _symbols(NULL), _exception_type(NULL), - _message(NULL), _klass(klass) { + : _thread(current), _previous_symbol(nullptr), _symbols(nullptr), _exception_type(nullptr), + _message(nullptr), _klass(klass) { _this_type = VerificationType::reference_type(klass->name()); } ClassVerifier::~ClassVerifier() { // Decrement the reference count for any symbols created. - if (_symbols != NULL) { + if (_symbols != nullptr) { for (int i = 0; i < _symbols->length(); i++) { Symbol* s = _symbols->at(i); s->decrement_refcount(); @@ -1847,7 +1847,7 @@ char* ClassVerifier::generate_code_data(const methodHandle& m, u4 code_length, T } } else { verify_error(ErrorContext::bad_code(bcs.bci()), "Bad instruction"); - return NULL; + return nullptr; } } @@ -2029,7 +2029,7 @@ void ClassVerifier::verify_cp_type( // In this case, a constant pool cache exists and some indices refer to that // instead. Be sure we don't pick up such indices by accident. // We must check was_recursively_verified() before we get here. - guarantee(cp->cache() == NULL, "not rewritten yet"); + guarantee(cp->cache() == nullptr, "not rewritten yet"); verify_cp_index(bci, cp, index, CHECK_VERIFY(this)); unsigned int tag = cp->tag_at(index).value(); @@ -2067,7 +2067,7 @@ void ClassVerifier::verify_error(ErrorContext ctx, const char* msg, ...) { #ifdef ASSERT ResourceMark rm; const char* exception_name = _exception_type->as_C_string(); - Exceptions::debug_check_abort(exception_name, NULL); + Exceptions::debug_check_abort(exception_name, nullptr); #endif // ndef ASSERT } @@ -2098,7 +2098,7 @@ Klass* ClassVerifier::load_class(Symbol* name, TRAPS) { name, Handle(THREAD, loader), Handle(THREAD, protection_domain), true, THREAD); - if (kls != NULL) { + if (kls != nullptr) { if (log_is_enabled(Debug, class, resolve)) { Verifier::trace_class_resolution(kls, current_class()); } @@ -2122,14 +2122,14 @@ bool ClassVerifier::is_protected_access(InstanceKlass* this_class, fieldDescriptor fd; if (is_method) { Method* m = target_instance->uncached_lookup_method(field_name, field_sig, Klass::OverpassLookupMode::find); - if (m != NULL && m->is_protected()) { + if (m != nullptr && m->is_protected()) { if (!this_class->is_same_class_package(m->method_holder())) { return true; } } } else { Klass* member_klass = target_instance->find_field(field_name, field_sig, &fd); - if (member_klass != NULL && fd.is_protected()) { + if (member_klass != nullptr && fd.is_protected()) { if (!this_class->is_same_class_package(member_klass)) { return true; } @@ -2285,13 +2285,13 @@ void ClassVerifier::verify_switch( stackmap_table->check_jump_target( current_frame, target, CHECK_VERIFY(this)); } - NOT_PRODUCT(aligned_bcp = NULL); // no longer valid at this point + NOT_PRODUCT(aligned_bcp = nullptr); // no longer valid at this point } bool ClassVerifier::name_in_supers( Symbol* ref_name, InstanceKlass* current) { Klass* super = current->super(); - while (super != NULL) { + while (super != nullptr) { if (super->name() == ref_name) { return true; } @@ -2728,7 +2728,7 @@ void ClassVerifier::verify_invoke_init( cp->signature_ref_at(bcs->get_index_u2()), Klass::OverpassLookupMode::find); // Do nothing if method is not found. Let resolution detect the error. - if (m != NULL) { + if (m != nullptr) { InstanceKlass* mh = m->method_holder(); if (m->is_protected() && !mh->is_same_class_package(_klass)) { bool assignable = current_type().is_assignable_from( @@ -2765,10 +2765,10 @@ bool ClassVerifier::is_same_or_direct_interface( VerificationType ref_class_type) { if (ref_class_type.equals(klass_type)) return true; Array* local_interfaces = klass->local_interfaces(); - if (local_interfaces != NULL) { + if (local_interfaces != nullptr) { for (int x = 0; x < local_interfaces->length(); x++) { InstanceKlass* k = local_interfaces->at(x); - assert (k != NULL && k->is_interface(), "invalid interface"); + assert (k != nullptr && k->is_interface(), "invalid interface"); if (ref_class_type.equals(VerificationType::reference_type(k->name()))) { return true; } @@ -2833,10 +2833,10 @@ void ClassVerifier::verify_invoke_instructions( // Get the signature's verification types. sig_as_verification_types* mth_sig_verif_types; sig_as_verification_types** mth_sig_verif_types_ptr = method_signatures_table()->get(sig_index); - if (mth_sig_verif_types_ptr != NULL) { + if (mth_sig_verif_types_ptr != nullptr) { // Found the entry for the signature's verification types in the hash table. mth_sig_verif_types = *mth_sig_verif_types_ptr; - assert(mth_sig_verif_types != NULL, "Unexpected NULL sig_as_verification_types value"); + assert(mth_sig_verif_types != nullptr, "Unexpected null sig_as_verification_types value"); } else { // Not found, add the entry to the table. GrowableArray* verif_types = new GrowableArray(10); @@ -2908,7 +2908,7 @@ void ClassVerifier::verify_invoke_instructions( // Get the verification types for the method's arguments. GrowableArray* sig_verif_types = mth_sig_verif_types->sig_verif_types(); - assert(sig_verif_types != NULL, "Missing signature's array of verification types"); + assert(sig_verif_types != nullptr, "Missing signature's array of verification types"); // Match method descriptor with operand stack // The arguments are on the stack in descending order. for (int i = nargs - 1; i >= 0; i--) { // Run backwards @@ -2932,7 +2932,7 @@ void ClassVerifier::verify_invoke_instructions( current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this)); if (current_type() != stack_object_type) { if (was_recursively_verified()) return; - assert(cp->cache() == NULL, "not rewritten yet"); + assert(cp->cache() == nullptr, "not rewritten yet"); Symbol* ref_class_name = cp->klass_name_at(cp->klass_ref_index_at(index)); // See the comments in verify_field_instructions() for @@ -2993,7 +2993,7 @@ void ClassVerifier::verify_invoke_instructions( VerificationType ClassVerifier::get_newarray_type( u2 index, u2 bci, TRAPS) { const char* from_bt[] = { - NULL, NULL, NULL, NULL, "[Z", "[C", "[F", "[D", "[B", "[S", "[I", "[J", + nullptr, nullptr, nullptr, nullptr, "[Z", "[C", "[F", "[D", "[B", "[S", "[I", "[J", }; if (index < T_BOOLEAN || index > T_LONG) { verify_error(ErrorContext::bad_code(bci), "Illegal newarray instruction"); @@ -3150,13 +3150,13 @@ void ClassVerifier::verify_return_value( // they can be reference counted. Symbol* ClassVerifier::create_temporary_symbol(const char *name, int length) { // Quick deduplication check - if (_previous_symbol != NULL && _previous_symbol->equals(name, length)) { + if (_previous_symbol != nullptr && _previous_symbol->equals(name, length)) { return _previous_symbol; } Symbol* sym = SymbolTable::new_symbol(name, length); if (!sym->is_permanent()) { - if (_symbols == NULL) { - _symbols = new GrowableArray(50, 0, NULL); + if (_symbols == nullptr) { + _symbols = new GrowableArray(50, 0, nullptr); } _symbols->push(sym); } diff --git a/src/hotspot/share/classfile/verifier.hpp b/src/hotspot/share/classfile/verifier.hpp index c50e2f7c217..961a2c22f4b 100644 --- a/src/hotspot/share/classfile/verifier.hpp +++ b/src/hotspot/share/classfile/verifier.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, 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 @@ -116,7 +116,7 @@ class TypeOrigin { : _origin(origin), _index(index), _frame(frame), _type(type) {} public: - TypeOrigin() : _origin(NONE), _index(0), _frame(NULL) {} + TypeOrigin() : _origin(NONE), _index(0), _frame(nullptr) {} static TypeOrigin null(); static TypeOrigin local(u2 index, StackMapFrame* frame); @@ -422,7 +422,7 @@ class ClassVerifier : public StackObj { // Return status modes Symbol* result() const { return _exception_type; } - bool has_error() const { return result() != NULL; } + bool has_error() const { return result() != nullptr; } char* exception_message() { stringStream ss; ss.print("%s", _message); @@ -459,8 +459,8 @@ class ClassVerifier : public StackObj { } if (!s->is_permanent()) { s->increment_refcount(); - if (_symbols == NULL) { - _symbols = new GrowableArray(50, 0, NULL); + if (_symbols == nullptr) { + _symbols = new GrowableArray(50, 0, nullptr); } _symbols->push(s); } diff --git a/src/hotspot/share/classfile/vmClasses.cpp b/src/hotspot/share/classfile/vmClasses.cpp index 93e8b972082..df6830d464a 100644 --- a/src/hotspot/share/classfile/vmClasses.cpp +++ b/src/hotspot/share/classfile/vmClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, 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 @@ -41,8 +41,8 @@ #include "runtime/globals.hpp" InstanceKlass* vmClasses::_klasses[static_cast(vmClassID::LIMIT)] - = { NULL /*, NULL...*/ }; -InstanceKlass* vmClasses::_box_klasses[T_VOID+1] = { NULL /*, NULL...*/ }; + = { nullptr /*, nullptr...*/ }; +InstanceKlass* vmClasses::_box_klasses[T_VOID+1] = { nullptr /*, nullptr...*/ }; // CDS: scan and relocate all classes referenced by _klasses[]. @@ -53,7 +53,7 @@ void vmClasses::metaspace_pointers_do(MetaspaceClosure* it) { } bool vmClasses::is_loaded(InstanceKlass* klass) { - return klass != NULL && klass->is_loaded(); + return klass != nullptr && klass->is_loaded(); } // Compact table of the vmSymbolIDs of all the VM classes (stored as short to save space) @@ -102,7 +102,7 @@ bool vmClasses::resolve(vmClassID id, TRAPS) { Klass* k = SystemDictionary::resolve_or_fail(symbol, true, CHECK_false); (*klassp) = InstanceKlass::cast(k); } - return ((*klassp) != NULL); + return ((*klassp) != nullptr); } void vmClasses::resolve_until(vmClassID limit_id, vmClassID &start_id, TRAPS) { @@ -154,7 +154,7 @@ void vmClasses::resolve_all(TRAPS) { resolve_through(VM_CLASS_ID(Class_klass), scan, CHECK); } - assert(vmClasses::Object_klass() != NULL, "well-known classes should now be initialized"); + assert(vmClasses::Object_klass() != nullptr, "well-known classes should now be initialized"); java_lang_Object::register_natives(CHECK); @@ -226,13 +226,13 @@ void vmClasses::resolve_all(TRAPS) { void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) { assert(!Universe::is_fully_initialized(), "We can make short cuts only during VM initialization"); assert(klass->is_shared(), "Must be shared class"); - if (klass->class_loader_data() != NULL) { + if (klass->class_loader_data() != nullptr) { return; } // add super and interfaces first Klass* super = klass->super(); - if (super != NULL && super->class_loader_data() == NULL) { + if (super != nullptr && super->class_loader_data() == nullptr) { assert(super->is_instance_klass(), "Super should be instance klass"); resolve_shared_class(InstanceKlass::cast(super), loader_data, domain, CHECK); } @@ -240,12 +240,12 @@ void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* load Array* ifs = klass->local_interfaces(); for (int i = 0; i < ifs->length(); i++) { InstanceKlass* ik = ifs->at(i); - if (ik->class_loader_data() == NULL) { + if (ik->class_loader_data() == nullptr) { resolve_shared_class(ik, loader_data, domain, CHECK); } } - klass->restore_unshareable_info(loader_data, domain, NULL, THREAD); + klass->restore_unshareable_info(loader_data, domain, nullptr, THREAD); SystemDictionary::load_shared_class_misc(klass, loader_data); Dictionary* dictionary = loader_data->dictionary(); dictionary->add_klass(THREAD, klass->name(), klass); @@ -258,7 +258,7 @@ void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* load // Tells if a given klass is a box (wrapper class, such as java.lang.Integer). // If so, returns the basic type it holds. If not, returns T_OBJECT. BasicType vmClasses::box_klass_type(Klass* k) { - assert(k != NULL, ""); + assert(k != nullptr, ""); for (int i = T_BOOLEAN; i < T_VOID+1; i++) { if (_box_klasses[i] == k) return (BasicType)i; diff --git a/src/hotspot/share/classfile/vmClasses.hpp b/src/hotspot/share/classfile/vmClasses.hpp index 364014a2514..f2b8c5666ee 100644 --- a/src/hotspot/share/classfile/vmClasses.hpp +++ b/src/hotspot/share/classfile/vmClasses.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, 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 @@ -52,7 +52,7 @@ class vmClasses : AllStatic { } static InstanceKlass* check_klass(InstanceKlass* k) { - assert(k != NULL, "klass not loaded"); + assert(k != nullptr, "klass not loaded"); return k; } diff --git a/src/hotspot/share/classfile/vmIntrinsics.cpp b/src/hotspot/share/classfile/vmIntrinsics.cpp index b511165521a..82bdcacd8e4 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.cpp +++ b/src/hotspot/share/classfile/vmIntrinsics.cpp @@ -620,7 +620,7 @@ void vmIntrinsics::init_vm_intrinsic_name_table() { const char* vmIntrinsics::name_at(vmIntrinsics::ID id) { const char** nt = &vm_intrinsic_name_table[0]; - if (nt[as_int(_none)] == NULL) { + if (nt[as_int(_none)] == nullptr) { init_vm_intrinsic_name_table(); } @@ -632,7 +632,7 @@ const char* vmIntrinsics::name_at(vmIntrinsics::ID id) { vmIntrinsics::ID vmIntrinsics::find_id(const char* name) { const char** nt = &vm_intrinsic_name_table[0]; - if (nt[as_int(_none)] == NULL) { + if (nt[as_int(_none)] == nullptr) { init_vm_intrinsic_name_table(); } @@ -655,7 +655,7 @@ bool vmIntrinsics::is_disabled_by_flags(vmIntrinsics::ID id) { // not initialized yet, process Control/DisableIntrinsic if (vm_intrinsic_control_words[as_int(_none)].is_default()) { - for (ControlIntrinsicIter iter(ControlIntrinsic); *iter != NULL; ++iter) { + for (ControlIntrinsicIter iter(ControlIntrinsic); *iter != nullptr; ++iter) { vmIntrinsics::ID id = vmIntrinsics::find_id(*iter); if (id != vmIntrinsics::_none) { @@ -664,7 +664,7 @@ bool vmIntrinsics::is_disabled_by_flags(vmIntrinsics::ID id) { } // Order matters, DisableIntrinsic can overwrite ControlIntrinsic - for (ControlIntrinsicIter iter(DisableIntrinsic, true/*disable_all*/); *iter != NULL; ++iter) { + for (ControlIntrinsicIter iter(DisableIntrinsic, true/*disable_all*/); *iter != nullptr; ++iter) { vmIntrinsics::ID id = vmIntrinsics::find_id(*iter); if (id != vmIntrinsics::_none) { @@ -768,7 +768,7 @@ const char* vmIntrinsics::short_name_as_C_string(vmIntrinsics::ID id, char* buf, default: break; } const char* kptr = strrchr(kname, JVM_SIGNATURE_SLASH); - if (kptr != NULL) kname = kptr + 1; + if (kptr != nullptr) kname = kptr + 1; int len = jio_snprintf(buf, buflen, "%s: %s%s.%s%s", str, fname, kname, mname, sname); if (len < buflen) diff --git a/src/hotspot/share/classfile/vmSymbols.cpp b/src/hotspot/share/classfile/vmSymbols.cpp index 7fb713c5778..6b7a4340afe 100644 --- a/src/hotspot/share/classfile/vmSymbols.cpp +++ b/src/hotspot/share/classfile/vmSymbols.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -37,7 +37,7 @@ #include "utilities/xmlstream.hpp" -Symbol* vmSymbols::_type_signatures[T_VOID+1] = { NULL /*, NULL...*/ }; +Symbol* vmSymbols::_type_signatures[T_VOID+1] = { nullptr /*, nullptr...*/ }; inline int compare_symbol(const Symbol* a, const Symbol* b) { if (a == b) return 0; @@ -102,7 +102,7 @@ void vmSymbols::initialize() { #ifdef ASSERT for (int i = (int)T_BOOLEAN; i < (int)T_VOID+1; i++) { Symbol* s = _type_signatures[i]; - if (s == NULL) continue; + if (s == nullptr) continue; SignatureStream ss(s, false); assert(ss.type() == i, "matching signature"); assert(!ss.is_reference(), "no single-char signature for T_OBJECT, etc."); @@ -140,7 +140,7 @@ void vmSymbols::initialize() { #ifdef ASSERT { // Spot-check correspondence between strings, symbols, and enums: - assert(Symbol::_vm_symbols[NO_SID] == NULL, "must be"); + assert(Symbol::_vm_symbols[NO_SID] == nullptr, "must be"); const char* str = "java/lang/Object"; TempNewSymbol jlo = SymbolTable::new_permanent_symbol(str); assert(strncmp(str, (char*)jlo->base(), jlo->utf8_length()) == 0, ""); @@ -293,6 +293,6 @@ vmSymbolID vmSymbols::find_sid(const Symbol* symbol) { vmSymbolID vmSymbols::find_sid(const char* symbol_name) { Symbol* symbol = SymbolTable::probe(symbol_name, (int) strlen(symbol_name)); - if (symbol == NULL) return vmSymbolID::NO_SID; + if (symbol == nullptr) return vmSymbolID::NO_SID; return find_sid(symbol); } diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 891292be7b8..f6a4d8b2143 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, 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 @@ -869,7 +869,7 @@ class vmSymbols: AllStatic { static Symbol* type_signature(BasicType t) { assert((uint)t < T_VOID+1, "range check"); - assert(_type_signatures[t] != NULL, "domain check"); + assert(_type_signatures[t] != nullptr, "domain check"); return _type_signatures[t]; }