You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by 武哥 <wa...@gmail.com> on 2026/08/01 17:23:19 UTC
[DISCUSS] Compile-time validation for Java Thrift annotations
Hello,
I’m working on ThriftAnnotationLint, an independent Java annotation processor for projects using Facebook Swift or Airlift Drift annotations.
Some annotation mistakes are accepted by javac but fail later when Swift or Drift builds runtime metadata or initializes a codec. In an enterprise release pipeline, this can be especially costly when a model JAR is released first and the consuming server is deployed later. The problem may only appear during integration tests, application startup, or even after deployment.
Apache Thrift’s compiler validates Thrift IDL files, but that is a different layer from validating Java classes annotated for Swift or Drift. Based on a review of the publicly available tools and repositories, I have not found a widely used public tool that provides comprehensive compile-time semantic validation for these annotated Java models. I would be interested to know whether Thrift users are aware of an existing solution or internal tool in this area.
ThriftAnnotationLint moves these checks into compilation and reports diagnostics on the source element that introduced the problem. It currently checks:
- duplicate, missing, or conflicting Thrift field IDs and names;
- invalid requiredness, constructors, builders, getters, setters, and unions;
- incompatible Java types and codec container shapes;
- undeclared recursive model cycles;
- reachable generic models from source and classpath dependencies.
The project is Java 8 compatible, has no runtime dependencies, and is verified against Facebook Swift 0.19.2–0.23.1 and Airlift Drift 1.18.
Project:
https://github.com/EzraIO/thrift-annotation-lint
Maven Central:
https://central.sonatype.com/artifact/io.github.ezraio/thrift-annotation-lint/0.2.2
I would appreciate feedback from Thrift users:
1. Have you encountered similar annotation or codec initialization failures?
2. Would compile-time validation be useful in your build pipeline?
3. Which validation rules or integrations would be most valuable?
4. Are there existing tools, internal or public, that cover this use case?
This is an independent project and is not an official Apache Thrift component.
Best regards,
Wang Wu