RFR: 8365940: Misleading macro in jvm_md.h:57
Matias Saavedra Silva
matsaave at openjdk.org
Thu Oct 30 16:05:00 UTC 2025
On Thu, 30 Oct 2025 07:46:45 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> The macro `JVM_MAXPATHLEN` should expand to the result of `MAXPATHLEN + 1` as the original result may lead to a different value when using the macro as part of an expression. Verified with tier 1-5 tests.
>
> 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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28049#discussion_r2478673652
More information about the hotspot-runtime-dev
mailing list