GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `PowerMockWhiteboxGetMethodToJavaReflection` recipe by MBoegers · Pull Request #1026 · openrewrite/rewrite-testing-frameworks

Conversation

@MBoegers

@MBoegers MBoegers commented Jun 17, 2026 •
edited by Copilot AI
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

What

Adds a per-API recipe migrating Whitebox.getMethod(Class, String, Class...) to Class.getDeclaredMethod(String, Class...) + setAccessible(true), registered in the PowerMockWhiteboxToJavaReflection composite. The result is the reflective Method, so the declared result variable is reused as the local:

Method m = Whitebox.getMethod(MyService.class, "greet", String.class);
// →
Method m = MyService.class.getDeclaredMethod("greet", String.class);
m.setAccessible(true);

How

A hasArrayArg helper on WhiteboxToReflectionVisitor skips calls that pass an explicit Class[] varargs array (left for manual migration); the parameter Class literals otherwise pass straight through.

The resultLocalName / fieldVarName / methodVarName helper group was shared with #1025 (getField). Now that #1025 has merged, this PR drops the duplicated helper block and retains only the hasArrayArg helper unique to this recipe.

Notes

  • getDeclaredMethod does not walk the class hierarchy — documented in the description.
  • Second of three new-API recipes (getField → getMethod → invokeConstructor).

Tests

4 cases: param type (@DocumentExample), no params, primitive param (int.class), and an explicit-Class[] no-op guard. recipeCsvValidate passes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@MBoegers
Add PowerMockWhiteboxGetMethodToJavaReflection recipe
495b111
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.
@moderne-meeseeks moderne-meeseeks Bot added this to OpenRewrite Jun 17, 2026
@moderne-meeseeks moderne-meeseeks Bot assigned MBoegers Jun 17, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 17, 2026
@MBoegers

MBoegers commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started work on behalf of MBoegers June 18, 2026 14:09
View session
Merge main into MBoegers/whitebox-getmethod, resolving conflicts from #…
0cdd3db
…1025 (getField)

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts

Done — merged main (including #1025) into this branch and resolved all three conflicts:

  • WhiteboxToReflectionVisitor.java: dropped the duplicated helper group (already landed via Add PowerMockWhiteboxGetFieldToJavaReflection recipe #1025), kept the hasArrayArg helper unique to this PR.
  • powermockito.yml: combined both getField and getMethod in the description and recipe list.
  • recipes.csv: included entries for both getField and getMethod.

Merge commit: 0cdd3db

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot finished work on behalf of MBoegers June 18, 2026 14:14
@MBoegers
MBoegers marked this pull request as ready for review June 18, 2026 14:19
@MBoegers
MBoegers requested a review from timtebeek June 18, 2026 14:20
timtebeek
timtebeek approved these changes Jun 18, 2026
View reviewed changes
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Jun 18, 2026
@MBoegers
MBoegers merged commit 20880b9 into main Jun 18, 2026
1 check passed

Uh oh!

There was an error while loading. Please reload this page.

@MBoegers
MBoegers deleted the MBoegers/whitebox-getmethod branch June 18, 2026 15:32
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Jun 18, 2026
mergify Bot added a commit to robfrank/linklift that referenced this pull request Jul 17, 2026
@mergify
chore(deps): bump org.openrewrite.recipe:rewrite-testing-frameworks f…
f69dc0e
…rom 3.38.0 to 3.42.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-testing-frameworks](https://github.com/openrewrite/rewrite-testing-frameworks) from 3.38.0 to 3.42.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-testing-frameworks's releases](https://github.com/openrewrite/rewrite-testing-frameworks/releases).*

> 3.42.0
> ------
>
> What's Changed
> --------------
>
> * Support Kotlin sources in `AssertThrowsOnLastStatement` by [`@​vlsi`](https://github.com/vlsi) in [openrewrite/rewrite-testing-frameworks#1048](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1048)
> * Use range selector so JUnit5to6Migration gates on Java 17 or higher by [`@​steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-testing-frameworks#1049](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1049)
> * Simplify JUnit5to6Migration minimum Java version to '17' by [`@​steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-testing-frameworks#1050](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1050)
>
> New Contributors
> ----------------
>
> * [`@​vlsi`](https://github.com/vlsi) made their first contribution in [openrewrite/rewrite-testing-frameworks#1048](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1048)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.41.0...v3.42.0>
>
> 3.41.0
> ------
>
> What's Changed
> --------------
>
> * Keep `mockStatic` import in `CleanupMockitoImports` when type info is incomplete by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-testing-frameworks#1047](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1047)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.40.0...v3.41.0>
>
> v3.39.0
> -------
>
> What's Changed
> --------------
>
> * Add `PowerMockWhiteboxGetFieldToJavaReflection` recipe by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1025](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1025)
> * Add `PowerMockWhiteboxGetMethodToJavaReflection` recipe by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1026](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1026)
> * Add `PowerMockWhiteboxInvokeConstructorToJavaReflection` recipe by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1027](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1027)
> * Expand TestNG to AssertJ assertion coverage by [`@​juherr`](https://github.com/juherr) in [openrewrite/rewrite-testing-frameworks#1028](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1028)
> * Flag un-migratable PowerMock powermock-reflect usage with a comment by [`@​MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-testing-frameworks#1016](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1016)
>
> New Contributors
> ----------------
>
> * [`@​juherr`](https://github.com/juherr) made their first contribution in [openrewrite/rewrite-testing-frameworks#1028](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/pull/1028)
>
> **Full Changelog**: <openrewrite/rewrite-testing-frameworks@v3.38.0...v3.39.0>


Commits

* [`2b5d852`](openrewrite/rewrite-testing-frameworks@2b5d852) Keep Mockito dependency managed in Mockito1to3Migration multi-module builds
* [`e2dffca`](openrewrite/rewrite-testing-frameworks@e2dffca) OpenRewrite recipe best practices
* [`c709cec`](openrewrite/rewrite-testing-frameworks@c709cec) Simplify JUnit5to6Migration minimum Java version to '17' ([#1050](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1050))
* [`d3830c0`](openrewrite/rewrite-testing-frameworks@d3830c0) Use range selector so JUnit5to6Migration gates on Java 17 or higher ([#1049](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1049))
* [`b0b1f19`](openrewrite/rewrite-testing-frameworks@b0b1f19) Support Kotlin sources in `AssertThrowsOnLastStatement` ([#1048](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1048))
* [`2e6d485`](openrewrite/rewrite-testing-frameworks@2e6d485) OpenRewrite recipe best practices
* [`95ff73a`](openrewrite/rewrite-testing-frameworks@95ff73a) Keep `mockStatic` import in `CleanupMockitoImports` when type info is incompl...
* [`cba9383`](openrewrite/rewrite-testing-frameworks@cba9383) Recipe best practices
* [`9321cbc`](openrewrite/rewrite-testing-frameworks@9321cbc) Convert `assertThrows` with an `Executable` variable ([#1046](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1046))
* [`0eb4765`](openrewrite/rewrite-testing-frameworks@0eb4765) Skip JUnit 4 lifecycle annotation when Jupiter equivalent already present ([#1](https://redirect.github.com/openrewrite/rewrite-testing-frameworks/issues/1)...
* Additional commits viewable in [compare view](openrewrite/rewrite-testing-frameworks@v3.38.0...v3.42.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-testing-frameworks&package-manager=maven&previous-version=3.38.0&new-version=3.42.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@timtebeek timtebeek timtebeek approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@MBoegers MBoegers

Labels

None yet

Projects

OpenRewrite
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@MBoegers @timtebeek
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.