Download presentation
Presentation is loading. Please wait.
1
Transformation of Java Card into Diet Java Semester Project Presentation Erich Laube
2
Overview 1. Introduction to Jive and Background 2. Transformation Basics 3. Examples 4. Future Work 5. 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 try { // something } catch (Exception1 e1){ // handler1 } catch (Exception2 e2){ // handler2 } try{ // something } catch (Exception1 e1){ // handler1 } catch (Exception2 e2){ // handler2 } Only one Catch per Try done in Grammar file
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||cond){ if (x) break; b = false }} { boolean b = true while (b){ if (x) break; b = cond; }
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; void °cK(int i){ super.°cM(i); f = i; } void °cK(){ °cK(2); } Class K extends M{ int f = 2; K(int i){ super(i); f = i; } K(){ this(f); } 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
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.