I have a code snippet similar to the following in my project:
public static void main(final String[] args) {
System.out.println("Hello world");
final TypeReference<String> tr1 = new TypeReference<>() {};
final Runnable r = () -> {
System.out.println("Running");
final TypeReference<String> tr = new TypeReference<>() {};
System.out.println(tr);
};
new Thread(r).start();
}
This is present in eclipse that runs with Java 11. Now, when eclipse compiles this class, it generates the following files:
TestAnon.class
TestAnon$2.class
TestAnon$3.class
As it has got two anonymous inner classes, it makes sense to have two different class files with $
. However, the postfixes are $2
and $3
instead of $1
and $2
. Any specific reason for generating class files in this order (and skipping $1
)?
P.S. When I compile the class on command line, it generates classes files in correct order.
$1
. – DampproofTestAnon.class
does not have$1
is that it is class which you actually runing(?) so to make it simple. But if you try this code run from other class,not main
I think it will generate$1
as well. Not sure just guessing. – Broom