1 / 22

Featherweight Java

Featherweight Java. „Inside every large language is a small language struggling to get out …“ T.Hoare nach Igarashi, Pierce, Wadler. Gliederung. Motivation Featherweight Java Programmstruktur Reduktion Regeln(Syntax, Reduktion, Typisierung) Stupid Cast Beweis der Typsicherheit

Télécharger la présentation

Featherweight Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Featherweight Java „Inside every large language is a small language struggling to get out …“ T.Hoare nach Igarashi, Pierce, Wadler Analysetechniken in der Softwaretechnik SS 2007

  2. Gliederung • Motivation • Featherweight Java Programmstruktur • Reduktion • Regeln(Syntax, Reduktion, Typisierung) • Stupid Cast • Beweis der Typsicherheit • Featherweight Generic Java (FGJ) • Schlussfolgerungen Analysetechniken in der Softwaretechnik SS 2007 Gliederung

  3. Was ist Featherweight Java • ein funktionaler Java-Kern • Reduktion auf das Wesentliche • nur wenig umfangreicher als der -Kalkül • Subset von Java und von Standard-Java compilierbar • voll Turing-fähig Analysetechniken in der Softwaretechnik SS 2007 Motivation

  4. Wozu Featherweight Java? • Finden von Typproblemen im Java-Kern • Beweisen der Typsicherheit des Java-Kerns • Basis für Erweiterungen • plastische Darstellung durch compilierbaren Code Analysetechniken in der Softwaretechnik SS 2007 Motivation

  5. 5 mögliche Ausdrücke • Objektinstanzierung • Methodenaufruf • Feldzugriff • Casting • Variablenzugriff Analysetechniken in der Softwaretechnik SS 2007 Programmstruktur

  6. Was ist in FJ möglich • gegenseitige rekursive Klassendefinitionen • Methoden überschreiben • Methodenrekursion mit Hilfe von this • Vererbung Analysetechniken in der Softwaretechnik SS 2007 Programmstruktur

  7. Was ist in FJ nicht möglich • Zuweisungen • Interfaces • Überladen • Aufrufe von super • Null-Pointer • Primitive Datentypen Analysetechniken in der Softwaretechnik SS 2007 Programmstruktur

  8. Was ist in FJ nicht möglich • abstrakte Methodendeklarationen • Shadowing von Feldern • Zugriffskontrolle (public, private, etc.) • Exceptions • Fortgeschrittene Techniken Analysetechniken in der Softwaretechnik SS 2007 Programmstruktur

  9. FJ Programm class A extends Object { A() {super();} } class B extends Object { B() {super();} } Analysetechniken in der Softwaretechnik SS 2007 Programmbeispiel

  10. FJ Programm class Pair extends Object { Object fst; Object snd; Pair(Object fst, Object snd) { super(); this.fst=fst; this.snd=snd; } Pair setfst(Object newfst) { return new Pair(newfst, this.snd); } } Analysetechniken in der Softwaretechnik SS 2007 Programmbeispiel

  11. Reduktion new Pair(new A(), new B()).setfst(new B()); newfst  new B() this  new Pair(new A(), new B()) new Pair(newfst, this.snd) new Pair(new B(), new B()) Analysetechniken in der Softwaretechnik SS 2007 Reduktion

  12. Java S Syntax Analysetechniken in der Softwaretechnik SS 2007 Regeln

  13. FJ Syntax L ::= class C extends D { Cf; K M } K ::= C(Cf) {super(f); this.f=f;} M ::= C m(Cx) { return e;} e ::= x | e.f | e.m(e) | new C(e) | (C)e Analysetechniken in der Softwaretechnik SS 2007 Regeln

  14. FJ Vererbung C <: C C <: D D <: E C <: E class C extends D {...} C <: D Analysetechniken in der Softwaretechnik SS 2007 Regeln

  15. ┝ e0 : D D <: C ┝ (C)e0 : C ┝ e0 : D C <: D C  D ┝ (C)e0 : C Casting Regeln Upcast Downcast Analysetechniken in der Softwaretechnik SS 2007 Stupid Cast

  16. Object Upcast Downcast Stupid Cast B A (A)(Object)new B() (A)new B() Analysetechniken in der Softwaretechnik SS 2007 Stupid Cast

  17. ┝ e0 : D D <: C ┝ (C)e0 : C ┝ e0 : D C <: D C  D ┝ (C)e0 : C Stupidcast ┝ e0 : D C <: D D <: C stupid warning ┝ (C)e0 : C Stupid Cast Upcast Downcast Analysetechniken in der Softwaretechnik SS 2007 Stupid Cast

  18. fields(C) = Cf (new C(e)).fi ei Reduktion new Pair(new A(), new B()).snd  new B() Analysetechniken in der Softwaretechnik SS 2007 Regeln

  19. weitere Theoreme : • Progress • Reduction preserves Cast-Safety • Progress of Cast-Save Programs Beweis der Typsicherheit Preservation: Wenn ┝ t : C und t  t‘, dann ┝ t‘ : C‘ für C‘ <: C Analysetechniken in der Softwaretechnik SS 2007 Typsicherheit

  20. Featherweight Generic Java (FGJ) • Featherweight Java um Generics erweitert • FGJ auf FJ zurückgeführt • somit ist FGJ auch typsicher Analysetechniken in der Softwaretechnik SS 2007 FGJ

  21. Schlussfolgerungen • Featherweight Java ist typsicher • stupid casts in Java eingeführt • Typsicherheit auf Generics erweitert und bewiesen • Fehler im Java-Compiler in bezug auf Generics gefunden • Weiterhin erweiterbar Analysetechniken in der Softwaretechnik SS 2007 Schlussfolgerungen

  22. Quellennachweise • Igarashi, A., Pierce, B.C. and Wadler 2002. Featherweight Java: A Minimal Core Calculus for Java and GJ,University of Tokyo, University of Pennsylvania, Avaya Labs • Benjamin C. Pierce / Types and Programming/, MIT Press • 2002.Drossopoulou, S., Eisenbach, S 1997. Java is Type Safe – Probably, London Analysetechniken in der Softwaretechnik SS 2007 Quellennachweise

More Related