• Refine Query
  • Source
  • Publication year
  • to
  • Language
  • 1
  • Tagged with
  • 1
  • 1
  • 1
  • 1
  • 1
  • 1
  • 1
  • 1
  • 1
  • 1
  • 1
  • About
  • The Global ETD Search service is a free service for researchers to find electronic theses and dissertations. This service is provided by the Networked Digital Library of Theses and Dissertations.
    Our metadata is collected from universities around the world. If you manage a university/consortium/country archive and want to be added, details can be found on the NDLTD website.
1

Constraining future extensions of immutable classes / Begränsning av framtida arv från omuterbara klasser

Blomstrand, Mikael January 2018 (has links)
Immutable data and persistent data structures are seeing more and more use. Many common programming errors can be solved by simply using immutable data, and in concurrent and parallel programming, they remove the need for data synchronization. There are many benefits of immutable data, but few modern languages provide a way to declare or control immutability. By analyzing a class, it is possible to know whether creating an object of that specific class will make an immutable object. This means that for final classes, which can't be extended, immutability can be inferred from the type. The same is not true for non-final classes. A mutable subclass can be made without recompiling the original, immutable superclass, making it possible to make mutable objects of the previously immutable class. This makes all non-final classes potentially mutable, ruling out many interesting class hierarchies. This thesis explores how the use of such unwanted class extensions could be detected. The solution introduces \emph{phantom classes}, synthetic final classes that are used in place of the original classes. These classes are essentially empty class extensions, behaving exactly the same as the original classes, but since they are final, can not be extended. An object can be verified by downcasting. If the cast fails, the object have been created in foreign code.A proof-of-concept is implemented as a fork of Dotty, what will become version 3 of the Scala compiler. The implementation is called Mållgan.Mållgan is able to compile real code, and produces executable JVM bytecode.Tests show that the code compiled with Mållgan can still be used normally by code compiled with regular Dotty, indicating that the solution is transparent to any code not aware of it. Overall the study shows that the solution is feasible, but a formal proof would be needed to provide definite proof for the correctness. / Omuterbar data och beständiga datastrukturer används mer och mer. Många vanliga programmeringsfel kan undvikas genom att använda omuterbar data, och i parallell och flertrådig programmering slipper man datasynkronisering. Det finns många fördelar med omuterbar data, men få moderna programmeringsspråk stödjer ett sätt att deklarera eller kontrollera omuterbarhet. Genom att analysera en klass är det möjligt att ta reda på om ett objekt som skapats från klassen är omuterbar. För klasser som inte går att ärva går det alltså att härleda om ett objekt är omuterbart eller inte från typen. För klasser som går att ärva finns inga garantier för att subklasserna är omuterbara, och subklasser kan skapas utan att orginalklassen måste kompileras om. Det här gör att alla klasser som går att ärva är potentiellt muterbara, vilket omöjliggör många intressanta klasshierarkier. Den här uppsatsen utforskar hur sådana oönskade subklasser kan upptäckas. Lösningen heter \emph{fantomklasser} (phantom classes), syntetiska klasser som inte går att ärva. Dessa är i grund och botten tomma subklasser som beter sig exakt likadant som orginalklasserna. Ett objekt kan verifieras genom att verifiera typen. Om de inte kan göras till fantomklassen måste de ha gjorts av främmande kod. Som proof-of-concept implementerades lösningen som en fork av Dotty, det som kommer att bli version 3 av Scala-kompilatorn. Implementationen heter Mållgan. Mållgan klarar att kompilera verklig kod och producerar exekverbar JVM bytekod. Tester visar att kod kompilerad med Mållgan fortfarande kan användas som vanligt med vanlig Dotty. Det här indikerar att lösningen är transparent för kod som inte är medveten om implementationen. Studien visar att lösningen är genomförbar, men ett mer formellt bevis krävs för att visa att lösningen är korrekt.

Page generated in 0.2849 seconds