Found reviewing PR #232 (Windows JDK bootstrap). Verified against install.ps1 as merged.
What happens
Resolve-Java (install.ps1:237-290) probes JAVA_HOME, then the PATH, and otherwise calls Install-EmbeddedJdk. It never looks at $EMBEDDED_JDK_DIR — <Target>\jdk, the JDK a previous run of the same installer may already have put there.
Both generated launchers document and implement a three-step order whose first step is exactly that directory:
REM 1. the JDK bundled into this install (present only when the installer had to
REM bootstrap one because the host had no Java, or too old a Java)
REM 2. %JAVA_HOME%
REM 3. whatever java is on PATH
The installer implements only steps 2 and 3. It sets JAVA_HOME for the session only (deliberately, and correctly — install.ps1:282-286, a machine-wide JAVA_HOME would repoint every other tool on the box), so a later shell has no JAVA_HOME pointing at it either.
Consequence
On a host with no system Java, every re-run of the installer downloads the ~180 MB Temurin zip again and unpacks it over a perfectly good JDK. That includes the ordinary cases: upgrading the REPL version, re-running after a failed jar download, adding -NoExtensions.
Suggested fix
Probe <Target>\jdk\bin\java.exe first in Resolve-Java, through the same Get-JavaMajorFromExe check every other source gets, so a bundled JDK that already satisfies $REQUIRED_JAVA_VERSION short-circuits the bootstrap. That also makes the installer's resolution order match the one its own launchers advertise.
Found reviewing PR #232 (Windows JDK bootstrap). Verified against
install.ps1as merged.What happens
Resolve-Java(install.ps1:237-290) probesJAVA_HOME, then the PATH, and otherwise callsInstall-EmbeddedJdk. It never looks at$EMBEDDED_JDK_DIR—<Target>\jdk, the JDK a previous run of the same installer may already have put there.Both generated launchers document and implement a three-step order whose first step is exactly that directory:
The installer implements only steps 2 and 3. It sets
JAVA_HOMEfor the session only (deliberately, and correctly — install.ps1:282-286, a machine-wideJAVA_HOMEwould repoint every other tool on the box), so a later shell has noJAVA_HOMEpointing at it either.Consequence
On a host with no system Java, every re-run of the installer downloads the ~180 MB Temurin zip again and unpacks it over a perfectly good JDK. That includes the ordinary cases: upgrading the REPL version, re-running after a failed jar download, adding
-NoExtensions.Suggested fix
Probe
<Target>\jdk\bin\java.exefirst inResolve-Java, through the sameGet-JavaMajorFromExecheck every other source gets, so a bundled JDK that already satisfies$REQUIRED_JAVA_VERSIONshort-circuits the bootstrap. That also makes the installer's resolution order match the one its own launchers advertise.