Class JarUtils


  • public final class JarUtils
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  JarUtils.NativeMethodFound  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int ELFMAG0  
      private static int ELFMAG1  
      private static int ELFMAG2  
      private static int ELFMAG3  
      private static org.slf4j.Logger LOGGER  
      private static java.lang.String MANIFEST_PATH  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JarUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean containsNativeCode​(java.nio.file.Path jarPath)
      Heuristically try to determine whether given JAR (or WAR, EAR, ...) file contains native (architecture-dependent) code.
      (package private) static java.nio.file.Path getBackupNameOf​(java.nio.file.Path p)  
      static void injectManifest​(java.nio.file.Path targetJar, Artifact artifact)
      Inject artifact coordinates into manifest of specified JAR (or WAR, EAR, ...) file.
      private static void putAttribute​(java.util.jar.Manifest manifest, java.lang.String key, java.lang.String value, java.lang.String defaultValue)  
      private static void updateManifest​(Artifact artifact, java.util.jar.Manifest mf)  
      static boolean usesNativeCode​(java.nio.file.Path jarPath)
      Heuristically try to determine whether given JAR (or WAR, EAR, ...) file is using native (architecture-dependent) code.
      • Methods inherited from class java.lang.Object

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

      • JarUtils

        private JarUtils()
    • Method Detail

      • containsNativeCode

        public static boolean containsNativeCode​(java.nio.file.Path jarPath)
        Heuristically try to determine whether given JAR (or WAR, EAR, ...) file contains native (architecture-dependent) code.

        Currently this code only checks only for ELF binaries, but that behavior can change in future.

        Returns:
        true if native code was found inside given JAR
      • usesNativeCode

        public static boolean usesNativeCode​(java.nio.file.Path jarPath)
        Heuristically try to determine whether given JAR (or WAR, EAR, ...) file is using native (architecture-dependent) code.

        Currently this code only checks if any class file declares Java native methods, but that behavior can change in future.

        Returns:
        true given JAR as found inside to use native code
      • putAttribute

        private static void putAttribute​(java.util.jar.Manifest manifest,
                                         java.lang.String key,
                                         java.lang.String value,
                                         java.lang.String defaultValue)
      • updateManifest

        private static void updateManifest​(Artifact artifact,
                                           java.util.jar.Manifest mf)
      • getBackupNameOf

        static java.nio.file.Path getBackupNameOf​(java.nio.file.Path p)
      • injectManifest

        public static void injectManifest​(java.nio.file.Path targetJar,
                                          Artifact artifact)
        Inject artifact coordinates into manifest of specified JAR (or WAR, EAR, ...) file. The file is modified in-place.
        Parameters:
        targetJar -
        artifact -