audit4j / audit4j-core

An open source auditing framework.
http://audit4j.org
Apache License 2.0
126 stars 76 forks source link

isJDK_N_OrHigher() method having issue with Java 10 #82

Closed gaurav072 closed 5 years ago

gaurav072 commented 6 years ago

I have found one of the issue with method isJDK_N_OrHigher() in EnvUtil class in audit4j-core 2.5.0

private static boolean isJDK_N_OrHigher(int n) {
        List<String> versionList = new ArrayList<String>();
        // this code should work at least until JDK 10 (assuming n parameter is
        // always 6 or more)
        for (int i = 0; i < 5; i++) {
            versionList.add("1." + (n + i));
        }

        String javaVersion = System.getProperty("java.version");
        if (javaVersion == null) {
            return false;
        }
        for (String v : versionList) {
            if (javaVersion.startsWith(v))
                return true;
        }
        return false;
    }

As the list containing 1.x and matching with system java version. It works fine upto Java 1.8 but from Java 10 versioning has been changed(10.x) due to which validation is failing. Could you please look into this.

gaurav072 commented 6 years ago

Have you get any chance to look into this?

PritishSehzpaul commented 5 years ago

Hi. I would like to help. May I look into it?

gaurav072 commented 5 years ago

Could you please review the code and merge it?

bcaure commented 5 years ago

this does not work with jdk 9 :

Audit4j:INFO Initializing Audit4j... Audit4j:ERROR Your Java version (9.0.4) is not supported for Audit4j. see http://audit4j.org/errors#javaVersion for further details. Audit4j:ERROR Failed to initialize Audit4j: Java version is not supported.

gaurav072 commented 5 years ago

Java 9 was not a stable release, Oracle already removed it from the website. https://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html