paketo-buildpacks / libjvm

A library and helper applications that form the basis for building the different Paketo-style JVM-providing buildpacks
Apache License 2.0
19 stars 20 forks source link

Fix spring-boot#481: add JRE_HOME #395

Closed anthonydahanne closed 4 months ago

anthonydahanne commented 4 months ago

Checklist

dmikusa commented 4 months ago

So if I have this correct.

At build time:

I'm curious what the behavior of PATH is here, given that both the JRE & JDK will be on PATH. I guess it depends on how the lifecycle processes the layers and puts them on the PATH? What have you observed @anthonydahanne ?

dmikusa commented 4 months ago

Should we also update the JLink installer?

That presently sets JAVA_HOME at build time but not JRE_HOME or JDK_HOME. I'm not 100% sure what it should do though. Probably JRE_HOME cause we strip out the JDK part, at least by default, and you're guaranteed to have at least a JRE.

anthonydahanne commented 4 months ago

At build time:

JRE_HOME -> the JRE
JDK_HOME -> the JDK
JAVA_HOME -> the JDK (cause JRE is set to default, and JDK is set to override)

Almost: if the buildplan requires both JRE and JDK: JRE_HOME -> the JDK

I'm curious what the behavior of PATH is here, given that both the JRE & JDK will be on PATH. I guess it depends on how the lifecycle processes the layers and puts them on the PATH? What have you observed @anthonydahanne ?

Well, PATH is kind of... not predictable. What I have observed is JDK path sometimes before, sometimes after JRE path in the PATH env. So, that was not deterministic to call java from a contribute method, so that's why it's fixed using JRE_HOME/bin/java

Should we also update the JLink installer?

That, I don't know. But... I supposed it's not required if nobody had any issues with it so far. We had the issue with CDS training run: CDS MUST use the same JVM during training run and runtime; and because of PATH, it was not reliable

dmikusa commented 4 months ago

Well, PATH is kind of... not predictable. What I have observed is JDK path sometimes before, sometimes after JRE path in the PATH env.

Interesting 🤔 I'm going to mention this upstream and see what they say.

Almost: if the buildplan requires both JRE and JDK: JRE_HOME -> the JDK

Oh, that's not what I would have expected. Why would JRE_HOME point to the JDK? Isn't that what you're trying to avoid? Cause the JDK would run the CDS training, but then the JRE would run the app at runtime and they'd be different?

anthonydahanne commented 4 months ago

oh I'm sorry, I pressed enter too fast I meant to say:

Almost: if the buildplan requires ONLY a JDK (BP_JVM_TYPE=jdk): JRE_HOME -> the JDK