Back to search

University of Waterloo

Reified Generic Types for Scala 3 on the JVM

Abstract

dc:description.abstract

Scala implements parametric polymorphism on the Java Virtual Machine (JVM) primarily through type erasure. As a result, generic type arguments are normally unavailable during execution, and primitive values passed through generic code are represented using boxed object references. This limits the information available to the virtual machine and prevents generic values from consistently using unboxed forms. This thesis presents an extension to the Scala 3 compiler that preserves generic type information and communicates it to a reification-aware JVM. The compiler inserts lightweight runtime reified type values for method and class type parameters and propagates them through the Scala compiler intermediate representation. It also emits custom JVM classfile attributes that describe how erased method parameters, return values, fields, method invocations, and object allocations relate to the corresponding reified type values. Together, these runtime values and static hints define a reified unboxed semantics, while retaining ordinary JVM bytecode as the underlying executable representation. The implementation modifies the Scala 3 compiler and integrates reification with its existing transformation and bytecode generation pipeline. It is evaluated using focused generic benchmarks and by recompiling the Scala standard library. The modified compiler successfully compiles the standard library. Of the 2058 standard library tests, 2033 pass, for a pass rate of 98.7%. The remaining failures are primarily caused by structural changes introduced by reification. These results demonstrate that generic type information can be preserved through the production Scala compiler and encoded at the JVM bytecode level at the scale of a realistic Scala codebase. The work establishes the compiler-side foundation for future evaluation and optimization in a reification-aware JVM.

Degree

thesis:*
Grantor dc:publisher
University of Waterloo
Year dc:date.issued
2026

Author and committee

dc:creator, dc:contributor.*
Author dc:creator
  • Xu, Jin

Rights

Language dc:language.iso
en

Identifiers

dc:identifier.*
Handle dc:identifier.uri
https://hdl.handle.net/10012/24005

Chain of custody

source
Harvested from
University of Waterloo
Base URL
dspacemainprd01.lib.uwaterloo.ca/server/oai/request
Last updated
2026-11-19
Source record
OAI-PMH GetRecord
related terms
citation

Xu, Jin. Reified Generic Types for Scala 3 on the JVM. University of Waterloo, 2026. https://hdl.handle.net/10012/24005