PulseExploreJournal ClubDebatesTrendingResearchersJournals
Instagram
HomeExploreJournal ClubTrending
Synapse
⌘+K
Synapse
January 25, 2026ACM Transactions on Software Engineering and Methodology0 citations

Unmasking the Type Inference Capabilities of LLMs for Java Code Snippets

View Full Paper
YDYiwen DongZXZhenyang XuYTYongqiang Tian

Key Points

  • The aim is to assess the type inference capabilities of LLMs on Java code snippets and address potential biases in current evaluations.
  • Developed ThaliaType, a new benchmark suite for type inference evaluation.
  • Analyzed data leakage from StatType-SO in StarCoder2’s training set.
  • Conducted performance evaluations of various LLMs on both StatType-SO and ThaliaType.
  • Implemented semantic-preserving code transformations to test LLMs’ understanding of code execution semantics.
  • Performance of LLMs drops significantly on ThaliaType compared to StatType-SO, with precision decreasing by up to 59%.
  • Recall decreases by up to 72% when evaluated with the new benchmark.
  • Findings indicate that earlier strong performance might be influenced by data leakage, affecting generalizability.

Abstract

Type inference is a crucial task for reusing online code snippets. Although code snippets are prevalently shared on platforms like StackOverflow, they frequently lack essential type information, such as fully qualified names (FQNs) and required libraries. Recent studies have leveraged Large Language Models (LLMs) to perform type inference for such code snippets, demonstrating promising performance. However, these evaluations may suffer from data leakage, as the benchmark suite, StatType-SO, used for evaluation has been publicly available on GitHub since 2017. Consequently, it remains uncertain whether the strong performance of LLMs reflects genuine semantic understanding of code or is due to the ground truth being included in the training set. This paper strives to comprehensively evaluate the genuine type inference capabilities of LLMs on Java code snippets and identify potential limitations of LLMs. First, we created ThaliaType, a new, previously unreleased benchmark suite designed for type inference evaluation. Second, using the StarCoder2 LLM as a baseline, we uncovered data leakage from StatType-SO in StarCoder2’s open-source training set and observed that other state-of-the-art LLMs exhibit similar performance drops when evaluated on ThaliaType, with precision decreasing by up to 59% and recall by up to 72%. Finally, we developed semantic-preserving code transformations to further investigate the capabilities of LLMs in understanding the execution semantics of code snippets. Our results showed that the performance of LLMs on StatType-SO is far less robust to these transformations than on ThaliaType, suggesting that the performance on StatType-SO may be biased by data leakage and have limited generalizability. These findings highlight the importance of carefully designed, leakage-free benchmarks for evaluating LLMs on type inference tasks. We recommend future studies adopt ThaliaType to ensure rigorous and reliable assessments of LLMs’ genuine type inference capabilities.

Ask AI
Helpful
Bookmark
Share
View Full Paper

Cite This Study

Dong et al. (2026) studied this question.

synapsesocial.com/papers/6975b306feba4585c2d6e8e0https://doi.org/10.1145/3790099
Ask AI
Helpful
Bookmark
Share
View Full Paper