Skip to content

Conversation

@fabriciolima
Copy link

@fabriciolima fabriciolima commented Dec 7, 2025

The current check for abstract methods in decorators was too restrictive. According to the CDI specification, decorators may declare abstract methods that belong to decorated types. The check should only reject abstract methods that do not belong to any decorated type.

Changes:

  • Modified Decorators.createDecorator() to check if abstract methods belong to decorated types before rejecting them
  • Added belongsToDecoratedType() method to verify if a method exists in any decorated type
  • Added methodParametersMatch() helper to compare method signatures
  • Now checks abstract methods from decorator class and inherited from superclasses (as mentioned in the TODO comment)

This fixes the issue where decorators with abstract methods that belong to the decorated interface were incorrectly rejected.

@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Dec 7, 2025
@geoand geoand requested a review from Ladicek December 8, 2025 06:55
* Checks if a method belongs to any of the decorated types.
* A method belongs to a decorated type if it has the same name and parameter types.
*/
private static boolean belongsToDecoratedType(MethodInfo method, Set<Type> decoratedTypes,
Copy link
Member

Choose a reason for hiding this comment

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

This method is incorrect, because it ignores methods inherited from superinterfaces of decorated types.

Copy link
Member

Choose a reason for hiding this comment

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

This should be relatively easy to fix.

/**
* Checks if two methods have matching parameter types.
*/
private static boolean methodParametersMatch(MethodInfo method1, MethodInfo method2) {
Copy link
Member

Choose a reason for hiding this comment

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

This method is incorrect, because it ignores generic interfaces and decorators implementing instantiations of them.

Copy link
Member

Choose a reason for hiding this comment

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

This can actually be fairly hard to fix. I know we have utilities in ArC to do type parameter substitutions, but I'm not sure how easily they apply here.

@Ladicek
Copy link
Member

Ladicek commented Dec 8, 2025

Also, this is completely lacking tests.

@fabriciolima fabriciolima marked this pull request as draft December 9, 2025 13:21
The check for abstract methods in decorators was too restrictive.
According to the CDI specification, decorators may declare abstract methods
that belong to decorated types. The check should only reject abstract methods
that do not belong to any decorated type.

Changes:
- Modified Decorators.createDecorator() to check if abstract methods belong
  to decorated types before rejecting them
- Added methodExistsInHierarchy() to verify if a method exists in the
  decorated type hierarchy (including superinterfaces)
- Added allParamsMatch() helper to compare method signatures
- Now checks abstract methods from decorator class and inherited from
  superclasses (as mentioned in the TODO comment)
- Added comprehensive test cases for the fix

This fixes the issue where decorators with abstract methods that belong
to the decorated interface were incorrectly rejected.

Note: This fix does not handle generic interfaces with type parameters
(e.g., GenericInterface<T> with T resolved to String). This is a known
limitation that could be addressed in a follow-up PR.

Fixes: quarkusio#51196
@fabriciolima fabriciolima force-pushed the fix/decorator-abstract-methods-check branch from a7ec8d6 to 6c58e91 Compare December 9, 2025 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/arc Issue related to ARC (dependency injection)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArC: imprecise check for abstract methods in decorators

3 participants