Proposal for JSE API representing java.specification.version

Alex Buckley alex.buckley at oracle.com
Wed Nov 2 23:34:48 UTC 2016


Andy,

Java SE 9 has java.lang.Runtime.Version for manipulating the version 
strings returned as system properties. It was introduced by JEP 223 -- 
see http://openjdk.java.net/jeps/223. Best to follow up on verona-dev.

Alex

On 11/2/2016 4:22 PM, Andrew Guibert wrote:
> Hello all,
>
> Many Java frameworks and applications require knowledge of the Java version
> they are running on.  Currently the only way to check the Java version is
> by doing:
>
>      String javaVersion = System.getProperty("java.specification.version");
>
> This of course returns a String, which is very awkward to work with when it
> comes to comparisons.  For example, if I want to check if my code is
> running at least on Java 8, I have to do the following:
>
>      if (Pattern.matches("1\\.[0-7]", javaVersion))
>          // at java 7 or earlier
>      else
>          // at java 8 or later
>
> It would be nice if the JDK had a built-in enum, similar to what is
> provided by org.apache.commons [1], so that Java version comparisons are
> less awkward.
>
> I'm not familiar with the process is for getting new APIs into the JDK, but
> if it is a simple matter of making a pull request I can certainly do so.
>
> Regards, Andy
>
> [1]
> https://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/commons/lang3/JavaVersion.html
>


More information about the jigsaw-dev mailing list