Try OpenEdge Now
skip to main content
Object-oriented Programming
Programming with Class-based Objects : Using static members of a class : Initializing and deleting static members
 

Initializing and deleting static members

ABL calls the static constructor of a class exactly once in a session to initialize its static data members and properties some time after you first reference the class type in the session. ABL calls this static constructor before any other action on a class type that has static members. So, if you instantiate the class as the first reference to its type, its static constructor executes before any of its instance constructors. If the static constructor raises ERROR, ABL fails to load its class type. This makes the class type unavailable for access during the remainder of the session. For more information on error handling for static constructors, see Raising errors within a static constructor.
If the class definition has super classes with their own static members, ABL initializes all of these static members by calling the static constructor for each class in the hierarchy from top to bottom. If the class is being instantiated with this reference, it then initiates the call to all the instance constructors of the class hierarchy. For more information on initialization during class instantiation, see Class hierarchies and inheritance.
Note: ABL provides no guarantee exactly when a static constructor will run, only that it will run before any instance constructor of the class type runs.
As noted previously, static members of a class, once initialized, are scoped to the class type and remain available for the duration of the ABL session. Thus, you cannot delete them during the session. The only way to remove static members from an application is by removing them from the source code and running the recompiled application in a new ABL session.