A class that the framework subclasses at run time is final, or an entity has final methods
What it finds
Spring subclasses @Configuration classes so that calls between @Bean methods return the shared bean, and JPA providers subclass entities to load them lazily. A final class cannot be subclassed, so Spring refuses to start, and a final method of an entity cannot be intercepted, so it reads fields that were never loaded.
Reported is a final class annotated @Configuration, unless it sets proxyBeanMethods to false, or @Entity, @Embeddable or @MappedSuperclass, and a final instance method of such an entity class that is not private.
From the rule's source, final_proxied_class.rs.
import javax.persistence.Entity;import org.springframework.context.annotation.Configuration; @Configurationfinal class AppConfig {}tx0 reports: cannot be final @Configuration(proxyBeanMethods = false)final class LiteConfig {} @Entityclass Order { public final long total() {tx0 reports: cannot be intercepted return 0; } private final long hidden() { return 0; }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:final-proxied-class" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:final-proxied-class] reason="..."tx0 explain tx0/java:final-proxied-class shows the same in the terminal. Found a false positive? Report it.