class loading mechanism in java

        The life cycle of a class includes: loading, validating, preparing, parsing, initializing, unloading, where validation, preparation and resolution are collectively referred to as connections. The order of these 5 stages is certain, but the actual implementation is not step-by-step, and is usually cross-hybrid.

        The more important loading process triggers are as follows (for hotspot):

        1. Start loading when the static part of the class is referenced for the first time

        2. When the subclass is initialized -- the constructor (it can be understood that the constructor contains static variables and static blocks for constructing Class objects, (the construction method is to instantiate the object))

        3. When using reflection

Their specific content is as follows:


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325732483&siteId=291194637