Conversation
LeakageSignatureCollector is an ASM ClassVisitor that collects all types referenced in the public API surface of public classes: superclass, interfaces, method signatures, field types, thrown exceptions, and generic type parameters. TypeCollectorSignatureVisitor is an ASM SignatureVisitor that extracts class types from generic type signatures (e.g. List<InternalType>), catching leakages that would be invisible from erased descriptors alone.
New Maven goal 'leakagecheck' that detects when @publicapi classes expose types from non-@publicapi packages in their public signatures. The mojo scans all dependency JARs to build the full @publicapi package set, then checks each public class in @publicapi packages for references to Vespa types (com.yahoo.*, ai.vespa.*) that are not in @publicapi packages. Detected leakages are compared against a leakage-spec.json file; both new leakages and stale spec entries fail the build. Use -Dleakage.writeSpec to generate or update the spec file.
Add the leakagecheck execution alongside the existing abicheck execution in the abi-check-plugin configuration. Both goals share the same publicApiAnnotation configuration and run at the package phase.
Generated by running `mvn package -Dleakage.writeSpec` across all modules. These spec files grandfather existing leakages so the build can enforce that no new leakages are introduced going forward.
7ff3f40 to
0d7b5a4
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new leakagecheck goal in the abi-check-plugin to detect and prevent @PublicApi classes from exposing types from non-@PublicApi packages in their public signatures. The check scans the module JAR and all dependencies to build a complete set of @PublicApi packages, then uses ASM to extract referenced types from method signatures, fields, supertypes, and generic type parameters. Detected leakages are compared against per-module leakage-spec.json files (following the same pattern as abi-spec.json), and the build fails on new leakages or stale entries.
Changes:
- Added
leakagecheckgoal to the Maven build lifecycle inparent/pom.xml - Implemented
LeakageCheckermojo andLeakageSignatureCollectorfor detecting API leakages - Grandfathered existing leakages in 16 modules via checked-in
leakage-spec.jsonfiles
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| parent/pom.xml | Adds leakagecheck execution to the abi-check-plugin configuration |
| abi-check-plugin/src/main/java/com/yahoo/abicheck/mojo/LeakageChecker.java | Main mojo implementation for detecting and validating PublicApi leakages |
| abi-check-plugin/src/main/java/com/yahoo/abicheck/collector/LeakageSignatureCollector.java | ASM visitor that collects types from public API surfaces |
| abi-check-plugin/src/main/java/com/yahoo/abicheck/collector/TypeCollectorSignatureVisitor.java | ASM signature visitor for extracting generic type parameters |
| abi-check-plugin/src/test/java/com/yahoo/abicheck/mojo/LeakageCheckerTest.java | Unit tests for leakage filtering and comparison logic |
| abi-check-plugin/src/test/java/com/yahoo/abicheck/LeakageSignatureCollectorTest.java | Unit tests for type collection from class files |
| */leakage-spec.json (16 files) | Per-module specification files documenting grandfathered API leakages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
leakagecheckgoal toabi-check-pluginthat detects when@PublicApiclasses expose types from non-@PublicApipackages in their public signaturesprovidedscope) to build the full@PublicApipackage setleakage-spec.json(same pattern asabi-spec.json); fail on new leakages and stale entriesleakage-spec.jsonfilesTest plan
mvn test -f abi-check-plugin/pom.xmlpasses (30 tests)mvn package -DskipTests --threads 1C