Commit eaec4e3
authored
[Xamarin.Android.Tools.AndroidSdk] More Microsoft Dist JDK Support (#130)
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1314263
Remember `AndroidSdkInfo.DetectAndSetPreferredJavaSdkPathToLatest()`
(commit a4aad18)? It's supposed to "detect" the latest installed
"preferred" JDK installation location, and set configuration values
so that subsequent `new AndroidSdkInfo()` expressions will use that
JDK location, instead of some other JDK location.
The "preferred" JDK was a JDK that was "known good" for Xamarin.Android
use, i.e. one that Visual Studio installed. In a4aad18, this was the
`microsoft_dist_openjdk_*` version.
When we (prematurely) removed support for the `microsoft_dist_openjdk_`
build in commits 237642c and dca30d9, we updated
`AndroidSdkInfo.DetectAndSetPreferredJavaSdkPathToLatest()` to instead
prefer the [Microsoft OpenJDK][0] build, but this migration needed to
be delayed until Visual Studio 17.0.
Which means that the "current world order" is *wrong*:
`AndroidSdkInfo.DetectAndSetPreferredJavaSdkPathToLatest()` tries to
detect a JDK that is not currently installed by anything.
Futhermore, Visual Studio for Mac will call
`AndroidSdkInfo.DetectAndSetPreferredJavaSdkPathToLatest()` if no JDK
is currently configured.
The result is that on "clean" systems, Visual Studio for Mac can
crash with a `NotSupportedException` because it's looking for a
Microsoft OpenJDK installation, but only a `microsoft_dist_openjdk_`
installation is available. Thus, no preferred JDK is found, and the
IDE crashes.
Fix this by adding a new (`internal`) `JdkInfo.GetPreferredJdkInfos()`
method, which appropriately checks *both* Microsoft OpenJDK *and*
`microsoft_dist_openjdk_` installation locations, and update
`AndroidSdkInfo.DetectAndSetPreferredJavaSdkPathToLatest()` to now
use `JdkInfo.GetPreferredJdkInfos()`.
(We add the method to `JdkInfo` so that it is easier to keep
`GetPreferredJdkInfos()` and `GetKnownSystemJdkInfos()` consistent
with each other.)
[0]: https://www.microsoft.com/openjdk1 parent f9c1b0d commit eaec4e3
File tree
2 files changed
+10
-1
lines changed- src/Xamarin.Android.Tools.AndroidSdk
2 files changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
| |||
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
303 | 312 | | |
304 | 313 | | |
305 | 314 | | |
| |||
0 commit comments