Class Util
- java.lang.Object
-
- ej.bon.Util
-
public class Util extends Object
This class offers basic services for B-ON implementation.
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longcurrentTimeMillis()Gets the application time in milliseconds.static longgcReclaimDeadObjects()Triggers a garbage collection to reclaim all dead objects in the managed heap.static booleanisInInitialization()Indicates whether the current code is part of the initialization phase.static booleanisInMission()Indicates whether the system has entered the mission phase, i.e.static <T> T[]newArray(Class<T[]> type, int length)Allocates a new array of object references from the given array type and length.static longplatformTimeMillis()Gets an arbitrary time in milliseconds.static longplatformTimeNanos()Gets an arbitrary time in nanoseconds.static voidsetCurrentTimeMillis(long t)Sets the application time.static voidsetCurrentTimeMillis(Date d)Sets the application time.
-
-
-
Method Detail
-
isInMission
public static boolean isInMission()
Indicates whether the system has entered the mission phase, i.e. it is initialized.- Returns:
trueif 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 whereisInInitialization()istrueandisInMission()istrue.- Returns:
trueif 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- iftis 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 asUtil.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 allocatelength- the length of the array to allocate- Returns:
- the new allocated array
- Throws:
NullPointerException- if the type isnullOutOfMemoryError- 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.
-
-