JDK-8342860 : Fix more NULL usage backsliding
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 24
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-10-22
  • Updated: 2024-11-24
  • Resolved: 2024-11-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b24Fixed
Related Reports
Relates :  
Relates :  
Description
In the 1/2 year since JDK-8327171 there have been a number of new uses of NULL introduced into HotSpot code.

egrep "[^[:alnum:]_]NULL([^[:alnum:]_]|$)" on {src,test}/hotspot was used to find these, with some known cases removed.  (Some in globalDefinitions_xxx.hpp require more work, jvmti.{xml,xsl} are generating C code.)

These are all in comments, and should be using "null" instead of "NULL".
-----
src/hotspot/os/posix/os_posix.cpp:819:    // It is possible that we found a NULL symbol, hence no error.
src/hotspot/share/oops/constantPool.cpp:480:    // has cleared the resolved_klasses()->at(...) pointer to NULL. Thus, we
src/hotspot/share/opto/escape.cpp:648:// against the NULL constant, otherwise it will be against the constant input of
src/hotspot/share/opto/escape.cpp:676:// against NULL.
src/hotspot/share/opto/escape.cpp:810:// juse use a CmpP/N against the NULL constant.
src/hotspot/share/opto/escape.cpp:813:// splitted cast was not nullable (or if it was the NULL constant) then we don't
src/hotspot/share/opto/escape.cpp:841://                         Call  NULL
src/hotspot/share/opto/escape.cpp:877:  //  - nullptr:    Meaning that the base is actually the NULL constant and therefore
-----

These are in comments, but the language is C.  We probably want to use "null" here anyway.
-----
src/hotspot/share/include/jvm.h:422: * Find a class from a boot class loader. Returns NULL if class not found. 
src/hotspot/share/include/cds.h:72:  char*   _mapped_base;       // Actually mapped address (NULL if this region is not mapped). 
-----

These are in string literals, and should be using "null" instead of "NULL".
-----
src/hotspot/share/opto/library_call.cpp:7777:  assert(a_start, "a array is NULL");
src/hotspot/share/opto/library_call.cpp:7779:  assert(b_start, "b array is NULL");
src/hotspot/share/opto/library_call.cpp:7781:  assert(r_start, "r array is NULL");
src/hotspot/share/opto/library_call.cpp:7806:  assert(a_start, "a array is NULL");
src/hotspot/share/opto/library_call.cpp:7808:  assert(b_start, "b array is NULL");
-----

These are in code, and should be using "nullptr" instead of "NULL".
-----
src/hotspot/os/linux/cgroupSubsystem_linux.cpp:170:  while ((token = strsep(&mo_ptr, ",")) != NULL) {
src/hotspot/os/windows/os_windows.cpp:4153:  if (RegQueryValueExA(hKey, valueName, NULL, NULL, (LPBYTE)buffer, &valueLength) != ERROR_SUCCESS) {
src/hotspot/os/aix/os_aix.cpp:471:      void* p = mmap(NULL, 64*K, PROT_READ | PROT_WRITE, MAP_ANON_64K | MAP_ANONYMOUS | MAP_SHARED, -1, 0);
src/hotspot/share/classfile/classLoader.cpp:1245:    return (char) strtol(hex, NULL, 16);
src/hotspot/share/services/diagnosticFramework.cpp:427:  while (token != NULL) {
-----

Comments
Changeset: 7d6a2f37 Branch: master Author: theoweidmannoracle <theo.weidmann@oracle.com> Date: 2024-11-08 13:31:24 +0000 URL: https://git.openjdk.org/jdk/commit/7d6a2f3740bf42652bdf05bb922d1f2b2ae60d6a
08-11-2024

I updated the regex in the description to also find "NULL"s at end of line.
05-11-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/21826 Date: 2024-11-01 13:35:56 +0000
05-11-2024

There are more in the compiler code than runtime code, so sending it to compiler.
28-10-2024