Fix Java-based tools when java is installed but there's no runtime.

Review Request #12088 — Created Feb. 25, 2022 and submitted — Latest diff uploaded

Information

ReviewBot
release-3.0.x

Reviewers

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 run java -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 running java 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, with java but no runtime,
and with a runtime.

Commits

Files

    Loading...