MemberSubstitution.failIfNoMatch seems to be ignored #1780
-
Hello, I searched the issues and questions here and in the Google Group, but I couldn't find any results. However, if there is a missing accessor, the build fails with the message below:
Looking at the I downloaded Byte Buddy's source code and checked that this attribute is being set but it's only checked inside the I'm wondering if the For instance, the matcher that looks for a setter related to a given field is this simple class here. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
The error you are getting is different. It says that you try to replace a method with another, by using a matcher, but the matcher does not yield exactly one replacement. If you want to only replace a method or field if a method exists, you should already exclude that element in the method or field matcher that identifies the element that is to be substituted. |
Beta Was this translation helpful? Give feedback.
-
I wonder: could you not expand your matcher to check if a field has a getter/setter and can be substituted? You have access to the declaring type from the matcher, so this would certainly work. |
Beta Was this translation helpful? Give feedback.
failIfNoMatch
is meant to fail an application if a method does not contain any substitution that is specified. That means, you mean to replace a callback method, but the method has changed and does no longer contain an invocation to a callback.The error you are getting is different. It says that you try to replace a method with another, by using a matcher, but the matcher does not yield exactly one replacement. If you want to only replace a method or field if a method exists, you should already exclude that element in the method or field matcher that identifies the element that is to be substituted.