What are the 'shadow$_klass_' and 'shadow$_monitor_' variables for in java.lang.Object?

They are indeed connected to GC. They seem to have been added in order to support Brooks pointers. I found some information on Brooks pointers here:

The idea is that each object on the heap has one additional reference field. This field either points to the object itself, or, as soon as the object gets copied to a new location, to that new location. This will enable us to evacuate objects concurrently with mutator threads

See especially these two commits:

libcore: a7c69f785f7d1b07b7da22cfb9150c584ee143f4

art: 9d04a20bde1b1855cefc64aebc1a44e253b1a13b


These are classes related to Shenandoah Garbage Collection in JDK.

There are 4 older GC in OpenJDK Serial,Parallel,Concurrent Mark Sweep, & G1. Yet the problem with these lie in the fact that they need to compact the entire old heap atleast once & if the heap is large, this will be very heavy. Shenandoah is designed with <10ms pauses for 100Gb+ heaps.

This is achieved by using Forwarding Pointers based on Brooks Pointers.The shadow_$klass & shadow$_monitor are these forwarding pointers.

The primary idea in Shenandoah GC, is that it allows application threads to interact with objects in heap while they're being moved around during compacting (moving referenced objects to a better location), removing the need to "stop-the-world"

Look at this other SO answer: Brooks Pointer in Object class