There are various whitepapers and the like on this.
As far as which objects may be collected, it's just any object that isn't referred to - directly or indirectly - by one of the root set of threads in the JVM.
Collecting algorithms vary from jvm to jvm. You'd do better to search the web for a whitepaper on the subject.
~Cheers
The basis is "mark and sweep". Follow all the live references from the active threads and their stacks marking the live objects, then clear all the unmarked space.
But it gets more complicated, with "generational" space management todeal specially with emphemeral objects and very long lived objects (most java objectsare one or the other.)