Fix NPE when ModifyExpressionValue uses "CONSTANT" as a target #6
+21
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Issue
A
NullPointerException
is triggered when Adapter tries to patch aModifyExpressionValue
that uses "CONSTANT" as a target as it fails to find the value fortarget()
in the at annotation within the call toMethodContext.getInjectionPointMethodQualifier()
.The Proposal
As a
ModifyExpressionValue
's return value for the mixin method must return the same as its target, rather than using the target's descriptor to get the expected return type, it should be expected to be equivalent to the return type for the mixin method. Therefore, the change is to use the mixin method's descriptor in order to ensure it is never null.Possible Side Effects
If it were somehow the case that the return type did not match the target for the
ModifyExpressionValue
it might be possible for this to cause incorrect behaviour, although it seems unlikely.Alternatives
I had considered instead finding some way to account for specifically the types of the target method, however after careful consideration I figured this solution out as it was far simpler and cleaner than checking what type the target returned.