Hoist PowerMock Whitebox calls used in expression position#1015
Closed
MBoegers wants to merge 3 commits into
Closed
Hoist PowerMock Whitebox calls used in expression position#1015MBoegers wants to merge 3 commits into
MBoegers wants to merge 3 commits into
Conversation
5fc96ec to
4ad8941
Compare
6296e0a to
bc38b91
Compare
Adds migration of getField, getMethod, invokeConstructor, static invokeMethod(Class,..), the where-Class get/setInternalState overloads, and non-literal field/method names, alongside the existing setInternalState/getInternalState/invokeMethod support. Primitive results are cast through their wrapper type, and the explicit Class[]/varargs-array overloads of invokeMethod/invokeConstructor are deliberately left untouched (no faithful mechanical translation).
4ad8941 to
dfdc2d0
Compare
Adds a second pass to PowerMockWhiteboxToJavaReflection that handles Whitebox result calls nested inside an enclosing statement (return, method arguments, if-conditions, ...): the reflection preamble and a temp local are hoisted before the statement and the call is replaced by a reference to the temp. Calls in short-circuit (&&/||) or ternary positions are left untouched to preserve evaluation semantics.
bc38b91 to
a2f486c
Compare
Member
|
Given the work we've done on this front in the past week, is there anything left to do here? |
Member
|
@copilot resolve the merge conflicts in this pull request |
Contributor
Collaborator
Author
|
I close this PR without merging. The PRs from last week should deliver the main value, the proposed changes here are huge in terms of code changes with questionable value. |
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.
Ports the expression-position hoisting logic onto the current split Whitebox reflection recipes.
Adds a second pass in the shared
WhiteboxToReflectionVisitorthat handlesWhiteboxresult calls nested inside an enclosing statement (return, method arguments,ifconditions, …), which the statement/variable-declaration pass cannot rewrite in place because reflection needs a multi-statement preamble.For each such call, the reflection preamble and a temp local are hoisted before the enclosing statement, and the call is replaced by a reference to the temp. Calls in short-circuit (
&&/||) right operands or ternary branches are left untouched, since hoisting would change whether the reflective call executes.Keeps the split per-API recipe structure now on
main, updates the aggregate recipe metadata to describe the hoisting behavior, and retains 6 unit tests covering: areturn, a method-call argument, anifcondition, afor-loop body (hoisted into the loop body, not the method block), two nested calls in one statement (preserved order), and a short-circuit-guarded call left unchanged.