Introduction
Modern software development on the Java Virtual Machine (JVM) frequently involves polyglot environments where Java, Kotlin, Scala, and Groovy coexist. While individual compilers for these languages are highly mature, their interoperability—the "cross-language" compilation process—introduces significant complexity. Compilers must resolve types, inheritance structures, and method signatures across language boundaries, often leading to inconsistent assumptions and bugs.
CrossLangFuzzer is a novel framework designed to systematically explore these "seams" between languages. By generating complex, multi-lingual test programs, the framework has successfully identified 24 confirmed compiler bugs, highlighting cross-language interoperability as an under-explored source of software instability.
Methodology
CrossLangFuzzer operates through a structured three-stage pipeline designed to generate, test, and minimize bug-triggering programs.
1. Universal Intermediate Representation (IR)
To maintain critical source-level information like override intent—which is often lost in JVM bytecode—the framework utilizes a custom IR. This IR allows for the definition of class hierarchies and method signatures that can be rendered into any of the four target languages.
2. Automated Program Generation & Mutation
The tool generates valid class structures and applies three specific mutators to introduce diversity:
- LangShuffler: Randomly assigns languages to classes within a hierarchy.
- FunctionRemoval: Deletes methods to test if compilers correctly identify missing overrides.
- TypeChanger: Modifies generic type parameters to stress-test cross-language type resolution.
3. Differential Testing
Differential testing serves as the oracle for bug detection. The framework compiles the same generated code using different versions of a compiler (e.g., a latest release vs. a stable older version). Discrepancies in compilation results indicate potential bugs.
Evaluation and Results
The framework was evaluated against the latest production versions of major JVM compilers, including Kotlin (kotlinc K1/K2), Groovy (groovyc), Scala (scala2c/scala3c), and Java (javac).
In just one month of operation, CrossLangFuzzer uncovered 24 confirmed bugs:
- Kotlin: 10 bugs
- Scala 3: 7 bugs
- Groovy: 4 bugs
- Scala 2: 2 bugs
- Java: 1 bug
These findings included both regressions and long-standing issues that had escaped traditional single-language testing suites.
Key Insights
- The "User Side" Vulnerability: When a cross-language bug occurs (e.g., Language A calling Language B), the failure typically lies with the "user side" (Language A's compiler) failing to correctly adapt to the "provider's" (Language B) type system.
- Generics as a Primary Bug Source: 20 of the 24 discovered bugs were related to generics. Differences in how languages handle type erasure, wildcards, and specific types (like Kotlin’s
Nothing) are frequent sources of confusion. - Effectiveness of TypeChanger: The
TypeChangermutator was the most effective, detecting 11 of the 24 bugs, suggesting that nested generic type resolution across language boundaries is a particularly weak point in modern compilers. - Complexity Requirements: Bugs typically required deep inheritance trees (average depth of 3.21), explaining why simple unit tests often fail to catch them.
Limitations and Future Work
Currently, the process of shrinking bug-triggering code into a "minimized trigger program" remains largely manual, requiring significant domain expertise. Additionally, the IR is limited to class and method-level structures, excluding internal method logic and access modifiers. Future work aims to automate the minimization process and expand the IR to support expression-level generation.
Summary updated