Class ManifestUtils


  • public class ManifestUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<java.util.jar.Manifest> getManifest​(java.lang.Class<?> klass)  
      static java.util.Optional<java.lang.String> getVersion​(java.lang.Class<?> klass)
      Attempts to return the version of the jar/module for the given class.
      • Methods inherited from class java.lang.Object

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

      • getManifest

        public static java.util.Optional<java.util.jar.Manifest> getManifest​(java.lang.Class<?> klass)
      • getVersion

        public static java.util.Optional<java.lang.String> getVersion​(java.lang.Class<?> klass)

        Attempts to return the version of the jar/module for the given class.

        First, retrieves the Implementation-Version main attribute of the manifest; if that is missing, retrieves the JPMS module version (via reflection); if that is missing, returns an empty Optional.

        Parameters:
        klass - the class of the jar/module to retrieve the version
        Returns:
        the jar/module version, or an empty Optional