Annotation Interface Final


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented public @interface Final
Marks a type as non-extendable, or a method as non-overridable, without using the final keyword.

AOP is implemented by generating a subclass whose intercepted methods reach the original body through super. A final class cannot be subclassed and a final method cannot be overridden, so the keyword and AOP are mutually exclusive. This annotation expresses the same intent while leaving the class proxyable.

The contract is enforced when the framework scans a module's classes: a class extending a @Final type, or overriding a @Final method, is rejected at load time. Enforcement therefore covers every class loaded through the framework, across module boundaries. It does not happen at compile time, so an IDE will not flag a violation.

Usage example:


 @Final
 @Service
 public class PaymentService {

     @Transactional
     public void transfer(UUID from, UUID to, double amount) { }
 }
 
Since:
6.3.0
Author:
wisdomme