testing the -target option

Alan Snyder javalists at cbfiddle.com
Thu Oct 31 20:29:11 UTC 2024


> You can satisfy your curiosity by looking the the javac regressions tests in the OpenJDK repo. Under
> 
> https://github.com/openjdk/jdk
> 
> see the test/langtools/tools/javac directory hierarchy.
> 

Thank you.

I took a quick look at the files in that directory. I found many examples of using -target (or --release). The negative tests are easy to understand. The feature tests less so, as apparently each individual test developer decides what releases to test.

The thoroughness of the tests varies considerably. A few tests use all of the supported releases (from 8 onward), but many just test one or two releases and the current release. I don't see any way to estimate the coverage of these tests.

Given that the byte code produced by javac is not examined, the best way to positively test the -target feature for a given target is to run tests that are compatible with that target, and I would think that the best source of such tests is the actual target release. It looks like jtreg could do this, using the -compilejdk and -javacoption options. Has anyone tried this?

The most comprehensive test would be to use the latest javac to build the target release and then run all of the normal pre-release tests. I'm guessing that could be done by making the latest JDK the boot JDK (although the documentation only mentions using older JDKs), setting COMPILER=bootjdk and JDK_SOURCE_TARGET_VERSION to the target release (if necessary). Not something to be done nightly, but perhaps a good idea shortly before blessing a new release.

  Alan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20241031/51544fd5/attachment-0001.htm>


More information about the compiler-dev mailing list