Skip to content

Skip adding methods already provided by a superclass#983

Open
Jenson3210 wants to merge 3 commits intomainfrom
superclass-method-check
Open

Skip adding methods already provided by a superclass#983
Jenson3210 wants to merge 3 commits intomainfrom
superclass-method-check

Conversation

@Jenson3210
Copy link
Contributor

@Jenson3210 Jenson3210 commented Feb 13, 2026

Summary

  • AddMissingMethodImplementation now checks the superclass hierarchy before adding a method
  • Prevents duplicate method stubs when a superclass already provides the implementation

Problem

When running the Spring Boot 4 migration recipe, isWrapperFor, unwrap, and getParentLogger methods were being added to classes that extend superclasses (e.g., HikariDataSource, SnowflakeBasicDataSource) which already provide these methods. The recipe only checked the class's own body for existing methods, not the inherited ones.

Solution

Walk up the getSupertype() chain in AddMissingMethodImplementation and check if any superclass already has a matching method via getMethods(). If so, skip adding the method.

Test plan

  • Existing tests pass

  • New test added: skipWhenSuperclassAlreadyHasMethod — verifies that a subclass extending a superclass with the method is left unchanged

  • Fixes moderneinc/customer-requests#1862

When a class extends a superclass that already has the method
implementation, AddMissingMethodImplementation should not add
the method again.

Reproduces moderneinc/customer-requests#1862
AddMissingMethodImplementation now walks up the superclass chain
to check if the method is already inherited, avoiding unnecessary
duplicate method additions to classes like HikariDataSource subclasses.

Fixes moderneinc/customer-requests#1862
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant