-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I discovered this while investigating a crasher within the flutter tool, #139180. I'm filing this as a separate issue, because the scope of this issue is wider than fixing the crash. A fix for this would not be suitable for cherry-picking onto stable.
At startup, the tool searches for a Java installation1. Unless the located installation is from an Android Studio installation, the tool does not verify that the binary 1) exists and 2) is runnable. Said another way, the tool—during its search—does not discard invalid Java installations that come from flutter config --jdk-dir, JAVA_HOME, or the path.
Shouldn't we always verify that the java binary exists and is runnable before deeming it suitable for use throughout the rest of the tool? This isn't a serious issue at present, because folks that get vague Java-related issues at runtime (e.g. Gradle errors from flutter build apk) can check flutter doctor, where they will see that the Java version could not be verified. Still, this is confusing behavior at the very least.
Footnotes
-
We find java by calling the static
Java.find, see: https://github.com/flutter/flutter/blob/48187028c11ca8ca10e0179705d25553e1fe2c14/packages/flutter_tools/lib/src/context_runner.dart#L271 ↩