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

Kim Barrett kbarrett at openjdk.org
Thu Oct 30 07:49:18 UTC 2025


On Wed, 29 Oct 2025 19:27:29 GMT, Matias Saavedra Silva <matsaave 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.

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

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


More information about the hotspot-runtime-dev mailing list