I recently discovered that one of my units tests fails due to a bug in the JDK i.e. JDK-8080774
What is the best way of writing a conditional unit test – which checks the output one way for JDK versions where the bug fix is present and a different way when the bug fix is absent?
In case of JDK bug 8080774 – it is not fixed at all in JDK 6 or older, it is fixed in JDK version 7u91 or higher as well as in JDK version 8u60 or higher
I already considered parsing the output of System.getProperty("java.version")
but I am looking for a better/more elegant solution, if possible.
For example Apache Commons has SystemUtils.isJavaVersionAtLeast()
method but it does not have enough granularity.