Class VersionFinder

java.lang.Object
nonapi.io.github.classgraph.utils.VersionFinder

public final class VersionFinder extends Object
Finds the version number of ClassGraph, and the version of the JDK.
  • Field Details

    • MAVEN_PACKAGE

      private static final String MAVEN_PACKAGE
      The Maven package for ClassGraph.
      See Also:
    • MAVEN_ARTIFACT

      private static final String MAVEN_ARTIFACT
      The Maven artifact for ClassGraph.
      See Also:
    • OS

      public static final VersionFinder.OperatingSystem OS
      The operating system type.
    • JAVA_VERSION

      public static final String JAVA_VERSION
      Java version string.
    • JAVA_MAJOR_VERSION

      public static final int JAVA_MAJOR_VERSION
      Java major version -- 7 for "1.7", 8 for "1.8.0_244", 9 for "9", 11 for "11-ea", etc.
    • JAVA_MINOR_VERSION

      public static final int JAVA_MINOR_VERSION
      Java minor version -- 0 for "11.0.4"
    • JAVA_SUB_VERSION

      public static final int JAVA_SUB_VERSION
      Java minor version -- 4 for "11.0.4"
    • JAVA_IS_EA_VERSION

      public static final boolean JAVA_IS_EA_VERSION
      Java is EA release -- true for "11-ea", etc.
  • Constructor Details

    • VersionFinder

      private VersionFinder()
      Constructor.
  • Method Details

    • getProperty

      public static String getProperty(String propName)
      Get a system property (returning null if a SecurityException was thrown).
      Parameters:
      propName - the property name
      Returns:
      the property value
    • getProperty

      public static String getProperty(String propName, String defaultVal)
      Get a system property (returning null if a SecurityException was thrown).
      Parameters:
      propName - the property name
      defaultVal - the default value for the property
      Returns:
      the property value, or the default if the property is not defined.
    • getVersion

      public static String getVersion()
      Get the version number of ClassGraph.
      Returns:
      the version number of ClassGraph.
    • getSecureDocumentBuilderFactory

      private static DocumentBuilderFactory getSecureDocumentBuilderFactory() throws ParserConfigurationException
      Helper method to provide a XXE secured DocumentBuilder Factory. reference - https://gist.github.com/AlainODea/1779a7c6a26a5c135280bc9b3b71868f reference - https://rules.sonarsource.com/java/tag/owasp/RSPEC-2755
      Returns:
      DocumentBuilderFactory
      Throws:
      ParserConfigurationException
    • getSecureXPathFactory

      private static XPathFactory getSecureXPathFactory() throws XPathFactoryConfigurationException
      Helper method to provide a XXE secured XPathFactory Factory. reference - https://rules.sonarsource.com/java/tag/owasp/RSPEC-2755
      Returns:
      XPathFactory
      Throws:
      XPathFactoryConfigurationException