Fix Java-based tools when java is installed but there's no runtime.
Review Request #12088 — Created Feb. 25, 2022 and submitted
It's possible to have the
javacommand line tool without a runtime
installed, which prevents anything from executing. The Java support
wasn't built for this, incorrectly thinking that dependencies were met,
but failing to run.
JavaToolMixinto first run
java -version, checking the
error code, and caching a
_has_java_runtimeclass attribute, for
sharing across tools. Helper methods are available for unit tests to set
or clear this state, for testing.
The PMD tool now uses
JavaToolMixin, in order to take advantage of
this. Unlike other Java-based tools, PMD runs a wrapper script, rather
javadirectly. This required some changes in
JavaToolMixinto make fewer assumptions about its use.
And finally, the PMD tool had some code that assumed Unicode strings,
but broke with byte strings. The simulation tests gave it Unicode
strings, but it didn't instrument correctly with byte strings. The tests
have now been updated.
All relevant unit tests pass without
javabut no runtime,
and with a runtime.
Formalized the return type of
execute()to be Unicode.
Revision 2 (+280 -54)
Checks run (2 succeeded)