What does the 4th number mean in Java 9's version string scheme?

后端 未结 2 1482
星月不相逢
星月不相逢 2021-02-04 02:13

According to this blog on Java 9\'s new version string scheme, the version is supposed to be like MAJOR.MINOR.SECURITY, i.e., there are supposed to be 3 numbers and

2条回答
  •  失恋的感觉
    2021-02-04 03:07

    i.e., there are supposed to be 3 numbers and 2 periods in between.

    Not necessarily and you can validate the versions using the JDK itself as detailed below.

    In addition to the JEP which holds true as linked by @Stephen in the other answer, there has been an API addition to the JDK as well for the Runtime.Version which can be used to validate a given version string. This can be done using a sample stub as :

    [I wonder using JShell could be interesting here, no IDEs!]

    Runtime.Version version = Runtime.Version.parse("9");
    version = Runtime.Version.parse("9.0.1");
    version = Runtime.Version.parse("9.0.0.15");
    version = Runtime.Version.parse("9.0.0.15+181");
    

    The code makes use of the Version.parse that

    Parses the given string as a valid version string containing a version number followed by pre-release and build information.

    and can be further used(primarily) to get information like major, minor, pre-release and security number of the (runtime) version.

提交回复
热议问题