Package ej.bon

Class Util


  • public class Util
    extends Object
    This class offers basic services for B-ON implementation.
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • isInMission

        public static boolean isInMission()
        Indicates whether the system has entered the mission phase, i.e. it is initialized.
        Returns:
        true if the initialization is done
        See Also:
        Immortals
      • isInInitialization

        public static boolean isInInitialization()
        Indicates whether the current code is part of the initialization phase.

        When Class.forName(String) triggers classes to be loaded at runtime dynamically, class initializations are done in a context where isInInitialization() is true and isInMission() is true.

        Returns:
        true if the initialization is ongoing
        See Also:
        Immortals
      • currentTimeMillis

        public static long currentTimeMillis()
        Gets the application time in milliseconds.

        The result of this method is the same as the System.currentTimeMillis() method one.

        Returns:
        the application time in milliseconds
      • platformTimeMillis

        public static long platformTimeMillis()
        Gets an arbitrary time in milliseconds.

        Only elapsed time between two calls is meaningful.

        Returns:
        the platform time in milliseconds
      • platformTimeNanos

        public static long platformTimeNanos()
        Gets an arbitrary time in nanoseconds.

        Only elapsed time between two calls is meaningful.

        Returns:
        the platform time in nanoseconds
      • setCurrentTimeMillis

        public static void setCurrentTimeMillis​(long t)
        Sets the application time.

        This time does not change the platform time.

        Parameters:
        t - the application time to set in milliseconds
        Throws:
        IllegalArgumentException - if t is negative
      • setCurrentTimeMillis

        public static void setCurrentTimeMillis​(Date d)
        Sets the application time.

        This time does not change the platform time. The Util.setCurrentTimeMillis(d) method has the same effect as Util.setCurrentTimeMillis(d.getTime()).

        Parameters:
        d - the application time to set
      • newArray

        public static <T> T[] newArray​(Class<T[]> type,
                                       int length)
        Allocates a new array of object references from the given array type and length.
        Type Parameters:
        T - the type of the array elements
        Parameters:
        type - the type of the array to allocate
        length - the length of the array to allocate
        Returns:
        the new allocated array
        Throws:
        NullPointerException - if the type is null
        OutOfMemoryError - if the array could not be allocated
      • gcReclaimDeadObjects

        public static long gcReclaimDeadObjects()
        Triggers a garbage collection to reclaim all dead objects in the managed heap.

        This method performs only the work necessary to identify live objects and reclaim unused memory, without performing full heap compaction or defragmentation as System.gc() may do.

        As part of this process, weak references to dead objects are cleared and native resources hooks are called for all reclaimed objects.

        Returns:
        the total amount of memory currently available for future allocated objects, measured in bytes.