Closed ampusasidharan closed 3 years ago
It's the for loop on line 579:
# iterate over all Dict entries
for idx in $(seq 0 $((javaCounter - 1)))
do
version=$(/usr/libexec/PlistBuddy -c "print :$idx:JVMVersion" /dev/stdin <<< $javaXml)
path=$(/usr/libexec/PlistBuddy -c "print :$idx:JVMHomePath" /dev/stdin <<< $javaXml)
When javaCounter is 0 then seq 0 -1
makes PlistBuddy run twice with index -1 in the second iteration, when actually the loop should not run at all.
Possible solution:
for (( idx = 0 ; idx < javaCounter ; idx++ ))
But I don't know if that would introduce a typing problem for the compiled version, when $idx is used in a string. I guess that was the reason for writing the loop like this in the first place? So maybe enclosing the whole loop in an "if javaCounter > 0" instead?
Thanks for the hint @Flexperte! And sorry for the delay @ampusasidharan!
I added a fix with d83b501b8e11574835fc40773dbdf32ccd71b000 which implements a basic if guard.
This will be released shortly with v3.1.1
I'd be happy to get feedback for this fix. Give it a try by taking the latest version v3.1.1-beta
from the develop
branch... Otherwise v3.1.1 will be released in a couple of days anyways...
I'm submitting a bug.
Short description of the issue/suggestion: Terminating app due to uncaught exception when executing the app on a Mac where there is no Java (JDK) available.
Steps to reproduce the issue/enhancement:
What is the expected behavior? Exception should be handled the with a proper error message
What is the current behavior? It is failing with below uncaught exception
Unable to find any JVMs matching version "(null)". No Java runtime present, try --request to install. Print: Entry, ":0:JVMVersion", Does Not Exist Print: Entry, ":0:JVMHomePath", Does Not Exist 2020-10-19 11:59:32.898 PlistBuddy[75396:4189457] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray objectAtIndex:]: index (-1 (or possibly larger)) beyond bounds (0)' First throw call stack:
Do you have screenshots, GIFs, demos or samples which demonstrate the problem or enhancement? NA
What is the motivation / use case for changing the behavior? Executing the app on Mac with no Java
Please tell us about your environment:
Other information (e.g. related issues, suggestions how to fix, links for us to have context)