[Paper Review] API Beauty is in the eye of the Clients: 2.2 Million Maven Dependencies reveal the Spectrum of Client-API Usages
This study analyzes 2.2 million Maven dependencies across 94 popular Java libraries to reveal that while most API types are used by at least one client, a small core of types accounts for the vast majority of client usage. The findings resolve the paradox between Hyrum’s Law and empirical observations by showing a spectrum of usage: most APIs are minimally used, but with enough clients, even rare elements are adopted, enabling API maintainers to prioritize core elements for maintenance and documentation.
Hyrum's law states a common observation in the software industry: "With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody". Meanwhile, recent research results seem to contradict this observation when they state that "for most APIs, there is a small number of features that are actually used". We investigate this seeming paradox between the observations in industry and the research literature, with a large scale empirical study of client API relationships in one single ecosystem: Maven Central. We study the 94 most popular libraries in Maven Central, as well as the 829,410 client artifacts that declare a dependency to these libraries and that are available in Maven Central, summing up to 2.2M dependencies. Our analysis indicates the existence of a wide spectrum of API usages, with enough clients, most API types end up being used at least once. Our second key observation is that, for all libraries, there is a small set of API types that are used by the vast majority of its clients. The practical consequences of this study are two-fold: (i) it is possible for API maintainers to find an essential part of their API on which they can focus their efforts; (ii) API developers should limit the public API elements to the set of features for which they are ready to have users.
Motivation & Objective
- To resolve the apparent contradiction between Hyrum’s Law (all observable behaviors are used) and research showing only a small subset of API features are actually used.
- To investigate the spectrum of client-API usage patterns in a large-scale, real-world ecosystem—Maven Central.
- To determine the trade-off between API maintenance effort and the number of clients supported by focusing on commonly used API elements.
- To provide actionable insights for API developers on reducing public surface area while maintaining broad client compatibility.
- To explore the feasibility of supporting the majority of clients by maintaining only a small fraction of an API’s types.
Proposed method
- Collected 829,410 client artifacts and 5,225 library versions from the Maven Dependency Graph (MDG) as of September 2018.
- Performed static bytecode analysis to detect actual API usage, distinguishing declared dependencies from runtime usages.
- Analyzed usage patterns across all versions of each API to identify cumulative usage, then focused on the most popular version.
- Defined 'Core_n' as the minimal set of API types needed to support n% of clients, using extinction sequences to measure impact.
- Used statistical analysis to quantify the proportion of API types used by zero, few, or most clients across the 94 libraries.
- Validated results through manual review by three researchers and open-sourced all data and code for reproducibility.
Experimental results
Research questions
- RQ1To what extent do declared dependencies in Maven Central actually result in runtime API usage?
- RQ2How many API types are used by at least one client across the most popular versions of libraries?
- RQ3What fraction of API types accounts for the majority of client usage, and how does this vary across libraries?
- RQ4Can a significant portion of clients be supported by maintaining only a small subset of an API’s types?
- RQ5How does the presence of reflection or dynamic invocation affect the accuracy of static analysis in detecting API usage?
Key findings
- 41.13% of declared dependencies do not result in any actual API usage at the bytecode level, indicating a significant gap between declaration and runtime use.
- For the most popular version of each library, every public API member is used by at least one client, confirming Hyrum’s Law at scale.
- For over half of the 94 libraries, only 12% of API types are needed to support 75% of clients, indicating a strong core of frequently used elements.
- The migration effort for a library like gson:2.3.1 can be reduced from 162 to 20 API types (12%) by focusing on supporting 90% of clients instead of all.
- Even rare or exotic API types are eventually used by at least one client when the client base is sufficiently large, supporting Hyrum’s Law.
- The prevalence of reflection in client code is low (≤0.47% of methods), suggesting that static analysis is reliable for detecting actual API usage in this context.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.