On Wed, 17 Mar 2021 08:55:54 GMT, Alan Bateman <al...@openjdk.org> wrote:

> > > Using an anonymous class for the main class looks strange and hard to 
> > > believe anyone is relying on this. I wonder if we should do more checking 
> > > LauncherHelper.validateMainClass to reject cases like this.
> > 
> > 
> > I raised that same question, and people tends to agree launcher could 
> > reject anonymous/local classes. But pointed out that should require a CSR 
> > review. Therefore I chose to fix crash first, and we can file another 
> > ticket to address main class requirements.
> 
> The requirement for a CSR and release note should not be a concern here. I 
> don't object to the fix but I think it would be very useful to document the 
> main class and whether local or anonymous classes can be used, its 
> accessibility, and the accessibility of the main method. We had to do 
> something similar recently with the premain method (java.lang.instrument).

Absolutely we need to clarify that, however, the discussion of what should or 
should not be allowed may take some time. For example, if we limit such usage 
in launcher, should it be possible for custom launcher to start such a main 
method? Thus the recommendation to have a separate ticket for that.

The current java document mostly only say to load the specify the class name, 
however there is a sentence `By default, the first argument that isn't an 
option of the java command is the fully qualified name of the class to be 
called. If -jar is specified, then its argument is the name of the JAR file 
containing class and resource files for the application. The startup class must 
be indicated by the Main-Class manifest header in its manifest file.`. Not that 
it says `fully qualified name of the class`.

Filed [JDK-8263735](https://bugs.openjdk.java.net/browse/JDK-8263735) for the 
follow up, in the mean time, we should get this crash resolved.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2999

Reply via email to