On 6/25/20 11:07, Alan Bateman wrote:
On 25/06/2020 17:17, serguei.spit...@oracle.com wrote:
New wevrev version is:
http://cr.openjdk.java.net/~sspitsyn/webrevs/2020/instr-setAccessible.2/
One inconsistency is that it uses getDeclaredMethod to find the 2-arg
premain and getMethod to find the 1-arg premain. The latter will fail
if the method is not public so you won't get the nice exception
message. I wonder if we could fix this at the same time.
The implementation has this order of lookup:
// The agent class must have a premain or agentmain method that
// has 1 or 2 arguments. We check in the following order:
//
// 1) declared with a signature of (String, Instrumentation)
// 2) declared with a signature of (String)
// 3) inherited with a signature of (String, Instrumentation)
// 4) inherited with a signature of (String)
The declared methods are gotten with the getDeclaredMethod and inherited
with the getMethod.
This works for both 1-arg and 2-arg premain methods, so I'm not sure
what is inconsistent.
Or you have a concern there can be a non-nice NoSuchMethodException?
In fact, I don't understand why there is a need to use the
getDeclaredMethod.
As I see, the getMethod should return a declared method first, and only
if it is absent then it checks for a inherited one.
Thanks,
Serguei
-Alan.