RFR: 8343802: Prevent NULL usage backsliding

Julian Waters jwaters at openjdk.org
Wed Feb 5 17:35:36 UTC 2025


On Wed, 5 Feb 2025 15:39:32 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

> Please review this patch to add a test that checks the hotspot sources and test files for usages of NULL.
> It scans files in those directories, filtering out certain files as well as all `.c`, `.java` and `.jar` files in test sources. 
> 
> Before adding line 86 and excluding `os_windows.cpp`, the test failed with:
> 
> 
> Error: 'NULL' found in /w/jdk/src/hotspot/os/windows/os_windows.cpp at line 4436:
>     HMODULE hModule = NULL;
> Error: 'NULL' found in /w/jdk/src/hotspot/os/windows/os_windows.cpp at line 4437:
>     GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, &hModule);
> java.lang.RuntimeException: Found usage of 'NULL' in source files. See errors above.
> 	at TestNoNULL.main(TestNoNULL.java:73)
> 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
> 	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
> 	at java.base/java.lang.Thread.run(Thread.java:1447)

Seems like this solution would require someone working on the JDK to run the proper test, something which not everyone is guaranteed to do when working on HotSpot. Is there a way to make this part of the build process so trying to compile HotSpot will fail if there are NULLs in the source code?

EDIT: Removed the quoting of the original Pull Request body

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23466#issuecomment-2637585100


More information about the hotspot-dev mailing list