RFR: CODETOOLS-7902936 Stray VM warnings in forked PrintPropertiesMain lead to hard to debug XML parse exception
Aleksey Shipilev
shade at openjdk.java.net
Fri May 21 08:11:43 UTC 2021
On Fri, 21 May 2021 02:27:09 GMT, Jason Zaugg <jzaugg at openjdk.org> wrote:
> - Recover from stray output before the XML prelude
> - Report the output in the exception otherwise
> - Silence VM warnings in PrintPropertiesMain when JEP-158 (-Xlog:) is available (JRE 9+)
I see little sense in trying to recover here. The stray VM output can come in the middle of that XML dump too. I would prefer to cover the "hard to debug" part only: dump the proper diagnostics and then fail hard. We can probably print the helpful message how to shun the VM warnings, if user is so inclined?
jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java line 839:
> 837: command.add("-XX:+IgnoreUnrecognizedVMOptions");
> 838: command.add("-Xlog:all=error");
> 839:
I think pushing `-Xlog:` to unsuspecting VMs is asking for trouble, even with `IgnoreUnrecognizedVMOptions`. Let's not do this.
jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java line 595:
> 593: try {
> 594: out.loadFromXML(new ByteArrayInputStream(baos.toByteArray()));
> 595: } catch (InvalidPropertiesFormatException ex) {
Move this `catch` block to the existing `try-catch` block. Make the whole thing failing hard without trying to recover. Print the output contents in the exception.
jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java line 597:
> 595: } catch (InvalidPropertiesFormatException ex) {
> 596: // Maybe some VM output has preceded the XML content?
> 597: String output = new String(baos.toByteArray(), Charset.defaultCharset());
I suspect that since we are reading from the console, we need to use `Utils.guessConsoleCharset()` instead of trusting the default one.
-------------
Changes requested by shade (Committer).
PR: https://git.openjdk.java.net/jmh/pull/41
More information about the jmh-dev
mailing list