HotSpot doesn't use NULL

Volker Simonis volker.simonis at gmail.com
Tue Nov 26 07:24:41 UTC 2024


When I forwarded this to our team, William suggested to add a new jcheck
test to warn about this. I'm not familiar with the new git-jcheck, but at a
first glance, this looks like an interesting opportunity to me.

What do you think?

Kim Barrett <kim.barrett at oracle.com> schrieb am Di., 26. Nov. 2024, 01:26:

> On 11/25/24 7:16 AM, Kennke, Roman wrote:
> > Is it possible - and would it make sense - to mechanically forbit NULL?
> E.g. by re-defining it in a central place, just like we do for other stuff
> like constuctors for certain things?
> I don't think so.
>
> Redefining it in a way that makes it unusable seems problematic because it
> might affect non-HotSpot code. An example where I'm pretty sure this
> would be
> a problem is gtest.
>
> Redefining it in a way that still works, as is currently done for
> Windows (see
> JDK-8324686) doesn't prevent adding new uses.
>
> Something like the suggestion in JDK-8343802 is the only viable approach
> I've
> been able to come up with.  I've seen discussion that maybe there should
> be a
> gcc -Wnull-as-null-pointer-constant (alongside the existing
> -Wzero-as-null-pointer-constant), but that doesn't currently exist, and
> would
> only help for gcc-based platforms.
>
> clang-tidy has modernize-use-nullptr: "The check converts the usage of null
> pointer constants (e.g. NULL, 0) to use the new C++11 and C23 nullptr
> keyword."  Perhaps something could be built on that? Doing so is likely
> more
> work than the grep-based approach suggested in JDK-8343802.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20241126/c116f623/attachment.htm>


More information about the hotspot-dev mailing list