Jattern: A program query language for Java

(2025)

Files

Dedoyard_19772301_2025.pdf
  • UCLouvain restricted access
  • Adobe PDF
  • 565.5 KB

Details

Supervisors
Faculty
Degree label
Abstract
This thesis investigates the feasibility of extending a grammar-based pattern matching tool, originally designed for Python called Pyttern, to support another language: Java. The result of this work is Jattern, a language extension that brings structural pattern matching to Java source code. Unlike traditional tools that rely on simplified ASTs or bytecode analysis, Jattern directly extends the Java grammar using ANTLR and introduces custom wildcard constructs. These wildcards allow patterns to express flexible but structured code idioms, which can then be matched against real Java code. The thesis contributes a modular refactoring of the Pyttern codebase architecture, the implementation of five Java-specific wildcards, a guide for adding new wildcards, and validation through unit tests and idiom detection. It demonstrates that Pyttern’s model can be generalized, paving the way toward a multi-language pattern-matching framework useful for education and static analysis.