Question: [This answer](https://stackoverflow.com/a/1654928/160206) to another questions suggests, as a workaround for finding anonymous classes via reflection, to simply try all names, starting with `...$1` and counting up until no more can be found. Is this guaranteed to find all inner classes, or could there be cases where they start at 0 or some numbers are left out (for whatever reason)?

Answer: 
The [JLS 13.1](http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.1) specifies:

> 
> The class or interface must be named by its binary name, which must meet the following constraints: 
> 
> 
> * The binary name of a top level type (§7.6) is its canonical name (§6.7).
> * [...]
> * The binary name of an anonymous class (§15.9.5) consists of the binary name of its immediately enclosing type, followed by $, followed by a non-empty sequence of digits.
> 
> 
> 

So in theory, it does not have to start at 1, but it has to be something like `EnclosingClass$N` where N is a number.
In this link to a java.sun.com [tutorial](http://java.sun.com/developer/Books/certification/certbook.pdf), it explains anonymous classes from page 243 with example outputs which follow the naming convention described.e.g. \*$1.class, \*$2.class etc. On the top of page 246 it says:

> 
> The names of the anonymous classes at runtime are also shown in the program output. They are also the names used to designate their respective class files. Anonymous classes are not so anonymous after all.
> 
> 
> 

Considering that this tutorial is on the Oracle website, It's almost certain that this is a convention that will not vary. Hope this helps :)