RFR: JDK-8300241: Replace NULL with nullptr in share/classfile/
Johan Sjölen
jsjolen at openjdk.org
Tue Jan 24 22:44:59 UTC 2023
On Tue, 17 Jan 2023 11:13:22 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
> Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory share/classfile/. Unfortunately the script that does the change isn't perfect, and so we
> need to comb through these manually to make sure nothing has gone wrong. I also review these changes but things slip past my eyes sometimes.
>
> Here are some typical things to look out for:
>
> 1. No changes but copyright header changed (probably because I reverted some changes but forgot the copyright).
> 2. Macros having their NULL changed to nullptr, these are added to the script when I find them. They should be NULL.
> 3. nullptr in comments and logs. We try to use lower case "null" in these cases as it reads better. An exception is made when code expressions are in
> a comment.
>
> An example of this:
>
> ```c++
> // This function returns null
> void* ret_null();
> // This function returns true if *x == nullptr
> bool is_nullptr(void** x);
>
>
> Note how `nullptr` participates in a code expression here, we really are talking about the specific value `nullptr`.
>
> Thanks!
Found some manual fix ups.
Hi, I'm opening this up for review. It builds on my machine and I'm sending it off for tier1 testing. I haven't fixed my comments yet.
src/hotspot/share/classfile/classFileParser.cpp line 796:
> 794: // of table since we don't expect Symbol*'s to move.
> 795: static bool put_after_lookup(const Symbol* name, const Symbol* sig, NameSigHash** table) {
> 796: assert(name != nullptr, "name in constant pool is nullptr");
Change to null in string!
src/hotspot/share/classfile/classFileParser.cpp line 895:
> 893: const InstanceKlass* const k = _local_interfaces->at(index);
> 894: name = k->name();
> 895: // If no duplicates, add (name, null) in hashtable interface_names.
Maybe nullptr better here?
src/hotspot/share/classfile/javaClasses.cpp line 4287:
> 4285: java_lang_Class::print_signature(rt, st);
> 4286: } else {
> 4287: st->print("nullptr");
print "null"
src/hotspot/share/classfile/javaClasses.cpp line 4475:
> 4473:
> 4474: ClassLoaderData* java_lang_ClassLoader::loader_data_acquire(oop loader) {
> 4475: assert(loader != nullptr, "loader must not be nullptr");
Fix nullptr in string
src/hotspot/share/classfile/javaClasses.cpp line 4481:
> 4479:
> 4480: ClassLoaderData* java_lang_ClassLoader::loader_data(oop loader) {
> 4481: assert(loader != nullptr, "loader must not be nullptr");
Fix nullptr in string
src/hotspot/share/classfile/javaClasses.cpp line 4487:
> 4485:
> 4486: void java_lang_ClassLoader::release_set_loader_data(oop loader, ClassLoaderData* new_data) {
> 4487: assert(loader != nullptr, "loader must not be nullptr");
Fix nullptr in string
src/hotspot/share/classfile/klassFactory.hpp line 56:
> 54: *
> 55: * On broken invariants and/or runtime errors the returned value will be
> 56: * nullptr (or a nullptr handle) and the caller *might* now have a pending exception.
Fix nullptr in comments.
src/hotspot/share/classfile/modules.cpp line 62:
> 60:
> 61: static bool verify_package_name(const char* package_name, int len) {
> 62: assert(package_name != nullptr, "Package name derived from non-null jstring can't be nullptr");
Fix nullptr in string
src/hotspot/share/classfile/modules.cpp line 441:
> 439: ls.print("define_module(): creation of module: %s, version: %s, location: %s, ",
> 440: module_name, version_symbol != nullptr ? version_symbol->as_C_string() : "nullptr",
> 441: location_symbol != nullptr ? location_symbol->as_C_string() : "nullptr");
Fix nullptr in string
src/hotspot/share/classfile/modules.cpp line 702:
> 700: package_entry->name()->as_C_string(),
> 701: from_module_entry->name()->as_C_string(),
> 702: to_module_entry == nullptr ? "nullptr" :
Fix nullptr in string
src/hotspot/share/classfile/modules.cpp line 808:
> 806: assert(h_loader.is_null() || java_lang_ClassLoader::is_subclass(h_loader->klass()),
> 807: "Class loader is not a subclass of java.lang.ClassLoader");
> 808: assert(package_name != nullptr, "the package_name should not be nullptr");
Fix nullptr in string
src/hotspot/share/classfile/resolutionErrors.cpp line 67:
> 65: {
> 66: assert_locked_or_safepoint(SystemDictionary_lock);
> 67: assert(!pool.is_null() && error != nullptr, "adding nullptr obj");
Fix nullptr in string
src/hotspot/share/classfile/resolutionErrors.cpp line 79:
> 77: {
> 78: assert_locked_or_safepoint(SystemDictionary_lock);
> 79: assert(!pool.is_null() && message != nullptr, "adding nullptr obj");
Fix nullptr in string
src/hotspot/share/classfile/systemDictionary.cpp line 521:
> 519: "Only called when enabling legacy parallel class loading logic "
> 520: "for non-parallel capable class loaders");
> 521: assert(lockObject() != nullptr, "lockObject must be non-nullptr");
Fix nullptr in string
src/hotspot/share/classfile/verificationType.cpp line 194:
> 192: } else {
> 193: st->print_cr("nullptr");
> 194: }
Fix nullptr in string
src/hotspot/share/classfile/verifier.cpp line 2839:
> 2837: // Found the entry for the signature's verification types in the hash table.
> 2838: mth_sig_verif_types = *mth_sig_verif_types_ptr;
> 2839: assert(mth_sig_verif_types != nullptr, "Unexpected nullptr sig_as_verification_types value");
Fix nullptr in string
-------------
PR: https://git.openjdk.org/jdk/pull/12030
More information about the hotspot-dev
mailing list