SlideShare a Scribd company logo
1 of 61
Методы формальной
верификации
Методы формальной
верификации
… в Java 8
Методы формальной
верификации
… в Java 8
… да и вообще...
Владимир Иванов
Разработчик HotSpot JVM
Александр Ильин
Архитектор тестирования Oracle JDK
Pолевыеигры
Хардкорный девелопер
Тролль из отдела тестирования
Program testing can be used to show the
presence of bugs, but never to show their
absence.
[“Structured programming”, Dahl O.J., Dijkstra E.W. and Hoare C.A.R.]
[When] you have given the proof of [a
program's] correctness, … [you] can
dispense with testing altogether.
[“Software engineering”, Naur P., Randell B.]
(1972)
(1969)
Testing
is
Running the tested software
– in different environment
– with different data
in an attempt to
– Certify conformance
– Prove program correctness
– Prove incorrectness
Just a few years after “Structured programming” ...
We prove … that properly structured tests are
capable of demonstrating the absence of
errors in a program.
[“Toward a Theory of Test Data Selection”, John B. Goodenough, Susan L.
Gerhart] (1975)
Fundamental Test Theorem
Fundamental Test Theorem
COMPLETE(T ,C)=(∀d ∈T OK (d )⇒∀d ∈DOK (d ))∨(∀d ∈T ¬OK (d )⇒∀d ∈D¬OK (d ))
SUCCESSFUL(T )=∀t∈T OK (t)
RELIABLE(C)=(∀T1 ,T2⊂D)COMLPETE (T1 ,C)∧COMPLETE (T2 ,C)⇒
(SUCCESSFUL(T1)≡SUCCESSFUL(T2))
VALID(C)=∀d ∈D¬OK (d)⇒(∃T ⊆D)(COMPLETE (T ,C)∧¬SUCCESSFUL(T ))
∃T⊆D ,∃C
(COMPLETE(T ,C)∧RELIABLE(C)∧VALID(C)∧SUCCESSFUL(T ))⇒
∀d ∈DOK (d)
Program F(d) for domain D
Requirements: OUT(d, F(d)) = OK(d)
Data selection criteria: C
But wait! It's not over yet!
I hope to have convinced you that by its very nature
responsible system design and development must
be an activity of an undeniably mathematical nature.
… programming became an industrial activity at a
moment that the American manager was extremely
fearful of relying on the education and the
intelligence of his company's employees. And
management tried to organize the industrial
programming task in such a way that each
individual programmer would need to think as little
as possible.
[“Why correctness must be a mathematical concern” E. W Dijkstra] (1979)
But wait! It's not over yet!
"Arrogance in computer science is measured in
nano-Dijkstras."
Alan Kay
But wait! It's not over yet!
"Arrogance in computer science is measured in
nano-Dijkstras."
Alan Kay
"… and micro-Kays".
Unknown source ;-)
Testing
is
Running the tested software
– in different environment
– with different data
in an attempt to
– Certify conformance
– Prove program correctness (requires formal proof)
– Prove program incorrectness (practically)
Dynamic
Static testing
is
Analysis of artifacts
– source code
– binaries
– data files
in an attempt to
– discover errors
– identify suspicious patterns
– verify conformance of the artifacts
Static testing
includes
● Using static analyzers
– Big number of false positives
● Code reviews
– Tedious manual work
– Many errors missed
– Non formalizable
What defects
could by found by dynamic testing
Any defect!
You just need to invent enough test :)
only ...
It may take an indefinite amount of tests
So, the testing is, effectively, endless
What defects
could by found by static testing
Any defect!
You just need to look on the whole source long
enough
only ...
You can not know which ones you are detecting
and
You never know how many are left
What defects
are hard to find by dynamic testing
● Intermittent problems
– You may just missed it
● Platform/environment specific problem
– You just may not have the environment
What defects
are hard to find by static analysis
● Bugs in deep and wide class inheritance
– Virtual methods are resolved in runtime
● Bugs in modular system
– Many modules implement the same features,
modules are registered somewhere, etc.
– Same reason – modules are registered as runtime
Formal verification
is
Formal verifi cation is the act of proving or
disproving the correctness of intended algorithms
underlying a system with respect to a certain
formal specifi cation or property, using
formal methods of mathematics.
Formal verification vs Testing
● Testing
– Upper bound for program quality
● Passed test says nothing about quality
● What matters is when test fails
● Formal verification
– Lower bound for program quality
● Passed test guarantees absence of some type of
failures in a program
Formal verification
requires
● Correctness of
– Language
– Compiler
– “Core” of the program
● The specification is self-consistent
Formal verification
applied
boolean isPowerOfTwo(int a) {
return (a&(a-1)) == 0;
}
Formal verification
applied
(a1
…ak
)10....0Let's take a binary representation of a:
m >= 0
a > 0 => binary presentation of a has a least one 1 bit
a-1 = (a1
…ak
)01....1 => a&(a-1) = (a1
…ak
)00....0
m m
a&(a-1) = 0 => a1
,...,ak
= 0 => a = 2m
a = 2n
=> m=n, a1
,...,ak
= 0 => a&(a-1) = 0
∀0<a∈N :a &(a−1)=0⇔∃n∈N :a=2n
Formal verification
is
Formal verifi cation is the act of proving or
disproving the correctness of intended algorithms
underlying a system with respect to a certain
formal specifi cation or property, using
formal methods of mathematics.
Another approach is deductive verifi cation. It
consists of generating from the system and its
specifi cations (and possibly other annotations) a
collection of mathematical proof obligations,
the truth of which imply conformance of the
system to its specifi cation.
Deductive Verification
Theorem proving
● Four color theorem (proved in 1976)
● Curry-Howard isomorphism
– (Theorem, Proof) <=> (Type, Program)
● Theorem provers
– Interactive environments for constructing proofs
– Coq, Agda, Isabelle, HOL
● Real-world example
– COMPCERT: C Verified Compiler
Using tools
how about ...
● We create a program
– Is capable of proving something about another
program
– Is itself proven (yeah, yeah, a recursion)
● Use the program to prove something about
another program
● Let's call it a “prover”
Is this still a formal verification?
Sure!
Formal verification
compiler is a prover on it's own
● Formal verification for Java is performed by
Java compiler
– Types
– Uninitialized variable
– Missing of return statement
– Uncaught exceptions
– etc.
– etc.
Annotations in Java
@Stateless @LocalBean
public class GalleryFacade {
@EJB
private GalleryEAO galleryEAO;
@TransactionAttribute(SUPPORTS)
public Gallery findById(Long id) { ... }
@TransactionAttribute(REQUIRED)
public void create(String name) { … }
Annotations in Java
● Introduced in Java 5
● Metadata
● May be reflective
– SOURCE, CLASS, RUNTIME
● Standard (e.g. @Override) & custom annotations
● Extensively used nowadays
– JavaEE 6, IoC containers, test harnesses, etc
Annotations: pre-Java 8
● Allowed on declarations only
– Class declaration
@A public class Test {
@B private int a = 0;
@C public void m(@D Object o) {
@E int a = 1;
...
}
}
Annotations: pre-Java 8
● Allowed on declarations only
– Field declaration
@A public class Test {
@B private int a = 0;
@C public void m(@D Object o) {
@E int a = 1;
...
}
}
Annotations: pre-Java 8
● Allowed on declarations only
– Method declaration
@A public class Test {
@B private int a = 0;
@C public void m(@D Object o) {
@E int a = 1;
...
}
}
Annotations: pre-Java 8
● Allowed on declarations only
– Method parameter declaration
@A public class Test {
@B private int a = 0;
@C public void m(@D Object o) {
@E int a = 1;
...
}
}
Annotations: pre-Java 8
● Allowed on declarations only
– Local variable declaration
@A public class Test {
@B private int a = 0;
@C public void m(@D Object o) {
@E int a = 1;
...
}
}
Limitations
● Consider @NonNull annotation
● How to declare a Map with non-null keys and
values?
Limitations
● Consider @NonNull annotation
● How to declare a Map with non-null keys and
values?
@NonNull Map<K,V>?
Limitations
● Consider @NonNull annotation
● How to declare a Map with non-null keys and
values?
@NonNull Map<K,V>?
NO!
Limitations
● Consider @NonNull annotation
● How to declare a Map with non-null keys and
values?
@NonNull Map<K,V>?
NO!
● Map<@NonNull K, @NonNull V>
… but incorrect in Java 7 and earlier
Type annotations in Java 8 for the rescue!
Type annotations in Java 8
● Allowed anywhere you would write a type
… including generics and casts
… for array levels and receivers
Type annotations in Java 8:
Examples
● Class inheritance
class UnmodifiableList<T>
implements @ReadOnly List<T> { ... }
● Casts
myDate = (@ReadOnly Date) roDate;
● Type tests
myString instanceof @NonNull String;
● Arrays
String @NonNull [] messages;
Type annotations in Java 8:
Examples
● Generics
List<@Interned String> messages;
● Type parameter bounds
Collection<? super @Exists File>
● Generic type arguments in a generic method
o.<@NonNull String>toString("...");
Pluggable types
● User-defined (pluggable) type system
● Extend built-in type system
– express extra information about types via
type qualifiers
● Permit more expressive compile-time checking
and guarantee the absence of additional errors
Checker Framework
● Collection of compiler plugins (“checkers”)
● Relies on Pluggable types and Type
Annotations in Java 8
● Find different sorts of bugs or verify their
absence
– 14 checkers are already provided
● Supports custom compiler plugins (provides
API)
– 5 third-party checkers
Example: Nullness Checker
● Annotations
– @NonNull
– @Nullable
● Partial type hierarchy
Example: Nullness Checker
● Annotations
– @NonNull
– @Nullable
● Example:
@Nullable Object o1; // might be null
@NonNull Object o2; // never null
o1.toString(); // warning
o2 = o1; // warning
if (o2 == null) // warning: redundant test
Example: Nullness Checker
● Annotations
– @NonNull
– @Nullable
● Example:
public <@NonNull T> T process(T);
Example: Tainting Checker
● Use case:
– Trusted vs untrusted data
– Verify before use
● Examples
– SQL injection attack
● validate SQL query before executing it
– information leakage
● secret data vs data displayed to a user
Example: Tainting Checker
● Annotations
– @Untainted
● A type that includes only untainted, trusted values
– @Tainted
● A type that includes only tainted, untrusted values
Example: Tainting Checker
● Annotations
– @Untainted
– @Tainted
● Example
void execute(@Untainted String sql)
throws SQLException;
@Untainted String validate(@Tainted String)
throws SQLException;
Credit card number
Annotation
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE,
ElementType.TYPE_PARAMETER})
@TypeQualifier
@SubtypeOf(Unqualified.class)
public @interface CreditCard {}
Credit card number
Checker
@TypeQualifiers(CreditCard.class)
@SuppressWarningsKey("credit.card")
public class CreditCardChecker
extends BaseTypeChecker {
…
}
Credit card number
Usage
public class Account {
private final @CreditCard String cardNumber;
public Account(@CreditCard String number) {
this.cardNumber = number;
}
public @CreditCard String getCardNumber() {
return cardNumber;
}
}
Credit card number
Sources
@SuppressWarnings("credit.card")
@CreditCard String convert(String input) {
if(checkLuhn(input))
return input;
else
throw IllegalArgumentException("...")
}
new Account("4111111111111111");
new Account("4111111111111110");
Credit card number
Conclusion
● A card number in an account is always validated
● That is guaranteed at compile time
● You do not need to test with invalid numbers
● You do need to test
– All @SuppressWarnings("credit.card")
– checkLuhn(String cardNum)
● Better all … prove it!
More real life examples
String getProperty(@PropertyKey String key);
HashMap <@Adult Person, @NonNull Address>
findSobutylnik(@NonNull Location);
void monitorTemperature()
throws @Critical TemperatureException;
Checkers Framework:
Advanced features
● Linear checker
– Implements linear types (based on linear logic)
– control aliasing and prevent re-use
– Single ownership abstraction
● Prevents absence of ownership and multiple owners
● Dependent types
– @Dependent annotation
– Changes the type depending on qualified type of
the receiver (this)
– Example
List[N] – list with it's length encoded into it's type
How to start using
● No need to wait Java 8 release
– modified compiler already available
● Incremental program annotation
– Partial program checking
– Warnings during compilation
– Easily convertible into compilation errors
● -Werror flag to javac
– Default annotations for types w/o annotations
● Ability to annotate external libraries
Links
● Type Annotations Specification (JSR-308)
http://types.cs.washington.edu/jsr308/specification/java-
● Checker Framework
http://types.cs.washington.edu/checker-framework/curre
Q&A
Владимир Иванов
Александр Ильин
vladimir.x.ivanov@oracle.com
alexandre.iline@oracle.com
Formal verification vs Testing
b02 b03 b04 b05 b06 b07 b08b01
Defects

More Related Content

What's hot

Java 8 and beyond, a scala story
Java 8 and beyond, a scala storyJava 8 and beyond, a scala story
Java 8 and beyond, a scala storyittaiz
 
Testing untestable code - STPCon11
Testing untestable code - STPCon11Testing untestable code - STPCon11
Testing untestable code - STPCon11Stephan Hochdörfer
 
Java 8 best practices - Stephen Colebourne
Java 8 best practices - Stephen ColebourneJava 8 best practices - Stephen Colebourne
Java 8 best practices - Stephen ColebourneJAXLondon_Conference
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsGanesh Samarthyam
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkHumberto Marchezi
 
Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to AgileAnton Keks
 
Finding bugs that matter with Findbugs
Finding bugs that matter with FindbugsFinding bugs that matter with Findbugs
Finding bugs that matter with FindbugsCarol McDonald
 
Testing untestable code - PHPBNL11
Testing untestable code - PHPBNL11Testing untestable code - PHPBNL11
Testing untestable code - PHPBNL11Stephan Hochdörfer
 
findbugs Bernhard Merkle
findbugs Bernhard Merklefindbugs Bernhard Merkle
findbugs Bernhard Merklebmerkle
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 

What's hot (20)

Java 8 and beyond, a scala story
Java 8 and beyond, a scala storyJava 8 and beyond, a scala story
Java 8 and beyond, a scala story
 
Testing untestable code - STPCon11
Testing untestable code - STPCon11Testing untestable code - STPCon11
Testing untestable code - STPCon11
 
Java 8 best practices - Stephen Colebourne
Java 8 best practices - Stephen ColebourneJava 8 best practices - Stephen Colebourne
Java 8 best practices - Stephen Colebourne
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing Framework
 
Basic java for Android Developer
Basic java for Android DeveloperBasic java for Android Developer
Basic java for Android Developer
 
Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to Agile
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
 
Finding bugs that matter with Findbugs
Finding bugs that matter with FindbugsFinding bugs that matter with Findbugs
Finding bugs that matter with Findbugs
 
Spring IO 2015 Spock Workshop
Spring IO 2015 Spock WorkshopSpring IO 2015 Spock Workshop
Spring IO 2015 Spock Workshop
 
Grails Spock Testing
Grails Spock TestingGrails Spock Testing
Grails Spock Testing
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Testing untestable code - PHPBNL11
Testing untestable code - PHPBNL11Testing untestable code - PHPBNL11
Testing untestable code - PHPBNL11
 
findbugs Bernhard Merkle
findbugs Bernhard Merklefindbugs Bernhard Merkle
findbugs Bernhard Merkle
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Java Reflection @KonaTechAdda
Java Reflection @KonaTechAddaJava Reflection @KonaTechAdda
Java Reflection @KonaTechAdda
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 

Similar to Formal verification methods in Java 8

DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)Steve Upton
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017XavierDevroey
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 
Java Intro
Java IntroJava Intro
Java Introbackdoor
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for seleniumapoorvams
 
Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error predictionNIKHIL NAWATHE
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introductionchnrketan
 
PVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniquePVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniqueAndrey Karpov
 
May: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesMay: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesTriTAUG
 
core java programming
core java programmingcore java programming
core java programmingAnnu Raj
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basicsLovelitJose
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101kankemwa Ishaku
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014Shyam Sarkar
 

Similar to Formal verification methods in Java 8 (20)

DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
Unit 1
Unit 1Unit 1
Unit 1
 
Software testing: an introduction - 2017
Software testing: an introduction - 2017Software testing: an introduction - 2017
Software testing: an introduction - 2017
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
java slides
java slidesjava slides
java slides
 
Java Intro
Java IntroJava Intro
Java Intro
 
Java basic
Java basicJava basic
Java basic
 
Java 101
Java 101Java 101
Java 101
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error prediction
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
 
PVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniquePVS-Studio and static code analysis technique
PVS-Studio and static code analysis technique
 
May: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesMay: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and Challenges
 
core java programming
core java programmingcore java programming
core java programming
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
Unit test
Unit testUnit test
Unit test
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014Cancer genomics big_datascience_meetup_july_14_2014
Cancer genomics big_datascience_meetup_july_14_2014
 

More from Vladimir Ivanov

"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia Vladimir Ivanov
 
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine "Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine Vladimir Ivanov
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, UkraineVladimir Ivanov
 
JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013Vladimir Ivanov
 
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013Vladimir Ivanov
 
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012Vladimir Ivanov
 
Управление памятью в Java: Footprint
Управление памятью в Java: FootprintУправление памятью в Java: Footprint
Управление памятью в Java: FootprintVladimir Ivanov
 
Многоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVMМногоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVMVladimir Ivanov
 
G1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage CollectorG1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage CollectorVladimir Ivanov
 
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)Vladimir Ivanov
 

More from Vladimir Ivanov (10)

"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia "What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
"What's New in HotSpot JVM 8" @ JPoint 2014, Moscow, Russia
 
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine "Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
"Optimizing Memory Footprint in Java" @ JEEConf 2013, Kiev, Ukraine
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
 
JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013JVM JIT-compiler overview @ JavaOne Moscow 2013
JVM JIT-compiler overview @ JavaOne Moscow 2013
 
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
"Invokedynamic: роскошь или необходимость?"@ JavaOne Moscow 2013
 
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
"G1 GC и Обзор сборки мусора в HotSpot JVM" @ JUG SPb, 31-05-2012
 
Управление памятью в Java: Footprint
Управление памятью в Java: FootprintУправление памятью в Java: Footprint
Управление памятью в Java: Footprint
 
Многоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVMМногоуровневая компиляция в HotSpot JVM
Многоуровневая компиляция в HotSpot JVM
 
G1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage CollectorG1 GC: Garbage-First Garbage Collector
G1 GC: Garbage-First Garbage Collector
 
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
"Диагностирование проблем и настройка GC в HotSpot JVM" (JEEConf, Киев, 2011)
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Formal verification methods in Java 8

  • 4. Владимир Иванов Разработчик HotSpot JVM Александр Ильин Архитектор тестирования Oracle JDK Pолевыеигры Хардкорный девелопер Тролль из отдела тестирования
  • 5. Program testing can be used to show the presence of bugs, but never to show their absence. [“Structured programming”, Dahl O.J., Dijkstra E.W. and Hoare C.A.R.] [When] you have given the proof of [a program's] correctness, … [you] can dispense with testing altogether. [“Software engineering”, Naur P., Randell B.] (1972) (1969)
  • 6. Testing is Running the tested software – in different environment – with different data in an attempt to – Certify conformance – Prove program correctness – Prove incorrectness
  • 7. Just a few years after “Structured programming” ... We prove … that properly structured tests are capable of demonstrating the absence of errors in a program. [“Toward a Theory of Test Data Selection”, John B. Goodenough, Susan L. Gerhart] (1975) Fundamental Test Theorem
  • 8. Fundamental Test Theorem COMPLETE(T ,C)=(∀d ∈T OK (d )⇒∀d ∈DOK (d ))∨(∀d ∈T ¬OK (d )⇒∀d ∈D¬OK (d )) SUCCESSFUL(T )=∀t∈T OK (t) RELIABLE(C)=(∀T1 ,T2⊂D)COMLPETE (T1 ,C)∧COMPLETE (T2 ,C)⇒ (SUCCESSFUL(T1)≡SUCCESSFUL(T2)) VALID(C)=∀d ∈D¬OK (d)⇒(∃T ⊆D)(COMPLETE (T ,C)∧¬SUCCESSFUL(T )) ∃T⊆D ,∃C (COMPLETE(T ,C)∧RELIABLE(C)∧VALID(C)∧SUCCESSFUL(T ))⇒ ∀d ∈DOK (d) Program F(d) for domain D Requirements: OUT(d, F(d)) = OK(d) Data selection criteria: C
  • 9. But wait! It's not over yet! I hope to have convinced you that by its very nature responsible system design and development must be an activity of an undeniably mathematical nature. … programming became an industrial activity at a moment that the American manager was extremely fearful of relying on the education and the intelligence of his company's employees. And management tried to organize the industrial programming task in such a way that each individual programmer would need to think as little as possible. [“Why correctness must be a mathematical concern” E. W Dijkstra] (1979)
  • 10. But wait! It's not over yet! "Arrogance in computer science is measured in nano-Dijkstras." Alan Kay
  • 11. But wait! It's not over yet! "Arrogance in computer science is measured in nano-Dijkstras." Alan Kay "… and micro-Kays". Unknown source ;-)
  • 12. Testing is Running the tested software – in different environment – with different data in an attempt to – Certify conformance – Prove program correctness (requires formal proof) – Prove program incorrectness (practically) Dynamic
  • 13. Static testing is Analysis of artifacts – source code – binaries – data files in an attempt to – discover errors – identify suspicious patterns – verify conformance of the artifacts
  • 14. Static testing includes ● Using static analyzers – Big number of false positives ● Code reviews – Tedious manual work – Many errors missed – Non formalizable
  • 15. What defects could by found by dynamic testing Any defect! You just need to invent enough test :) only ... It may take an indefinite amount of tests So, the testing is, effectively, endless
  • 16. What defects could by found by static testing Any defect! You just need to look on the whole source long enough only ... You can not know which ones you are detecting and You never know how many are left
  • 17. What defects are hard to find by dynamic testing ● Intermittent problems – You may just missed it ● Platform/environment specific problem – You just may not have the environment
  • 18. What defects are hard to find by static analysis ● Bugs in deep and wide class inheritance – Virtual methods are resolved in runtime ● Bugs in modular system – Many modules implement the same features, modules are registered somewhere, etc. – Same reason – modules are registered as runtime
  • 19. Formal verification is Formal verifi cation is the act of proving or disproving the correctness of intended algorithms underlying a system with respect to a certain formal specifi cation or property, using formal methods of mathematics.
  • 20. Formal verification vs Testing ● Testing – Upper bound for program quality ● Passed test says nothing about quality ● What matters is when test fails ● Formal verification – Lower bound for program quality ● Passed test guarantees absence of some type of failures in a program
  • 21. Formal verification requires ● Correctness of – Language – Compiler – “Core” of the program ● The specification is self-consistent
  • 23. Formal verification applied (a1 …ak )10....0Let's take a binary representation of a: m >= 0 a > 0 => binary presentation of a has a least one 1 bit a-1 = (a1 …ak )01....1 => a&(a-1) = (a1 …ak )00....0 m m a&(a-1) = 0 => a1 ,...,ak = 0 => a = 2m a = 2n => m=n, a1 ,...,ak = 0 => a&(a-1) = 0 ∀0<a∈N :a &(a−1)=0⇔∃n∈N :a=2n
  • 24. Formal verification is Formal verifi cation is the act of proving or disproving the correctness of intended algorithms underlying a system with respect to a certain formal specifi cation or property, using formal methods of mathematics. Another approach is deductive verifi cation. It consists of generating from the system and its specifi cations (and possibly other annotations) a collection of mathematical proof obligations, the truth of which imply conformance of the system to its specifi cation.
  • 25. Deductive Verification Theorem proving ● Four color theorem (proved in 1976) ● Curry-Howard isomorphism – (Theorem, Proof) <=> (Type, Program) ● Theorem provers – Interactive environments for constructing proofs – Coq, Agda, Isabelle, HOL ● Real-world example – COMPCERT: C Verified Compiler
  • 26. Using tools how about ... ● We create a program – Is capable of proving something about another program – Is itself proven (yeah, yeah, a recursion) ● Use the program to prove something about another program ● Let's call it a “prover” Is this still a formal verification? Sure!
  • 27. Formal verification compiler is a prover on it's own ● Formal verification for Java is performed by Java compiler – Types – Uninitialized variable – Missing of return statement – Uncaught exceptions – etc. – etc.
  • 28. Annotations in Java @Stateless @LocalBean public class GalleryFacade { @EJB private GalleryEAO galleryEAO; @TransactionAttribute(SUPPORTS) public Gallery findById(Long id) { ... } @TransactionAttribute(REQUIRED) public void create(String name) { … }
  • 29. Annotations in Java ● Introduced in Java 5 ● Metadata ● May be reflective – SOURCE, CLASS, RUNTIME ● Standard (e.g. @Override) & custom annotations ● Extensively used nowadays – JavaEE 6, IoC containers, test harnesses, etc
  • 30. Annotations: pre-Java 8 ● Allowed on declarations only – Class declaration @A public class Test { @B private int a = 0; @C public void m(@D Object o) { @E int a = 1; ... } }
  • 31. Annotations: pre-Java 8 ● Allowed on declarations only – Field declaration @A public class Test { @B private int a = 0; @C public void m(@D Object o) { @E int a = 1; ... } }
  • 32. Annotations: pre-Java 8 ● Allowed on declarations only – Method declaration @A public class Test { @B private int a = 0; @C public void m(@D Object o) { @E int a = 1; ... } }
  • 33. Annotations: pre-Java 8 ● Allowed on declarations only – Method parameter declaration @A public class Test { @B private int a = 0; @C public void m(@D Object o) { @E int a = 1; ... } }
  • 34. Annotations: pre-Java 8 ● Allowed on declarations only – Local variable declaration @A public class Test { @B private int a = 0; @C public void m(@D Object o) { @E int a = 1; ... } }
  • 35. Limitations ● Consider @NonNull annotation ● How to declare a Map with non-null keys and values?
  • 36. Limitations ● Consider @NonNull annotation ● How to declare a Map with non-null keys and values? @NonNull Map<K,V>?
  • 37. Limitations ● Consider @NonNull annotation ● How to declare a Map with non-null keys and values? @NonNull Map<K,V>? NO!
  • 38. Limitations ● Consider @NonNull annotation ● How to declare a Map with non-null keys and values? @NonNull Map<K,V>? NO! ● Map<@NonNull K, @NonNull V> … but incorrect in Java 7 and earlier Type annotations in Java 8 for the rescue!
  • 39. Type annotations in Java 8 ● Allowed anywhere you would write a type … including generics and casts … for array levels and receivers
  • 40. Type annotations in Java 8: Examples ● Class inheritance class UnmodifiableList<T> implements @ReadOnly List<T> { ... } ● Casts myDate = (@ReadOnly Date) roDate; ● Type tests myString instanceof @NonNull String; ● Arrays String @NonNull [] messages;
  • 41. Type annotations in Java 8: Examples ● Generics List<@Interned String> messages; ● Type parameter bounds Collection<? super @Exists File> ● Generic type arguments in a generic method o.<@NonNull String>toString("...");
  • 42. Pluggable types ● User-defined (pluggable) type system ● Extend built-in type system – express extra information about types via type qualifiers ● Permit more expressive compile-time checking and guarantee the absence of additional errors
  • 43. Checker Framework ● Collection of compiler plugins (“checkers”) ● Relies on Pluggable types and Type Annotations in Java 8 ● Find different sorts of bugs or verify their absence – 14 checkers are already provided ● Supports custom compiler plugins (provides API) – 5 third-party checkers
  • 44. Example: Nullness Checker ● Annotations – @NonNull – @Nullable ● Partial type hierarchy
  • 45. Example: Nullness Checker ● Annotations – @NonNull – @Nullable ● Example: @Nullable Object o1; // might be null @NonNull Object o2; // never null o1.toString(); // warning o2 = o1; // warning if (o2 == null) // warning: redundant test
  • 46. Example: Nullness Checker ● Annotations – @NonNull – @Nullable ● Example: public <@NonNull T> T process(T);
  • 47. Example: Tainting Checker ● Use case: – Trusted vs untrusted data – Verify before use ● Examples – SQL injection attack ● validate SQL query before executing it – information leakage ● secret data vs data displayed to a user
  • 48. Example: Tainting Checker ● Annotations – @Untainted ● A type that includes only untainted, trusted values – @Tainted ● A type that includes only tainted, untrusted values
  • 49. Example: Tainting Checker ● Annotations – @Untainted – @Tainted ● Example void execute(@Untainted String sql) throws SQLException; @Untainted String validate(@Tainted String) throws SQLException;
  • 52. Credit card number Usage public class Account { private final @CreditCard String cardNumber; public Account(@CreditCard String number) { this.cardNumber = number; } public @CreditCard String getCardNumber() { return cardNumber; } }
  • 53. Credit card number Sources @SuppressWarnings("credit.card") @CreditCard String convert(String input) { if(checkLuhn(input)) return input; else throw IllegalArgumentException("...") } new Account("4111111111111111"); new Account("4111111111111110");
  • 54. Credit card number Conclusion ● A card number in an account is always validated ● That is guaranteed at compile time ● You do not need to test with invalid numbers ● You do need to test – All @SuppressWarnings("credit.card") – checkLuhn(String cardNum) ● Better all … prove it!
  • 55. More real life examples String getProperty(@PropertyKey String key); HashMap <@Adult Person, @NonNull Address> findSobutylnik(@NonNull Location); void monitorTemperature() throws @Critical TemperatureException;
  • 56. Checkers Framework: Advanced features ● Linear checker – Implements linear types (based on linear logic) – control aliasing and prevent re-use – Single ownership abstraction ● Prevents absence of ownership and multiple owners ● Dependent types – @Dependent annotation – Changes the type depending on qualified type of the receiver (this) – Example List[N] – list with it's length encoded into it's type
  • 57. How to start using ● No need to wait Java 8 release – modified compiler already available ● Incremental program annotation – Partial program checking – Warnings during compilation – Easily convertible into compilation errors ● -Werror flag to javac – Default annotations for types w/o annotations ● Ability to annotate external libraries
  • 58. Links ● Type Annotations Specification (JSR-308) http://types.cs.washington.edu/jsr308/specification/java- ● Checker Framework http://types.cs.washington.edu/checker-framework/curre
  • 59. Q&A
  • 61. Formal verification vs Testing b02 b03 b04 b05 b06 b07 b08b01 Defects