1 / 10

A state abstraction for Java

A state abstraction for Java. Ferruccio Damiani, Paola Giannini, Sophia Drossopoulou, Nick Cameron, Elena Giachino Presentation by Nick Cameron ncameron@doc.ic.ac.uk Imperial College London. Implicit state. Object a. Object a. m. m. m(). Some internal change. time. { while (…) {

refugioa
Download Presentation

A state abstraction for 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. A state abstraction for Java Ferruccio Damiani, Paola Giannini, Sophia Drossopoulou, Nick Cameron, Elena Giachino Presentation by Nick Cameron ncameron@doc.ic.ac.uk Imperial College London

  2. Implicit state Object a Object a m m m() Some internal change time Nicholas Cameron DoC Imperial College 2006

  3. { while (…) { try { this.wait(); } catch (…) {…} } … } { … this.notifyAll(); } Implicit state • Hard to program • Non-intuitive • Lack of abstraction • Error prone • Missed statements • Boilerplate • Mixes functionality with coordination code Nicholas Cameron DoC Imperial College 2006

  4. Explicit state Object a Object a s1 s1 m1() m1 m1 s2 s2 m2() m2 m2 as2 time Nicholas Cameron DoC Imperial College 2006

  5. StateJ class C { String f1; state s1 { void m1() {…} } state s2 { void m1() {…} void m2() {…} } void m3() {…} } Nicholas Cameron DoC Imperial College 2006

  6. StateJ { this!!s2; this!!previous; } state s2 { void m() as s1 } Nicholas Cameron DoC Imperial College 2006

  7. Case studies Java, StateJ, Chords Buffer reader/writer lock Latch Santa Claus problem Submarine Radar problem … Class Buffer { state full { void put(Object o) as partial } state empty { Object get() as partial } state partial { void put (Object o) {…} Object get() {…} } } Programming with StateJ Nicholas Cameron DoC Imperial College 2006

  8. Implementation and Formal System • Formal system extends Featherweight Java • Multiple threads • States, state change statement, spawn statement • Type sound • Implementation - compiler • Compiles (large) subset of Java + states to Java • Inheritance Nicholas Cameron DoC Imperial College 2006

  9. Current work • States can have fields state s1 (int n) {…} this!!s1(x); • Effect system to ensure fields are not accessed outside the correct state • Improving the StateJ compiler • Further case studies Nicholas Cameron DoC Imperial College 2006

  10. Conclusion • Explicit states makes it easier to write concurrent programs. • Objects have state, method dispatch depends on current state. • Type safe formal system and compiler. • Ongoing work… Nicholas Cameron DoC Imperial College 2006

More Related