Transformation of Java Card into Diet Java Semester Project Presentation Erich Laube.

Slides:



Advertisements
Similar presentations
CPSC 388 – Compiler Design and Construction
Advertisements

Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
Written by: Dr. JJ Shepherd
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
12. Common Errors, a few Puzzles. © O. Nierstrasz P2 — Common Errors, a few Puzzles 12.2 Common Errors, a few Puzzles Overview  Common errors … —Typical.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
Conditions What if?. Flow of Control The order of statement execution is called the flow of control Unless specified otherwise, the order of statement.
Loops – While, Do, For Repetition Statements Introduction to Arrays
12. Common Errors, a few Puzzles. © O. Nierstrasz P2 — Common Errors, a few Puzzles 12.2 Common Errors, a few Puzzles Sources  Cay Horstmann, Computing.
SMIILE Finaly COBOL! and what else is new Gordana Rakić, Zoran Budimac.
C++ for Engineers and Scientists Third Edition
Arrays, Conditionals & Loops in Java. Arrays in Java Arrays in Java, are a way to store collections of items into a single unit. The array has some number.
UNIT II Decision Making And Branching Decision Making And Looping
Introduction to Java and Software Design Dale Weems Headington Chapter 10 Additional Control Structures and Exceptions Slides by Sylvia Sorkin, The Community.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
Language Evaluation Criteria
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Java. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects It’s platform independent.
Exception Handling. Exceptions and Errors When a problem encounters and unexpected termination or fault, it is called an exception When we try and divide.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 18 Exception Handling.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
Compositional correctness of IP-based system design: Translating C/C++ Models into SIGNAL Processes Rennes, November 04, 2005 Hamoudi Kalla and Jean-Pierre.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
The Java Programming Language
1 Top Down Parsing. CS 412/413 Spring 2008Introduction to Compilers2 Outline Top-down parsing SLL(1) grammars Transforming a grammar into SLL(1) form.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
CS412/413 Introduction to Compilers and Translators Spring ’99 Lecture 8: Semantic Analysis and Symbol Tables.
Exception Handling Unit-6. Introduction An exception is a problem that arises during the execution of a program. An exception can occur for many different.
BUILD ON THE POLYGLOT COMPILER FRAMEWORK MIHAL BRUMBULLI 7th Workshop “SEERE” Montenegro-Risan 9-14 September 2007 SimJ Programming Language.
COP-3330: Object Oriented Programming Flow Control May 16, 2012 Eng. Hector M Lugo-Cordero, MS.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
J AVA P ROGRAMMING 2 C H 03: C ONTROL STATEMENTS if, for loop (review) switch, while, do while break, continue Fall Java Programming.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Decision Making and Branching (cont.)
CS412/413 Introduction to Compilers Radu Rugina Lecture 13 : Static Semantics 18 Feb 02.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Written by: Dr. JJ Shepherd
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CSE 501N Fall ’09 07: Iteration 17 September 2009 Nick Leidenfrost.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Lecture 5:Interfaces and Abstract Classes Michael Hsu CSULA.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
Lecture 6:Interfaces and Abstract Classes Michael Hsu CSULA.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
An Algorithm for Detecting and Removing Clones in Java Code Nicolas Juillerat & Béat Hirsbrunner Pervasive and Artificial Intelligence ( ) Research Group,
Chapter 4 Repetition Statements (loops)
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Indexer AKEEL AHMED.
Compiling, Assembling and Executing Java using Java
null, true, and false are also reserved.
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
Professor Jodi Neely-Ritz CGS3460
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Chap 2. Identifiers, Keywords, and Types
Loops CGS3416 Spring 2019 Lecture 7.
Looping and Repetition
Presentation transcript:

Transformation of Java Card into Diet Java Semester Project Presentation Erich Laube

Overview 1. Introduction to Jive and Background 2. Transformation Basics 3. Examples 4. Future Work 5. Conclusion

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

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

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

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

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

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; }

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

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); }

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

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

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)

Questions...?

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

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