Skip to content

When locating a java binary, the tool only verifies that the binary is runnable if it came from Android Studio installation #139613

@andrewkolos

Description

@andrewkolos

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

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions