We have a number of places in our tests where we do different things for Java 8. In opensaml, this is centralised; in the IdP it's distributed around the tests.
The way version detection is performed in each of these cases was built to distinguish between Java 7 (and to a limited extent Java 6) and Java 8, and tend to be described in terms of whether Java 8 is in use.
The detection mechanisms written for that context mostly fail in the presence of Java 9 (either by throwing an exception or correctly detecting Java 9 as "not 8" and then interpreting that as Java 7), and of course further down the line we will have to deal with the new post-V9 version system.
It seems clear that rather than having multiple places to update this on the (now much more frequent) release of a new Java version, we should centralise this functionality in java-support.
To avoid exposing a broader API than strictly necessary, I propose a utility class with (for now) a single isV8OrLater method:
- The more obvious API of returning "the Java version" and then having clients compare against it begs the question of what the sequence and ordering of those values will be in the future.
- I don't think we ever want to write tests for "==8" or similar, given the intended increased release rate.
It's not clear to me which of the existing java-support packages this would live in; maybe we need a new one.