'What does "class loading deadlock" mean here?

I have this classes:

public class User {

    public static final NonRegisteredUser NON_REG_USER = new NonRegisteredUser();

    //...

    public static class NonRegisteredUser extends User {
        //...
    }

}

And code inspector is detecting this warning:

Referencing subclass NonRegisteredUser from superclass User initializer might lead to class loading deadlock

What does it mean exactly?



Solution 1:[1]

Class loader begins loading User.

Static members are init first, in order of appearance. So the class loader sees the NonRegisteredUser class, and tries loading the User class for its initialization.

Next, class loader begins loading User.

Static members are init first, in order of appearance. So the class loader sees the NonRegisteredUser class, and tries loading the User class for its initialization.

Next, class loader begins loading User.

Static members are init first, in order of appearance. So the class loader sees the NonRegisteredUser class, and tries loading the User class for its initialization...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1