https://pantsbuild.org/ logo
#development
Title
# development
f

fast-nail-55400

02/23/2022, 6:28 PM
@ancient-vegetable-10556: Is there any way to obtain the absolute path to
JAVA_HOME
via
JdkEnvironment
?
a

ancient-vegetable-10556

02/23/2022, 6:29 PM
Yes!
Give me ~5 mins
f

fast-nail-55400

02/23/2022, 6:29 PM
👍
(context is letting BSP clients know where the relevant JDK is)
a

ancient-vegetable-10556

02/23/2022, 6:41 PM
@fast-nail-55400 it lives in
__java_home
in the root of the sandbox
it worries me slightly that BSP clients want to know where the relevant JDK is, because it’s very much the point that we don’t expose the JDK
f

fast-nail-55400

02/23/2022, 6:46 PM
And that is a relative link which was tripping ip making a file URI out of it which needs absolute path.
It's optional in the protocol but unclear to me whether IntelliJ will index JDK when using BSP unless this is given.
Will try hard-coding path for now to see what IntelliJ does.
IntelliJ adds a new JDK to its list using the path provided over BSP. So technically users could also supply a configured-in-IntelliJ JDK.
__java_home
in the sandbox is a symlink to the Coursier JDK cache, correct?
a

ancient-vegetable-10556

02/23/2022, 7:17 PM
Yes
And that jdk cache is a long-lived append-only cache
(sorry, missed this reply)
f

fast-nail-55400

02/23/2022, 7:36 PM
what would be the best way to resolve the absolute path on disk of that cache then?
a

ancient-vegetable-10556

02/23/2022, 7:39 PM
hrrrrrrm
I’d say the easiest way would be to get
jdk_preparation_script
to spit out its
$PWD
Oh wait, nope
It would be to run the
java_home_command
that’s set up inside
jdk_rules
, but we do not expose that just yet
f

fast-nail-55400

02/23/2022, 7:45 PM
ok so I’ll need to expose that then
this is a low priority BSP change in any event. just good to have the background context for it.
a

ancient-vegetable-10556

02/23/2022, 7:46 PM
I’d suggest pinging @witty-crayon-22786 to see how we’d expose that append-only cache directory directly, so that we control for future sandbox implementation changes
Another alternative would be to download the working JDK into a non-sandbox location for IDEs to use
which is probably the safest approach?
f

fast-nail-55400

02/23/2022, 7:49 PM
yeah and that would be consistent with discussion in https://github.com/pantsbuild/pants/issues/14562 regarding where to put compiled classfiles to expose them to the IDE
w

witty-crayon-22786

02/23/2022, 7:49 PM
imo, it’s “ok” to leak a location inside of the cache out, by invoking a process that will render the output of
java-home
.
…as part of an API like this. probably not elsewhere.