heroku / heroku-buildpack-jvm-common

Heroku's OpenJDK buildpack. A component of the Java, Scala, and Clojure buildpacks.
MIT License
41 stars 51 forks source link

[BUG] -XX:+UseContainerSupport not present in $JAVA_TOOL_OPTIONS for JAVA_VERSION >= 20 #306

Open greghuc opened 3 months ago

greghuc commented 3 months ago

Hi there

I just noticed that -XX:+UseContainerSupport is not present in $JAVA_TOOL_OPTIONS for my app running JAVA_VERSION="22.0.1" (this is the exact line in $JAVA_HOME/release file)

Eyeballing the code, this grep in jvmcommon.sh looks like it breaks for a JAVA_VERSION >= 20, since the regex only handles JAVA_VERSION=10..19

I presume this is a bug, rather than intentional?

Thanks

Greg

Malax commented 3 months ago

Hi @greghuc!

Thanks for opening this issue! You're absolutely right, this is not intentional. However, UseContainerSupport is enabled by default in the JVM/HotSpot for a long time now. This means that in practice this bug does not have any effect on the app. You should be able to verify this by printing the JVM flags on application startup with -XX:+PrintFlagsFinal.

Ultimately, the buildpack shouldn't set UseContainerSupport explicitly anymore as all supported versions enable this flag by default, even Java 8 (in newer versions).

I will keep this issue open to track that process.

Let me know if you have further input or questions, happy to discuss! :)

greghuc commented 3 months ago

Hi @Malax

That all makes sense. Thanks for the update!