Consider:
{code:java}
public interface A {
static A localSingleton() {
class B implements A {
private static final A INSTANCE = new B();
}
return B.INSTANCE;
}
}
{code}
The idea is to avoid exposing publicly class B (as classes declared in interfaces are `public` by default).
The class above compiles with Java 23 and less, but fails with Java 24-ea+30 with:
{noformat}
A.java:4: error: local class B cannot be instantiated from a static context
private static final A INSTANCE = new B();
^
1 error
{noformat}