TheInfiniteKind / appbundler

71 stars 24 forks source link

Searching JDK version by first token with dash is error-prone #87

Open Vampire opened 9 months ago

Vampire commented 9 months ago

If you for example use the mxschmitt/action-tmate@v3 action to get a login onto a GitHub Action runner, and call /usr/libexec/java_home -V you will see that the paths of the JDKs are like /Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.9-9/x64/Contents/Home.

If in such or similar situation the findJDKDylib algorithm is followed, it misses to find jdk1., then cuts as the first - and then again at the first /. This results in the "version" Hotspot_jdk which then of course fails the major version check.

The algorithm should be improved to check for further occurrences, or validate that digits are following or similar.

Vampire commented 9 months ago

Actually even checking all dashes would not help in this case, as for the shown example 9 would then be determined as version. It should probably actually call the executable to retrieve its version like for the JRE search.

rschmunk commented 9 months ago

I've thought for a while that actually asking the executable what its version is would be the best route.

Vampire commented 9 months ago

Expect a PR soon, I made that and some other improvements locally already. :-)