In Java, there are special objects called Garbage Collection Roots (GC roots). They serve as a root objects for Garbage Collection marking mechanism (see picture).
This article describes four types of GC roots:
- local variables
- active threads
- static variables
- JNI references
It is also mentioned, that:
Classes themselves can be garbage-collected.
GC roots aren't collected thus classes themselves are not GC roots.
So what are GC roots for the classes?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…