Anonymity and observability of unnamed classes (JEP 445)
Attila Kelemen
attila.kelemen85 at gmail.com
Sat May 6 18:09:58 UTC 2023
Thanks Remi, that answers most of my questions.
> There is a name, but it is not well defined, like an anonymous class has a name.
I guess that is a little unfortunate, because I was thinking about
loading the class myself (say, in a test), but this way I would not
for the same reason I would not load `MyClass$5` even though
technically possible.
> Since Java 11, you do not need a class name to run a class, you can specify the file name, e.g. java foo.java, it will compile the class in memory and then execute it's method main.
This I know, but then I think your response implies that it is not
very reasonable to use unnamed classes in normal applications, because
there I'm not passing a .java file, but passing a bunch of jars and
specifying the main class for `java` (either through command line or.a
jar's manifest).
More information about the jdk-dev
mailing list