Skip to content

Conversation

@timtebeek
Copy link
Member

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite May 9, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/resources/META-INF/rewrite/examples.yml
    • lines 2337-2336
    • lines 2352-2364
    • lines 2801-2800
    • lines 2820-2831

@Jenson3210
Copy link
Contributor

Jenson3210 commented May 9, 2025

What should we do when we the code has 3 levels of inheritance?

class PlainText {
    // someone allows for exceptions 
    protected void check() throws CheckedException {
        basicChecks()
    }
}
class ConfidentialText extends PlainText{
    // someone allows for exceptions 
    @Override
    protected void check() throws CheckedException {
        advancedChecks()
    }
}
class TopSecret extends ConfidentialText {
    // someone allows for exceptions 
    @Override
    protected void check() throws CheckedException {
       doesNotThrow()
    }
}

Will this not clean up the throws clause of ConfidentialText and TopSecret whereas it might have been needed by TopSecret?

@timtebeek
Copy link
Member Author

You're right, thanks! I thought the third level would get the exceptions declared on the top level still, but turns out that's not the case. Adjusted the logic to now look for final on the method or the class on protected methods before we change the signature.

@timtebeek timtebeek self-assigned this May 10, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/resources/META-INF/rewrite/examples.yml
    • lines 2337-2336
    • lines 2352-2364
    • lines 2801-2800
    • lines 2820-2831

Copy link
Contributor

@Jenson3210 Jenson3210 left a comment

Choose a reason for hiding this comment

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

LGTM!
Potentially add a C3 which does not get changed in the tests? Non final class and non final method. Although that is also covered by your original test case, it might be very clear how it behaves and what the difference is between these 3.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite May 10, 2025
@timtebeek
Copy link
Member Author

Thanks for the help improving the approach! On mobile here from the plane, so I'll merge as is 😅

@timtebeek timtebeek merged commit 988df5c into main May 10, 2025
2 checks passed
@timtebeek timtebeek deleted the UnnecessaryThrows-should-not-change-protected-api branch May 10, 2025 08:54
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants