Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter methods fail when the original method has a parameter #70

Merged
merged 4 commits into from
Aug 9, 2023

Conversation

basil
Copy link
Member

@basil basil commented Aug 9, 2023

Fixes #69. The new test fails without the changes to src/main and passes with them. The problem is that the logic for pushing arguments to the stack

for (Type p : paramTypes) {
    mv.visitVarInsn(p.getOpcode(ILOAD), sz);
    sz += p.getSize();
}

assumes that we didn't previously call

if (hasAdapterMethod()) {
    // the LHS of the adapter method invocation
    ga.loadThis();
    sz++;
}

a few lines earlier. If we did, then sz will have been incremented by one for the LHS of the adapter method invocation and we will be off by one. This PR corrects the off-by-one error by accounting for whether or not an adapter method is present.

@basil basil changed the title Demonstrating #69 Adapter methods fail when the original method has a parameter Aug 9, 2023
@basil basil marked this pull request as ready for review August 9, 2023 18:06
@basil basil requested a review from kohsuke August 9, 2023 18:16
Copy link
Member

@kohsuke kohsuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the substance of the change. I left one comment as a suggestion to make the intent a little clearer (which led to this bug in the first place)

@basil basil merged commit 62ba141 into jenkinsci:master Aug 9, 2023
@basil basil deleted the parameter branch August 9, 2023 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapter methods fail when the original method has a parameter
2 participants