flutter/packages/flutter_tools/test/general.shard
Andrew Kolos c22c19b6e2
have Java.version return null if java --version fails or cannot be run (#139614)
## Summary
Fixes https://github.com/flutter/flutter/issues/139180, where `flutter create` could crash if the `java` binary the tool found cannot be run.

## Context

At startup, the tool searches for a Java installation[^1]. Unless the located installation is from [an Android Studio installation](e1967ecabf/packages/flutter_tools/lib/src/android/android_studio.dart (L163)), the tool does not verify that the binary is runnable. For more, see https://github.com/flutter/flutter/issues/139613, which tracks this inconsistency in behavior. 

This means that in the scenario where

1) the user does not have Android Studio installed or the java binary found within cannot be run **and**
2) the user has a) `flutter config --jdk-dir` set, b) `JAVA_HOME` set in their environment, **or** c) `java` on their system path **and**
3) the java binary we think we found during cannot be run (or `java --version` fails), **then**

the user running `flutter create` with Android enabled will hit a tool crash.

## Change

`Java.version` should return null if version checking fails for any reason. [This is documented behavior](48f57621ad/packages/flutter_tools/lib/src/android/java.dart (L136)). Therefore, we'll update the implementation to first verify that the binary is runnable. If it isn't, it will return `null`.

