Package dev.brachtendorf
Class MiscUtil
- java.lang.Object
-
- dev.brachtendorf.MiscUtil
-
public class MiscUtil extends Object
Utility methods not belonging in any other specific category.- Author:
- Kilian
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMiscUtil.OSRetrieve the OS type this program is executed on.
-
Constructor Summary
Constructors Constructor Description MiscUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intconsistentHashCode(Enum e)Compute a consistent hashcode for enum valuesstatic voidrestartApp()Restart the java application by registering a shutdown hook at the very end of the life cycle.
-
-
-
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
-
-