Skip to content

False alarm from ClassInitializationDeadlock for inner enum implementing outer interface with default method #4378

@PhilippWendler

Description

@PhilippWendler

Error Prone 2.27.0 produces a ClassInitializationDeadlock warning for the following code:

public interface TestInterface {

  default Object foo() {
    return null;
  }

  public enum TestEnum implements TestInterface {
    INSTANCE;
  }
}

The exact message is

TestInterface.java:8: warning: [ClassInitializationDeadlock] Possible class initialization deadlock: TestEnum is a subclass of the containing class TestInterface
    INSTANCE;
    ^
    (see https://errorprone.info/bugpattern/ClassInitializationDeadlock)

Interestingly, it does not happen with a class instead of an enum, nor if I remove the default method.

My assumption is that this is a false alarm, because I don't see how initializing TestInterface would require initializing TestEnum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions