Reified Generic Types for Scala 3 on the JVM

dc.contributor.authorXu, Jin
dc.date.accessioned2026-08-20T19:55:12Z
dc.date.issued2026-08-20
dc.date.submitted2026-08-18
dc.description.abstractScala 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.
dc.identifier.urihttps://hdl.handle.net/10012/24005
dc.language.isoen
dc.pendingfalse
dc.publisherUniversity of Waterlooen
dc.titleReified Generic Types for Scala 3 on the JVM
dc.typeMaster Thesis
uws-etd.degreeMaster of Mathematics
uws-etd.degree.departmentDavid R. Cheriton School of Computer Science
uws-etd.degree.disciplineComputer Science
uws-etd.degree.grantorUniversity of Waterlooen
uws-etd.embargo.terms0
uws.contributor.advisorLhoták, Ondřej
uws.contributor.affiliation1Faculty of Mathematics
uws.peerReviewStatusUnrevieweden
uws.published.cityWaterlooen
uws.published.countryCanadaen
uws.published.provinceOntarioen
uws.scholarLevelGraduateen
uws.typeOfResourceTexten

Files

Original bundle

Now showing 1 - 1 of 1
Loading...
Thumbnail Image
Name:
Xu_Jin.pdf
Size:
484.12 KB
Format:
Adobe Portable Document Format

License bundle

Now showing 1 - 1 of 1
Loading...
Thumbnail Image
Name:
license.txt
Size:
6.4 KB
Format:
Item-specific license agreed upon to submission
Description: