Class Assertions


  • public final class Assertions
    extends java.lang.Object
    If you want to know if assertions are enabled (java option "-ea"), you can use this helper class. At runtime you can use the 'jconsole' and look at the java.lang.Runtime MXBean (java.lang.management.RuntimeMXBean). Here you can look at the attribute "InputArguments" if "-ea" is set.
    Since:
    31.01.2009
    Version:
    $Revision: 1.14 $
    Author:
    oliver
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean ENABLED
      The Constant enabled.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean areEnabled()
      If you want to know if the JavaVM was started with "Assertion enabled" (option -ea for SunVM) you can use this method.
      • Methods inherited from class java.lang.Object

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

      • ENABLED

        public static final boolean ENABLED
        The Constant enabled.
    • Method Detail

      • areEnabled

        public static boolean areEnabled()
        If you want to know if the JavaVM was started with "Assertion enabled" (option -ea for SunVM) you can use this method.

        Or you can ask the RuntimeMXBean for the input arguements and look for the argument "-ea".

        Returns:
        true, if are enabled
        See Also:
        RuntimeMXBean.getInputArguments()