Skip to content

ReflectionUtils considers locally overloaded default methods as overridden #976

Closed
@sbrannen

Description

@sbrannen

Overview

ReflectionUtils.isMethodShadowedBy(Method, Method) currently contains logic related to sub-signatures and generics that incorrectly considers an inherited overloaded method as overridden (a.k.a., shadowed). Consequently, certain searches for methods via findMethods(*) will omit valid methods from the results.

For example, given the following interface and concrete implementation, a search for all methods named foo within the class will only return the method in the class. The default method from the interface is incorrectly considered to be overridden by the foo(Double) method in the class.

interface InterfaceWithGenericDefaultMethod<N extends Number> {

	@Test
	default void foo(N number) {
	}
}

class GenericDefaultMethodTests implements InterfaceWithGenericDefaultMethod<Long> {

	@Test
	void foo(Double number) {
	}
}

Consequently, any attempt to execute GenericDefaultMethodTests as a test class using JUnit Jupiter will result in the execution of only one test method instead of the expected two.

Related Issues

Deliverables

  • Ensure that default methods that are overloaded by local methods are not considered overridden by the overloaded method.
  • Enabled @Disabled tests introduced in commit 7e1f75a.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions