Created
September 3, 2025 11:38
-
-
Save corneil/dce44233716f7dc61769509dbb2e71f7 to your computer and use it in GitHub Desktop.
Utility for determining if JVM is running assertions enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AssertionUtils { | |
| public static boolean assertionsEnabled = false; | |
| static { | |
| // When this class is loaded the static block will execute and it the application is running with -ea the value of assertionsEnabled will be set to true. | |
| //noinspection AssertWithSideEffects | |
| assert (assertionsEnabled = true); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment