Commit 09c3152
committed
[Xamarin.Android.Tools.AndroidSdk] Parse Properties after header
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1397171
Context: https://www.4e00.com/blog/java/2016/12/16/java-command-line-options.html
We have a Watson report of an `InvalidOperationException` being
thrown from `JdkInfo.GetJavaProperties()`:
Xamarin.Android.Tools.AndroidSdk!Xamarin.Android.Tools.JdkInfo
...
clr!IL_Throw
Xamarin.Android.Tools.AndroidSdk!Xamarin.Android.Tools.JdkInfo.__c__DisplayClass46_0._GetJavaProperties_b__0
The dump provides an additional glimmer of information: the
`InvalidOperationException` message text:
Unknown property key for value (to execute a class)!
`JdkInfo.GetJavaProperties()` only contains one `throw`, for when we
think we're processing a multi-line value, but we don't have a key
for the value encountered.
Which brings us to [java-command-line-options.html][0], which isn't
English, and isn't recent, but *does* show `java` output which
contains our "offending" string of "(to execute a class)":
$ java -showversion -help
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
Usage: java [-options] class [args...]
(to execute a class)
...
What appears to be happening is that `JdkInfo` is encountering a JDK
for which `java -XshowSettings:properties -version` shows something
resembling the above `java -showversion -help` output, and the
" (to execute a class)" is treated as part of a multi-line
value, which it isn't.
Update `JdkInfo.GetJavaProperties()` so that we *require* that we see
"Property settings:" *before* we start looking for keys & values.
This should ensure that we appropriately ignore
"(to execute a class)".
Additionally, add a `JdkInfo` constructor overload which takes an
`Action<TraceLevel, string>? logger` parameter, a'la `AndroidSdkInfo`,
so that `JdkInfo` can provide additional "contextual" logging without
requiring the use of exceptions. Turn the lack of a key for a multi-
line value into a warning, instead of an exception.
Finally, update `tools/ls-jdks` so that it will accept a path
to a JDK to look at, and dump out the parsed properties.
[0]: https://www.4e00.com/blog/java/2016/12/16/java-command-line-options.html1 parent dac3a47 commit 09c3152
File tree
3 files changed
+66
-13
lines changed- src/Xamarin.Android.Tools.AndroidSdk
- tests/Xamarin.Android.Tools.AndroidSdk-Tests
- tools/ls-jdks
3 files changed
+66
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| 60 | + | |
| 61 | + | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| |||
78 | 87 | | |
79 | 88 | | |
80 | 89 | | |
81 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
86 | | - | |
| 97 | + | |
87 | 98 | | |
88 | | - | |
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| |||
217 | 227 | | |
218 | 228 | | |
219 | 229 | | |
220 | | - | |
| 230 | + | |
221 | 231 | | |
222 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
223 | 235 | | |
224 | 236 | | |
225 | 237 | | |
| |||
239 | 251 | | |
240 | 252 | | |
241 | 253 | | |
242 | | - | |
| 254 | + | |
243 | 255 | | |
244 | 256 | | |
245 | 257 | | |
| |||
248 | 260 | | |
249 | 261 | | |
250 | 262 | | |
| 263 | + | |
| 264 | + | |
251 | 265 | | |
252 | 266 | | |
253 | 267 | | |
254 | 268 | | |
| 269 | + | |
| 270 | + | |
255 | 271 | | |
256 | 272 | | |
257 | 273 | | |
258 | 274 | | |
| 275 | + | |
259 | 276 | | |
260 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
261 | 285 | | |
262 | | - | |
263 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
264 | 289 | | |
265 | 290 | | |
266 | 291 | | |
| |||
276 | 301 | | |
277 | 302 | | |
278 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
279 | 307 | | |
280 | 308 | | |
281 | 309 | | |
| |||
443 | 471 | | |
444 | 472 | | |
445 | 473 | | |
446 | | - | |
| 474 | + | |
447 | 475 | | |
448 | 476 | | |
449 | 477 | | |
450 | 478 | | |
451 | 479 | | |
452 | | - | |
| 480 | + | |
453 | 481 | | |
454 | 482 | | |
455 | | - | |
| 483 | + | |
456 | 484 | | |
457 | 485 | | |
458 | 486 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
12 | 37 | | |
13 | 38 | | |
14 | 39 | | |
| |||
0 commit comments