On 24/06/2020 07:24, [email protected] wrote:
:

One approach would be to continue using the setAccessible and add extra check for non-public premain method.
Something like should probably work:
        if (!(Modifier.isPublic(m.getModifiers())) {
            throw new IllegalAccessException("premain method is not public");
        }
The equivalent with the java launcher is:

$ java Foo.java
error: 'main' method is not declared 'public static'

$ javac Foo.java
$ java Foo
Error: Main method not found in class Foo, please define the main method as:
   public static void main(String[] args)

So have the exception message provide a helpful message will be useful in the event that someone tries to deploy that doesn't have a public premain method.

BTW: Have you checked the agentmain case too?

-Alan.





Reply via email to