Let's say we have the following classes
public class Parent {
public Child child;
public Parent(Child child) {
this.child = child;
}
}
public class Child {
public String someField;
}
And we have the following code in our main
Parent parent = new Parent(new Child());
Child child = parent.child;
parent = null;
// then do other stuff
Will the parent be elligible for garbage collection after setting it to null even if one of its internal field / child is directly referenced by the main root thread ?