Add PowerMockWhiteboxGetMethodToJavaReflection recipe#1026
Merged
Conversation
Whitebox.getMethod(Class, "m", paramTypes...) returns a reflective Method;
migrate it to Class.getDeclaredMethod("m", paramTypes...) + setAccessible(true),
reusing the result variable as the local. Calls passing an explicit Class[]
varargs array are left unchanged for manual migration. Registered in the
PowerMockWhiteboxToJavaReflection composite.
Adds hasArrayArg and the resultLocalName helper group to
WhiteboxToReflectionVisitor. The resultLocalName group is also introduced by
PR #1025 (getField); whichever merges first, the other rebases onto main and
drops the duplicate.
Collaborator
Author
|
@copilot resolve the merge conflicts |
Contributor
Done — merged
Merge commit: |
timtebeek
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds a per-API recipe migrating
Whitebox.getMethod(Class, String, Class...)toClass.getDeclaredMethod(String, Class...)+setAccessible(true), registered in thePowerMockWhiteboxToJavaReflectioncomposite. The result is the reflectiveMethod, so the declared result variable is reused as the local:How
A
hasArrayArghelper onWhiteboxToReflectionVisitorskips calls that pass an explicitClass[]varargs array (left for manual migration); the parameterClassliterals otherwise pass straight through.The
resultLocalName/fieldVarName/methodVarNamehelper group was shared with #1025 (getField). Now that #1025 has merged, this PR drops the duplicated helper block and retains only thehasArrayArghelper unique to this recipe.Notes
getDeclaredMethoddoes not walk the class hierarchy — documented in the description.getField→getMethod→invokeConstructor).Tests
4 cases: param type (
@DocumentExample), no params, primitive param (int.class), and an explicit-Class[]no-op guard.recipeCsvValidatepasses.