Towards Safe Initialization of Scala Global Objects

dc.contributor.authorXing, Enze
dc.date.accessioned2025-12-16T15:37:10Z
dc.date.available2025-12-16T15:37:10Z
dc.date.issued2025-12-16
dc.date.submitted2025-12-10
dc.description.abstractThis thesis focuses on safe initialization of global objects in Scala. Global objects encapsulate global information in Scala, and their initialization is susceptible to causing run-time errors. Moreover, global objects are initialized by demand (i.e. on their first access). The initialization safety of a global object is brittle if it depends on the initialization point of the object, because the initialization point is the first access in the entire program. This motivates the idea of automatically detecting potential initialization errors during compilation. The main contribution of this thesis is designing and implementing a global object initialization checker in the Scala compiler. Theoretically, we identified run-time errors caused by unsafe initialization patterns of global objects and organized three static principles to enforce on Scala programs: Prohibiting accesses to uninitialized fields, which prevents null pointer exceptions; partial ordering of global object initialization order, which prevents deadlocks between locks that guard the initialization of global objects; and initialization-time irrelevance, which ensures that initialization safety of the global object is independent of the initialization point. We then designed the global object initialization checker by proposing the formal initialization semantics of a Scala initialization calculus, and the initialization checker is presented as an abstract interpreter of the initialization calculus. The initialization checker also checks the initialization process of each global object individually rather than conducting a whole-program analysis. Practically, we have integrated the abstract interpreter into the Scala compiler after extending the initialization semantics with more Scala features. The initialization checker can be turned on when compiling Scala programs, and we evaluated the initialization checker during the compilation of many widely-used open-source Scala projects which form a test suite. The initialization checker reports warnings in several projects that are verified to be true positives. The result highlights the necessity of checking the initialization safety of Scala projects and the utility of the global object initialization checker in this thesis.
dc.identifier.urihttps://hdl.handle.net/10012/22744
dc.language.isoen
dc.pendingfalse
dc.publisherUniversity of Waterlooen
dc.subjectprogramming language
dc.subjectScala
dc.titleTowards Safe Initialization of Scala Global Objects
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.advisorLhotak, Ondrej
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:
Xing_Enze.pdf
Size:
646.15 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: