15 RFR(XS): 8165276: Spec states that invoke the premain method in an agent class if it's public but implementation differs

David Holmes david.holmes at oracle.com
Wed Jun 24 09:26:45 UTC 2020


On 24/06/2020 5:33 pm, Alan Bateman wrote:
> On 24/06/2020 07:55, serguei.spitsyn at oracle.com wrote:
>>
>> Thank you for the example.
>> Yes, I'm working on a helpful message and was thinking to use the 
>> Reflection method:
>>  IllegalAccessException newIllegalAccessException(Class<?> currentClass,
>>                                                   Class<?> memberClass,
>>                                                   Class<?> targetClass,
>>                                                   int modifiers);
> m.canAccess(null) will tell you if the premain method is accessible. If 
> it returns false then you can thrwo IAE with a useful message.

If we call setAccessible(true) then canAccess will return true.

If we don't call setAccessible(true) then canAccess will return false 
due to the problem Serguei reported.

David

> 
> -Alan.


More information about the serviceability-dev mailing list