I'm reading about G1 GC, and there are processes called "Reference Processing" and "Reference Enq" in both Young collection and Concurrent Marking cycle steps. What exactly are those processes? What will happen there?
Reference processing is a phase dedicated for handling special references objects (e.g. weak references, finalizers, JNI references).
Special references have two important aspects
During normal GC phase, reference object are queue for post processing.
"Ref Proc" phase starts after main GC phase, so it is known which objects have survived and which are not, so reference semantic could be applied.
"Ref Enq" is done afterward to place reference into reference queues (reference queue is a Java object on heap, typically used to implement patterns enabled by special references).