RFR: 8165276: Spec states to invoke the premain method in an agent class if it's public but implementation differs [v4]
David Holmes
dholmes at openjdk.java.net
Mon Dec 14 02:42:01 UTC 2020
On Sat, 12 Dec 2020 09:48:27 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Serguei Spitsyn has updated the pull request incrementally with one additional commit since the last revision:
>>
>> added 8165276 to @bug list of impacted tests
>
> src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java line 468:
>
>> 466: String msg = "method " + classname + "." + methodname + " must be declared public";
>> 467: throw new IllegalAccessException(msg);
>> 468: }
>
> I think the updated patch looks much better.
>
> If the agent class doesn't declare a premain then NoSuchMethodException will be thrown.
>
> The only thing that I'm wondering about now is the exception message when the agent class is not public. If I read the changes correctly it means that IllegalAccessException will be thrown saying that <class>.premain should be public. Is that correct? We might need to adjust to the exception message to make it clear, or put in an explicit then to ensure to test that the agent class is public.
I think an explicit check for a public premain method is better to disambiguate the cases and provide appropriate error messages.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1694
More information about the serviceability-dev
mailing list