The wide adoption of third-party libraries in software projects is beneficial but also risky. Third-party libraries may have security vulnerabilities, may be abandoned by their maintainers, or may no longer align with current project requirements. Under such circumstances, developers need to migrate a library to another library with similar functionalities, but the migration decisions are often opinion-based and sub-optimal with limited information at hand. Therefore, several filtering-based approaches have been proposed to mine library migrations from existing software data, but they suffer from either low precision or low recall with different thresholds, which limits their usefulness in supporting migration decisions.
In this paper, we present a novel approach that utilizes multiple metrics to rank and therefore recommend library migrations. Given a library to migrate, our approach first generates candidate target libraries from a large corpus of software repositories, and then ranks them by combining the following four metrics to capture different dimensions of evidence from development history: Rule Support, Message Support, Distance Support, and API Support. We evaluate the performance of our approach with 773 migration rules (190 source libraries) that we borrow from previous work and recover from 21,358 Java GitHub projects. The experiments show that our metrics are effective to help identify real migration targets from other libraries, and our approach significantly outperforms existing works, with MRR of 0.8566, top-1 precision of 0.7947, top-10 NDCG of 0.7665, and top-20 recall of 0.8939. To demonstrate the generality of our approach, we manually verify the recommendation results of 480 most popular libraries and confirm 661 new migration rules from 231 libraries with comparable performance.