RFR: 8365940: Misleading macro in jvm_md.h:57

Matias Saavedra Silva matsaave at openjdk.org
Thu Oct 30 19:42:33 UTC 2025


On Thu, 30 Oct 2025 16:01:57 GMT, Matias Saavedra Silva <matsaave at openjdk.org> wrote:

>> src/hotspot/os/posix/include/jvm_md.h line 57:
>> 
>>> 55: //       Linux releases. Here we define JVM_MAXPATHLEN to be MAXPATHLEN + 1,
>>> 56: //       so buffers declared in VM are always >= 4096.
>>> 57: #define JVM_MAXPATHLEN (MAXPATHLEN + 1)
>> 
>> Per the comment immediately preceeding the definition, JVM_MAXPATHLEN exists
>> to support "JVM and the rest of JDK are built on different Linux releases". We
>> used to have the JVM and the rest of the JDK separable, and could use
>> (somewhat) different versions of them together. But that model was elminated
>> years ago.
>> 
>> All uses of JVM_MAXPATHLEN are in HotSpot. (There are also
>> unused *definitions* of that name in
>> jdk.hotspot.agent/share/native/libsaproc/sadis.c.)
>> 
>> Looking around, there are many uses of MAXPATHLEN in HotSpot. If we really
>> need JVM_MAXPATHLEN, how sure are we that all of those uses of MAXPATHLEN are
>> okay?
>> 
>> So maybe it would be better to just remove JVM_MAXPATHLEN and use MAXPATHLEN
>> everywhere.
>
> Thanks for finding that, I was also unsure whether or not the comment above was still valid today. I agree that if JVM_MAXPATHLEN is actually unneeded it can be removed.

After further inspection, MAXPATHLEN seems to only be used within the hotspot/os directory and other areas in Hotspot rely on JVM_MAXPATHLEN. Tampering with this could cause some issues since the value of JVM_MAXPATHLEN varies between platforms and does not necessarily rely on MAXPATHLEN. The simple fix in this PR is sufficient.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28049#discussion_r2479305235


More information about the hotspot-runtime-dev mailing list