TL;DR
JavaBench is a new project-level benchmark designed to evaluate how well Large Language Models (LLMs) handle complex, multi-class Java projects and core Object-Oriented Programming (OOP) features. The study reveals a significant "human-AI gap": while undergraduate students average a 91% pass rate on these tasks, even the best LLMs fail to complete a single project perfectly, highlighting major weaknesses in handling cross-class dependencies and OOP principles like inheritance and encapsulation.
What Problem Does This Paper Address?
Most current code generation benchmarks, such as the widely used HumanEval, suffer from three major imbalances:
- Language Bias: Over 95% of benchmarks focus on Python, leaving static, object-oriented languages like Java under-represented.
- Granularity Gap: Most benchmarks operate at the function or statement level. Real-world software development happens at the project level, involving complex interactions between dozens of classes.
- Missing OOP Features: Existing tests primarily check basic coding logic (loops, variables) but ignore advanced OOP concepts like inheritance, polymorphism, and encapsulation—the bread and butter of professional Java development.
JavaBench bridges this gap by providing a project-level evaluation framework that specifically exercises these advanced features in a realistic Java environment.
Methods
The authors developed a systematic pipeline to evaluate LLMs on project-level generation. Starting with a "skeleton" project where method bodies are replaced with TODO markers, they tested several variables:
- Context Settings: How much information should the LLM see? They compared Maximum Context (the whole project), Minimum Context (only the current class), and Selected Context (the current class plus the method signatures of its dependencies).
- Synthesis Strategies: Should the model generate methods one by one (Independent), all at once (Holistic), or in a specific sequence (Incremental)?
- Evaluation Granularity: To get a nuanced view of performance, they used Class-wise evaluation (replacing one canonical class with a generated one) and Test-wise evaluation (replacing all classes involved in a specific unit test).
Datasets
The core contribution is JavaBench, a benchmark consisting of:
- 4 Java Projects: Based on real-world undergraduate programming assignments (e.g., a chess-like game, a puzzle game).
- Scale: 389 methods across 106 Java classes.
- Testing: 396 manually constructed test cases achieving ~92% code coverage.
- Human Baseline: Data from 282 undergraduate students who completed these same projects, providing a rigorous performance ceiling.
Key Insights and Ideas
- The "Goldilocks" Context: Providing too much information (Maximum Context) often leads to truncation or "lost in the middle" issues, while too little (Minimum Context) leaves the model blind to necessary dependencies. The Selected Context—providing only method signatures of related classes—struck the best balance.
- Holistic is Healthier: Generating an entire class in one pass (Holistic Synthesis) generally outperformed generating methods individually. This suggests LLMs benefit from "seeing" the entire class structure they are intended to build.
- OOP Blind Spots: Models frequently failed on fundamental OOP constraints. Common errors included trying to instantiate abstract classes (inheritance errors) or accessing private fields directly from subclasses (encapsulation errors).
- The Project-Level Wall: While LLMs can be quite good at individual functions, their performance collapses at the project level. No studied LLM could correctly complete an entire project from start to finish.
Key Results
The researchers evaluated five state-of-the-art models, including GPT-3.5 and DeepSeek-Coder.
- Human vs. AI: Undergraduate students achieved a 90.93% average pass rate. In contrast, the best LLM (DeepSeek-Coder-33b) achieved only a 41.17% Pass@5 in the most relaxed evaluation setting.
- Pass Rates: At the class-wise level, the best models reached ~71% Pass@1. However, at the more difficult test-wise level (which requires multiple generated classes to work together), the average Pass@1 dropped to just 18.22%.
- Failure Modes: Analysis of failed cases showed that
AssertionFailedError(logic errors) andIllegalArgumentException(API misuse) were the most frequent culprits, accounting for over 76% of test failures.
Limitations and Future Work
The study was limited to five LLMs due to hardware constraints and focused on models up to 34B parameters. The authors acknowledge that more advanced prompt engineering or Retrieval-Augmented Generation (RAG) techniques might improve these scores.
Future work could involve expanding JavaBench with more diverse projects and exploring how to better "teach" LLMs the semantic constraints of object-oriented design to prevent the common inheritance and encapsulation errors observed in this study.
Summary updated