You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2018/03/08 15:48:00 UTC

[jira] [Comment Edited] (LANG-1384) NPE from SystemUtils.isJavaVersionAtLeast under Java 11 EA

    [ https://issues.apache.org/jira/browse/LANG-1384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16391420#comment-16391420 ] 

Gary Gregory edited comment on LANG-1384 at 3/8/18 3:47 PM:
------------------------------------------------------------

Yes, this will work for now, at least until Java versions go past {{"99"}}. This {{SystemUtils}} method:

{code:java}
    static boolean isJavaVersionMatch(final String version, final String versionPrefix) {
        if (version == null) {
            return false;
        }
        return version.startsWith(versionPrefix);
    }
{code}

will not do the right thing when comparing {{"100"}} with {{"10"}}.

Gary


was (Author: garydgregory):
Yes, this will work for now, at least until Java versions go past 99. This {{SystemUtils}} method:

{code:java}
    static boolean isJavaVersionMatch(final String version, final String versionPrefix) {
        if (version == null) {
            return false;
        }
        return version.startsWith(versionPrefix);
    }
{code}

will not do the right thing when comparing {{"100"{{ with {{"10"}}.

Gary

> NPE from SystemUtils.isJavaVersionAtLeast under Java 11 EA
> ----------------------------------------------------------
>
>                 Key: LANG-1384
>                 URL: https://issues.apache.org/jira/browse/LANG-1384
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 3.7
>         Environment: Java 11 EA
>            Reporter: Ian Young
>            Priority: Major
>
> Calling, for example, {{SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7);}} under the Java 11 early access release causes a NPE:
> {code:java}
> java.lang.NullPointerException
> at org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast(SystemUtils.java:1654)
> {code}
> This is:
> {code}
> return JAVA_SPECIFICATION_VERSION_AS_ENUM.atLeast(requiredVersion);
> {code}
> ... which implies that {{JAVA_SPECIFICATION_VERSION_AS_ENUM}} hasn't been resolved properly, although it looks like the code in JavaVersion intends to return {{JAVA_RECENT}} in the case of unknown versions.
> The {{java.specification.version}} system property is "11" in this environment.
> {code}
> $ java -version
> java version "11-ea" 2018-09-18
> Java(TM) SE Runtime Environment 18.9 (build 11-ea+2)
> Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11-ea+2, mixed mode){code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)