Class VersionFinder


  • public final class VersionFinder
    extends java.lang.Object
    Finds the version number of ClassGraph, and the version of the JDK.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private VersionFinder()
      Constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getProperty​(java.lang.String propName)
      Get a system property (returning null if a SecurityException was thrown).
      static java.lang.String getProperty​(java.lang.String propName, java.lang.String defaultVal)
      Get a system property (returning null if a SecurityException was thrown).
      private static javax.xml.parsers.DocumentBuilderFactory getSecureDocumentBuilderFactory()
      Helper method to provide a XXE secured DocumentBuilder Factory.
      private static javax.xml.xpath.XPathFactory getSecureXPathFactory()
      Helper method to provide a XXE secured XPathFactory Factory.
      static java.lang.String getVersion()
      Get the version number of ClassGraph.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAVEN_PACKAGE

        private static final java.lang.String MAVEN_PACKAGE
        The Maven package for ClassGraph.
        See Also:
        Constant Field Values
      • MAVEN_ARTIFACT

        private static final java.lang.String MAVEN_ARTIFACT
        The Maven artifact for ClassGraph.
        See Also:
        Constant Field Values
      • JAVA_VERSION

        public static final java.lang.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 Detail

      • VersionFinder

        private VersionFinder()
        Constructor.
    • Method Detail

      • getProperty

        public static java.lang.String getProperty​(java.lang.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 java.lang.String getProperty​(java.lang.String propName,
                                                   java.lang.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 java.lang.String getVersion()
        Get the version number of ClassGraph.
        Returns:
        the version number of ClassGraph.
      • getSecureDocumentBuilderFactory

        private static javax.xml.parsers.DocumentBuilderFactory getSecureDocumentBuilderFactory()
                                                                                         throws javax.xml.parsers.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:
        javax.xml.parsers.ParserConfigurationException
      • getSecureXPathFactory

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