MethodCall.resolve() does not apply ElementMatcher to private methods in a DynamicType under construction
See original GitHub issueI will try to refine this bug report as I learn more. I thought it was worth filing anyway because ElementMatchers
are used so much and are so central to ByteBuddy.
I’m defining a DynamicType
. As part of doing this, I am defining two private
methods: produce
and inject
.
At one point in my program I do this:
MethodCall.invoke(ElementMatchers.named("inject"))...
…i.e. “please invoke the inject
method I defined elsewhere in this dynamic type”.
I get an exception indicating that (as it happens) two methods (!) meet this criteria (even though I’ve only defined one inject
method). When I debug into the resolution code, I see that my produce
method has somehow matched the ElementMatchers.named("inject")
matcher. I’m not sure how this can happen.
I’m attaching a NetBeans debugger screenshot showing MethodCall.java
at line 812. Here, candidates.size()
is 2
. You can see that the matcher
is name(equals(inject))
and one of the two candidates is produce
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Silly me pushed it to an unrelated branch, thanks for noticing!
Hi, @raphw; I’m, er, not sure that you did. See:
https://github.com/raphw/byte-buddy/blob/636c274333744ff3d44cb5ace1da926a400e02a2/byte-buddy-dep/src/main/java/net/bytebuddy/implementation/MethodCall.java#L810
As of 2021-02-01 line 810 still doesn’t feature the
matcher
.