From 2879fe8b4127c2c06654aaf70c74ec456396fbb0 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 15 Jan 2022 18:29:38 +0100 Subject: [PATCH] cmd/gogio: add support for OpenJDK to java version detection When the `d8` command from the Android SDK fails because of an incompatible java version, the error message is cryptic. Before reporting the errors, we attempt to detect incompatible versions and report a clearer error. This change adds support for OpenJDK as well as other vendors to the detection logic. Fixes: https://todo.sr.ht/~eliasnaur/gio/342 Signed-off-by: Elias Naur --- cmd/gogio/androidbuild.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/gogio/androidbuild.go b/cmd/gogio/androidbuild.go index b322ae9d..12148c30 100644 --- a/cmd/gogio/androidbuild.go +++ b/cmd/gogio/androidbuild.go @@ -595,8 +595,9 @@ func determineJDKVersion() (int, int, bool) { if err != nil { return 0, 0, false } + var vendor string var major, minor int - _, err = fmt.Sscanf(string(out), "java version \"%d.%d", &major, &minor) + _, err = fmt.Sscanf(string(out), "%s version \"%d.%d", &vendor, &major, &minor) return major, minor, err == nil }