1 / 16

Transformation of Java Card into Diet Java

Semester Project Presentation. Transformation of Java Card into Diet Java. Erich Laube <laubee@student.ethz.ch>. Overview. Introduction to Jive and Background Transformation Basics Examples Future Work Conclusion. Jive. Java Interactive Verification Environment

dmitri
Télécharger la présentation

Transformation of Java Card into Diet 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. Semester Project Presentation Transformation of Java Card into Diet Java • Erich Laube <laubee@student.ethz.ch>

  2. Overview Introduction to Jive and Background Transformation Basics Examples Future Work Conclusion

  3. Jive Java Interactive Verification Environment Code (Java) vs. Specification (JML) Diet Java

  4. Goals • Transformation of forbidden constructs. • Reporting errors at compile time for constructs that are not transformed.

  5. Involved Tools • ANTLR • parser, lexer • Abstract Syntax Tree (AST) • Multijava • java compiler • static checks, type information • JML • Multijava enhanced with JML

  6. Difficulties • Tracking (nested Expressions) • Still knowing where one is • Execution order • Genericity • Constructs forbidden in program but allowed in specification part • large amount of node classes • non-uniform node layout

  7. Try-Catch • Only one Catch per Try • done in Grammar file try { // something } catch (Exception1 e1){ // handler1 } catch (Exception2 e2){ // handler2 } try{ try { // something } catch (Exception1 e1){ // handler1 } } catch (Exception2 e2){ // handler2 }

  8. Do While => While do { [body] } while (cond) [body] while (cond){ [body] } do { if (x) break; } while (cond) if (x) break; while (cond){ if (x) break; } { boolean b = true while (b){ if (x) break; b = cond; } } { boolean b = true while (b||cond){ if (x) break; b = false }}

  9. Constructors • conversion to method: • alter all constructor calls • find them, spread all over the code • call constructor of super method • create default constructor method • but only if no other constructor specified • special case: this() calls • call the initializer method (not always there) • also needs a JML specification

  10. Constructor conversion example Class K extends M{ int f; K(int i){ super(i); f = i; } K(){ this(2); } } Class K extends M{ int f = 2; K(int i){ super(i); f = i; } K(){ this(f); } } Class K extends M{ int f; void °cK(int i){ super.°cM(i); f = i; } void °cK(){ °cK(2); } } Class K extends M{ int f; °inst_init(){ f = 2; } void °cK(int i){ °inst_init(); super.°cM(i); f = i; } void °cK(){ °inst_init(); °cK(f); } } Class K extends M{ int f; boolean °init; void°inst_init(){ if (°init){} else { f = 2; °init = true; }} void °cK(int i){ super.°cM(i); °inst_init(); f = i;} void °cK(){ °inst_init(); °cK(f); } }

  11. Future Work • Remaining Transformations • non-strict operators • pre- and postfix operators (++,--) • inner classes • Optimizations: • reuse temporary variables • simple trafos for simple cases

  12. Conclusion • Many constructs covered • Mangled code: • difficult for user to still understand • Interesting and complex project

  13. Implemented Transformations • constructors • nonstatic initializers • variable initializers • local variables only at beginning of blocks • short if, for and do-loops, switch-blocks • multiple catch blocks for a try-block • casts within expressions • array access within expressions • compound assignment • assignment within expressions • assignments with side effects (partially) • pre- and postfix operators (partially)

  14. Questions...?

  15. Grammar File (ANTLR) • Passes every code construct • No Type Information • Also affects JML part • Work done here: • finding and forbidding • types • simple transformations • If-then-else • Try-catch

  16. Abstract Syntax Tree (Multijava) • Statements • can hold more Statements • can hold Expressions • Expressions • never hold Statements • can hold further Expressions

More Related