[^1]: We find java by calling the static `Java.find`, see: 48187028c1/packages/flutter_tools/lib/src/context_runner.dart (L271)
[^2]: This PR doesn't change this, as this would be too dangerous to cherry-pick into stable.
2023-12-06 23:13:17 +00:00
..
android have Java.version return null if java --version fails or cannot be run (#139614) 2023-12-06 23:13:17 +00:00
base Reduce animations further when --no-cli-animations is set. (#133598) 2023-11-16 21:05:22 +00:00
build_system Add commandHasTerminal parameter + apple usage event + sendException events for package:unified_analytics (#138806) 2023-11-22 12:25:10 +00:00
commands Flutter preview device (#135639) 2023-10-18 00:27:54 +00:00
custom_devices Don't build native assets in flutter build bundle (#136641) 2023-10-18 11:57:44 +00:00
dap
dart
drive Migration for HotEvent for Flutter hot runner (#137717) 2023-11-06 21:33:11 +00:00
fuchsia
intellij prevent tool crash when IntelliJValidatorOnMac encounters an installation with a missing CFBundleIdentifier (#138095) 2023-11-09 03:46:25 +00:00
ios [Reland] Migration for the sendTiming events for package:unified_analytics (#139299) 2023-12-04 21:39:18 +00:00
linux [native assets] Tool exit on build failure (#137995) 2023-11-07 16:41:19 +00:00
macos Give an actionable error message when a Pod requires a higher minimum OS version (#138097) 2023-11-27 16:22:54 +00:00
migrations Native assets support for Windows (#134203) 2023-09-27 12:22:58 +00:00
proxied_devices Send an event when proxied DDS creates a connection. (#139530) 2023-12-05 08:32:25 +00:00
reporting [flutter_tools] fix instructions to disable CLI animations (#139094) 2023-11-27 22:00:50 +00:00
runner [Reland] Migration for the sendTiming events for package:unified_analytics (#139299) 2023-12-04 21:39:18 +00:00
test Reland "Switch flutter_tools to run frontend server from AOT snapshot" (#136282) 2023-10-11 16:15:26 -04:00
tester Native assets support for MacOS and iOS (#130494) 2023-09-10 08:07:13 +00:00
vscode Added support for vscode and vscode-insiders installed via Flatpak (#137123) 2023-12-04 21:59:53 +00:00
web [Reland] Migration for the sendTiming events for package:unified_analytics (#139299) 2023-12-04 21:39:18 +00:00
windows [native assets] Tool exit on build failure (#137995) 2023-11-07 16:41:19 +00:00
analytics_test.dart Flutter preview device (#135639) 2023-10-18 00:27:54 +00:00
android_plugin_test.dart
application_package_test.dart
args_test.dart
artifact_updater_test.dart
artifacts_test.dart [flutter_tools] Fix local engine preview device (#138046) 2023-11-08 01:53:22 +00:00
asset_bundle_package_fonts_test.dart
asset_bundle_package_test.dart
asset_bundle_test.dart [web] Encode AssetManifest.bin as JSON and use that on the web. (#131382) 2023-09-19 22:38:51 +00:00
asset_bundle_variant_test.dart
asset_test.dart
base_utils_test.dart
build_info_test.dart do not include entries from --dart-define-from-file files in the gradle config or environment during build (#136865) 2023-10-19 21:01:51 +00:00
bundle_builder_test.dart Add --frontend-server-starter-path option to flutter run and flutter test (#135038) 2023-09-21 14:32:35 -04:00
cache_test.dart Remove bringup: true from realm_checker and remove the redundant tool test. (#137186) 2023-10-25 01:09:18 +00:00
channel_test.dart
cmake_test.dart
cold_test.dart
common_test.dart
compile_batch_test.dart Reland "Switch flutter_tools to run frontend server from AOT snapshot" (#136282) 2023-10-11 16:15:26 -04:00
compile_expression_test.dart
compile_incremental_test.dart Reland "Switch flutter_tools to run frontend server from AOT snapshot" (#136282) 2023-10-11 16:15:26 -04:00
compile_test.dart
config_test.dart
convert_test.dart
coverage_collector_test.dart Reland coverableLineCache optimisation (#136851) (#137385) 2023-10-30 11:00:30 +13:00
crash_reporting_test.dart
create_config_test.dart
daemon_test.dart
dart_plugin_test.dart
desktop_device_test.dart Add --trace-to-file option to flutter run (#135713) 2023-10-12 13:23:52 -04:00
devfs_test.dart Native assets support for MacOS and iOS (#130494) 2023-09-10 08:07:13 +00:00
device_port_forwarder_test.dart
device_test.dart Add --trace-to-file option to flutter run (#135713) 2023-10-12 13:23:52 -04:00
devtools_launcher_test.dart
emulator_test.dart
fake_native_assets_build_runner.dart Native assets support for Windows (#134203) 2023-09-27 12:22:58 +00:00
fake_process_manager_test.dart
features_test.dart Native assets support for MacOS and iOS (#130494) 2023-09-10 08:07:13 +00:00
flutter_manifest_test.dart Fix tool exit message shown when user provides a non-list to "assets" for a deferred component (#137837) 2023-11-06 04:01:25 +00:00
flutter_platform_test.dart
flutter_project_metadata_test.dart Native assets support for MacOS and iOS (#130494) 2023-09-10 08:07:13 +00:00
flutter_tester_device_test.dart Catch error for missing directory in FontConfigManager (#138496) 2023-11-15 23:17:29 +00:00
flutter_validator_test.dart
generate_localizations_test.dart Add type validation to non-template .arb file parsing logic (#139035) 2023-11-27 20:50:24 +00:00
github_template_test.dart
hot_test.dart [Reland] Migration for the sendTiming events for package:unified_analytics (#139299) 2023-12-04 21:39:18 +00:00
html_utils_test.dart
integration_test_device_test.dart
license_collector_test.dart
mdns_discovery_test.dart Add commandHasTerminal parameter + apple usage event + sendException events for package:unified_analytics (#138806) 2023-11-22 12:25:10 +00:00
message_parser_test.dart
persistent_tool_state_test.dart
plugin_parsing_test.dart
plugins_test.dart [flutter_tools] toolexit when using plugins with preview device (#136936) 2023-11-07 20:37:19 +00:00
preview_device_test.dart Don't build native assets in flutter build bundle (#136641) 2023-10-18 11:57:44 +00:00
project_file_invalidator_test.dart
project_test.dart [Android] Support Android 34 (take 2) (#137967) 2023-11-09 22:40:15 +00:00
project_validator_result_test.dart
protocol_discovery_test.dart
pub_dependencies_project_validator_test.dart
resident_devtools_handler_test.dart
resident_runner_test.dart [Reland] Migration for the sendTiming events for package:unified_analytics (#139299) 2023-12-04 21:39:18 +00:00
resident_web_runner_cold_test.dart Migration for HotEvent for Flutter hot runner (#137717) 2023-11-06 21:33:11 +00:00
resident_web_runner_test.dart [Reland] Migration for the sendTiming events for package:unified_analytics (#139299) 2023-12-04 21:39:18 +00:00
run_hot_test.dart Migration for HotEvent for Flutter hot runner (#137717) 2023-11-06 21:33:11 +00:00
template_test.dart
terminal_handler_test.dart [flutter_tools] remove VmService screenshot for native devices. (#135462) 2023-09-29 00:21:14 +00:00
testbed_test.dart
time_test.dart
tracing_test.dart
unified_analytics_test.dart Update analytics constructor to include FLUTTER_HOST (#138107) 2023-11-10 17:44:08 +00:00
update_packages_test.dart Roll dependencies (#139203) 2023-11-29 20:12:59 +00:00
utils_test.dart
version_test.dart [flutter_tools] Fix "FormatException: Invalid date format" during version freshness check (#134088) 2023-09-06 17:22:13 +00:00
vmservice_test.dart [flutter_tools] remove VmService screenshot for native devices. (#135462) 2023-09-29 00:21:14 +00:00
windows_version_validator_test.dart
xcode_backend_test.dart Add --frontend-server-starter-path option to flutter run and flutter test (#135038) 2023-09-21 14:32:35 -04:00