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
java
command 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.This enhances
JavaToolMixin
to first runjava -version
, checking the
error code, and caching a_has_java_runtime
class 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
than runningjava
directly. This required some changes in
JavaToolMixin
to 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
java
, withjava
but no runtime,
and with a runtime.
Summary | ID |
---|---|
91b3319018d73fbaf31d5e5eb8a32b27fc3ba8ec |