Class MiscUtil


  • public class MiscUtil
    extends Object
    Utility methods not belonging in any other specific category.
    Author:
    Kilian
    • Constructor Detail

      • MiscUtil

        public MiscUtil()
    • Method Detail

      • restartApp

        public static void restartApp()

        Restart the java application by registering a shutdown hook at the very end of the life cycle. Tested under JRE 8 Windows 10.

        This method should be used with caution and testing is needed to be done before relying on it's functionality!. JVM specific security managers, and overall behaviour might impact this method

        This method "injects" it's own runnable at the very end of the lifetime of the program after all shutdown hooks have been executed by accessing non private methods via reflection. This might break if the implementation of java will change therefore again be cautious! Guard yourself against constant restarting due to uninitialized conditions.

        Since:
        1.0.0 com.github.kilianB
      • consistentHashCode

        public static int consistentHashCode​(Enum e)
        Compute a consistent hashcode for enum values
        Parameters:
        e - the enum to compute the hashcode for
        Returns:
        the hashcode