jakartaee / interceptors

Jakarta Interceptors
https://eclipse.org/ee4j/interceptors
Other
11 stars 24 forks source link

Default method interception and bindings inheritance rules #84

Open manovotn opened 3 years ago

manovotn commented 3 years ago

Hello,

recently we came across and interesting question which revolves around interception of default methods.

Currently, the specification doesn't really mention default methods. Therefore you can only imply what it should behave like. One not so obvious aspect is inheritance rules for interceptor bindings in conjunction with default methods. According to what the spec says right now, you do not inherit bindings from interfaces. However, that means that the only way to intercept a default method is to use a class-level binding on the implementing class.

I have seen this disputed by users (of Weld and Quarkus, both of which support default method interception) several times and I have to give them some credit for it. It is indeed not really intuitive. It also takes away some customization power because you cannot use method-level binding with default methods; you have to intercept all methods of the implementing class.

I realize changing this presents backward compatibility issues and I am not saying we should go that way. However, I'd like to hear some more opinions on how people perceive this, if the spec should perhaps mention this and what they think could/should be done in this regard.