As know, local classes are inner classes. JLS 14.3
All local classes are inner classes (§8.1.3).
What an inner class is is
An inner class C is a direct inner class of a class or interface O if O is the immediately enclosing type declaration of C and the declaration of C does not occur in a static context.
A class C is an inner class of class or interface O if it is either a direct inner class of O or an inner class of an inner class of O.
Which means the declaration of an inner class shouldn't be occured in a non-static context. But consider the following program:
public static void main (String[] args) throws java.lang.Exception
{
class Foo{ } //occured in the static-context
}
Despite being declared in the static context, the declartion of the Foo
class is fine. Although it's impossible for an inner class to be declared in a static-context.