Integration of Java Generics Into The jmle Tool Within Th PowerPoint PPT Presentation

presentation player overlay
1 / 15
About This Presentation
Transcript and Presenter's Notes

Title: Integration of Java Generics Into The jmle Tool Within Th


1
Integration of Java Generics Into The jmle Tool
Within The Eclipse IDE
  • Adrian Kostrubiak
  • 9/16/08

2
Overview
  • Background
  • Java Generics
  • What is JML?
  • The jmle tool
  • Moving Forward

3
Collections Without Generics
  • LinkedList list new LinkedList()
  • list.add(one) list.add(two)
  • String first (String)list.get(1)
  • Integer second (Integer)list.get(2)
  • Compiles perfectly fine.
  • However, this results in a ClassCastException!!

4
Collections With Generics
  • LinkedListltStringgt list new
  • LinkedListltStringgt()
  • list.add(one) list.add(two)
  • String first list.get(1)
  • Integer second list.get(2)
  • This will not compile!

5
Benefits To Using Generics
  • Compile time safety checks
  • Eliminates possibility of runtime errors
  • No more unnecessary type casting
  • Clearer code

6
JML
  • Java Modeling Language
  • Exists in annotations before code modules
  • Behavioral interface specification language
  • Formally specify module behavior
  • Design by Contract (DbC)
  • Java style syntax

7
JML Code Example
  • /_at_ assignable \nothing
  • ensures \result j k /
  • int sumOfTwo(int j, int k) return(jk)
  • /_at_ assignable myVal
  • requires j gt 0
  • ensures myVal \old(myVal) - j /
  • void subtract(int j) myVal myVal - j

8
JML Specification Language
  • Formal language
  • Used in system design, requirement and system
    analysis
  • Not executable
  • Higher level than code being described

9
JML DbC
  • Preconditions - whats expected
  • requires
  • Postconditions - whats changed
  • ensures
  • Class invariants - whats the same
  • invariant

10
JML Not perfect.
  • Not executable on its own
  • No support for generics (yet)
  • Takes time to create a proper contract

11
The jmle Tool
  • Takes code with JML embedded
  • Creates a Java constraint program
  • Executed with the Java Constraint Kit

12
The jmle Tool Why?
  • Cant run JML code on its own
  • Good to be able to easily check if a program is
    meeting its contract
  • With JCK, everything is in Java - its easy

13
jmle In Eclipse
  • Program itself not run
  • Runs constraint program
  • Eases checking and understanding of constraints

14
Moving Forward
  • Currently no generic support in JML and jmle
  • Implementing generics
  • Push jmle from mere academic pursuit into actual
    industry

15
Conclusions
  • Generics are essential
  • Addition of generics to JML makes it appealing
  • Could even be used in industry
Write a Comment
User Comments (0)
About PowerShow.com