Consider this piece of code:
public class TopLevelClass {
Cloneable c = new Cloneable() {
private int privateField;
private void privateMethod
My final answer consists of two thesis:
There is not strong declaration of restrictions for anonymous class members modifiers in the JLS. I.e. there isn't such part of JLS.
But according to JVM specs anonymous classes aren't members of class:
JVM 7 spec: 4.7.6 The InnerClasses Attribute states:
If C is not a member of a class or an interface (that is, if C is a top-level class or interface (JLS §7.6) or a local class (JLS §14.3) or an anonymous class (JLS §15.9.5))...
so, according to
8.5 Member Type Declarations
A member class is a class whose declaration is directly enclosed in another class or interface declaration.
anonymous classes are not member classes.
so, according to 8.1.1. Class Modifiers:
The access modifiers protected and private (§6.6) pertain only to member classes within a directly enclosing class
this classes aren't member classes, so they can not have mentioned modifiers.