SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
GenevaJug
#sonarqube
DIY:
Java Static Analysis
Nicolas PERU - @benzonico
Michael GUMOWSKI - @m-g-sonar
Ego boost
● Nicolas PERU - @benzonico
○ Java developer@SonarSource
○ Developer in language team
○ Lead of sonar java plugin
○ Geneva Jug enthusiast
● Michael GUMOWSKI
○ Java developer@SonarSource
○ Developer in language team
○ Run half marathon in 1h24
Static Analysis
Analyze code,
without executing it.
● Back Story
Sonar Java Plugin
Challenge
Get the language.
Lexical Analysis
Only two things are infinite, the universe and human
stupidity, and I am not sure about the former.
Syntactic Analysis
Only two things are infinite, the universe and human
stupidity, and I am not sure about the former.
Albert E.
Subjects Verbs
Lexical Analysis
class A {
int b;
}
Syntactic Analysis
class A {
int b;
}
Keywords
Identifiers
punctuators
Syntax Tree
+
3
21
+
1 + 2 + 3
interface BinaryExpressionTree {
ExpressionTree leftOperand();
SyntaxToken operatorToken();
ExpressionTree rightOperand();
}
Java pop quizz !!
[ ]
[ ] ) [ ] [ ] {
int[ ] foo(int a[ ] ) [ ] [ ] {
return null;
}
int[ ] foo(int a[ ] ) [ ] [ ] {
return null;
}
int[ ][ ][ ] foo(int[ ] a) {
return null;
}
Semantic Analysis
Only two things are infinite, the universe and human
stupidity, and I am not sure about the former.
Albert E.
Semantic Analysis
Only two things are infinite, the universe and human
stupidity, and I am not sure about the former.
Albert E.
Semantic Analysis
class A {
int b;
A(int b) {
this.b = b;
}
}
Java pop quizz !!
class Foo<T> {
class T {
}
T myField;
}
Java pop quizz !!
class Foo<T> {
class T {
}
T myField;
}
How do you know that ?
JLS is your best friend
http://docs.oracle.com/javase/specs/jls/se8/html/index.html
Java pop quizz !!
interface F1 {
}
interface F2 {
}
Java pop quizz !!
class A<T extends F1 &
F2>{
void fun(F1 f1){}
void fun(T t){}
}
Java pop quizz !!
class A<T extends F2 &
F1>{
void fun(F1 f1){}
void fun(T t){}
}
Java pop quizz !!
The erasure of a type
variable is the erasure of
its leftmost bound.
How do you know that ?
JLS is your best friend
http://docs.oracle.com/javase/specs/jls/se8/html/index.html
Your turn now : Custom rules !
Beyond semantic : Symbolic Execution
Object myObject = new Object();
if(a) { myObject = null; }
...
if( !a ) { ... }
else { myObject.toString(); } //NPE
Symbolic Execution
Object myObject = new Object();
if(a) { myObject = null; }
...
if( !a ) { … }
else { myObject.toString(); } //NPE
Program State#0
myObject != null
Symbolic Execution
Object myObject = new Object();
if(a) { myObject = null; }
...
if( !a ) { … }
else { myObject.toString(); } //NPE
Program State#0
myObject != null
Program State#1
myObject != null
a = false
Program State#2
myObject = null
a = true
Symbolic Execution
...
if( !a ) { … }
else {
myObject.toString(); // NPE
}
Program State#1
myObject != null
a = false
Program State#2
myObject = null
a = true
Program State#4
myObject = null
a = true
Program State#3
...
Symbolic Execution challenges
Complex flows : Try Catch Finally
try {
methodCall();
methodThrowingException();
} catch ( CustomException e) {
...
}finally {
...
}
Symbolic Execution challenges
Complex conditions :
if(a + 1 < (b* 10 - 39) ) {
if( b > a/10 + 4 ) { … } // Always true
}
Symbolic Execution challenges
Explosion of states :
if(a) {...} else {...}
if(b) {...} else {...}
if(c) {...} else {...}
instruction; //evaluated by 8 states.
Uhoh ?!
From apache vysper:
https://nemo.sonarqube.org/issues/search#issues=AVJ9P2Bzm66gr6MLNW_j
Uhoh ?!
From elastic search:
https://nemo.sonarqube.org/issues/search#issues=AVJ9mFy_m66gr6MLNXpJ
Reach us
sonarqube@googlegroups.com
https://groups.google.com/forum/#!forum/sonarqube
sonarsource
jobs@sonarsource.com
Q & A

Contenu connexe

Tendances

Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)
mircodotta
 
Scala the good and bad parts
Scala the good and bad partsScala the good and bad parts
Scala the good and bad parts
benewu
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
mircodotta
 

Tendances (12)

TMPA-2015: Kotlin: From Null Dereference to Smart Casts
TMPA-2015: Kotlin: From Null Dereference to Smart CastsTMPA-2015: Kotlin: From Null Dereference to Smart Casts
TMPA-2015: Kotlin: From Null Dereference to Smart Casts
 
Value Types
Value TypesValue Types
Value Types
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)Effective Scala (SoftShake 2013)
Effective Scala (SoftShake 2013)
 
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
DEV.BG - Angular 1 and Jasmine (Unit Testing and TDD)
 
Tokyo F# meetup 14-08-03
Tokyo F# meetup 14-08-03Tokyo F# meetup 14-08-03
Tokyo F# meetup 14-08-03
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
 
Java principles
Java principlesJava principles
Java principles
 
Python basics
Python basicsPython basics
Python basics
 
Scala the good and bad parts
Scala the good and bad partsScala the good and bad parts
Scala the good and bad parts
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
 
10 Things I Hate About Scala
10 Things I Hate About Scala10 Things I Hate About Scala
10 Things I Hate About Scala
 

En vedette (7)

Introduction to Performance Testing Part 1
Introduction to Performance Testing Part 1Introduction to Performance Testing Part 1
Introduction to Performance Testing Part 1
 
Encuesta
EncuestaEncuesta
Encuesta
 
Manusia & Pengembangan Diri
Manusia & Pengembangan DiriManusia & Pengembangan Diri
Manusia & Pengembangan Diri
 
Business Analysis in IT by Ilze Buksha, Latvian
Business Analysis in IT by Ilze Buksha, LatvianBusiness Analysis in IT by Ilze Buksha, Latvian
Business Analysis in IT by Ilze Buksha, Latvian
 
Data Access using Entity Framework
Data Access using Entity FrameworkData Access using Entity Framework
Data Access using Entity Framework
 
Loja.bortolettocosmeticos.com
Loja.bortolettocosmeticos.comLoja.bortolettocosmeticos.com
Loja.bortolettocosmeticos.com
 
Presentazione mondo sara
Presentazione mondo saraPresentazione mondo sara
Presentazione mondo sara
 

Similaire à DIY: Analyse statique en Java

みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
techtalkdwango
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
Takuya Fujimura
 

Similaire à DIY: Analyse statique en Java (20)

Développer un moteur d'exécution symbolique en partant de rien
Développer un moteur d'exécution symbolique en partant de rienDévelopper un moteur d'exécution symbolique en partant de rien
Développer un moteur d'exécution symbolique en partant de rien
 
Programming with Freedom & Joy
Programming with Freedom & JoyProgramming with Freedom & Joy
Programming with Freedom & Joy
 
Proper Null handling with modern java techniques
Proper Null handling with modern java techniquesProper Null handling with modern java techniques
Proper Null handling with modern java techniques
 
Lagergren jvmls-2013-final
Lagergren jvmls-2013-finalLagergren jvmls-2013-final
Lagergren jvmls-2013-final
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
 
Clojure made really really simple
Clojure made really really simpleClojure made really really simple
Clojure made really really simple
 
JS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better Parts
 
Java Basics
Java BasicsJava Basics
Java Basics
 
It's All About Morphisms
It's All About MorphismsIt's All About Morphisms
It's All About Morphisms
 
Master the Concepts Behind the Java 10 Challenges and Eliminate Stressful Bugs
Master the Concepts Behind the Java 10 Challenges and Eliminate Stressful BugsMaster the Concepts Behind the Java 10 Challenges and Eliminate Stressful Bugs
Master the Concepts Behind the Java 10 Challenges and Eliminate Stressful Bugs
 
In Vogue Dynamic
In Vogue DynamicIn Vogue Dynamic
In Vogue Dynamic
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
What can scala puzzlers teach us
What can scala puzzlers teach usWhat can scala puzzlers teach us
What can scala puzzlers teach us
 
I just met you, and "this" is crazy, but here's my NaN, so call(me), maybe? b...
I just met you, and "this" is crazy, but here's my NaN, so call(me), maybe? b...I just met you, and "this" is crazy, but here's my NaN, so call(me), maybe? b...
I just met you, and "this" is crazy, but here's my NaN, so call(me), maybe? b...
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 
Autoboxing And Unboxing In Java
Autoboxing And Unboxing In JavaAutoboxing And Unboxing In Java
Autoboxing And Unboxing In Java
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
Java Annotations and Pre-processing
Java  Annotations and Pre-processingJava  Annotations and Pre-processing
Java Annotations and Pre-processing
 

Plus de lyonjug

201303 - Golo
201303 - Golo201303 - Golo
201303 - Golo
lyonjug
 
201303 - Java8
201303 - Java8201303 - Java8
201303 - Java8
lyonjug
 
201305 - Lambda by R. Forax
201305 - Lambda by R. Forax201305 - Lambda by R. Forax
201305 - Lambda by R. Forax
lyonjug
 
201301 - Focus Neo4j
201301 - Focus Neo4j201301 - Focus Neo4j
201301 - Focus Neo4j
lyonjug
 
201301 - Panorama NoSQL
201301 - Panorama NoSQL201301 - Panorama NoSQL
201301 - Panorama NoSQL
lyonjug
 
201209 Lombok & Guava
201209 Lombok & Guava201209 Lombok & Guava
201209 Lombok & Guava
lyonjug
 
201209 LT Clojure
201209 LT Clojure201209 LT Clojure
201209 LT Clojure
lyonjug
 
Présentation Granite ds lyon 2011 par William Draï
Présentation Granite ds lyon 2011 par William DraïPrésentation Granite ds lyon 2011 par William Draï
Présentation Granite ds lyon 2011 par William Draï
lyonjug
 
20091020 JPA2
20091020 JPA220091020 JPA2
20091020 JPA2
lyonjug
 

Plus de lyonjug (20)

Lightning talk LyonJUG février 2016 - Ansible
Lightning talk LyonJUG février 2016 - AnsibleLightning talk LyonJUG février 2016 - Ansible
Lightning talk LyonJUG février 2016 - Ansible
 
Introduction LyonJUG décembre 2015
Introduction LyonJUG décembre 2015Introduction LyonJUG décembre 2015
Introduction LyonJUG décembre 2015
 
Introduction LyonJUG Janvier 2016
Introduction LyonJUG Janvier 2016Introduction LyonJUG Janvier 2016
Introduction LyonJUG Janvier 2016
 
Presentation jug novembre2015
Presentation jug novembre2015Presentation jug novembre2015
Presentation jug novembre2015
 
201502 - Integration Testing
201502 - Integration Testing201502 - Integration Testing
201502 - Integration Testing
 
201311 - Middleware
201311 - Middleware201311 - Middleware
201311 - Middleware
 
201303 - Golo
201303 - Golo201303 - Golo
201303 - Golo
 
201303 - Java8
201303 - Java8201303 - Java8
201303 - Java8
 
201305 - Lambda by R. Forax
201305 - Lambda by R. Forax201305 - Lambda by R. Forax
201305 - Lambda by R. Forax
 
201301 - Focus Neo4j
201301 - Focus Neo4j201301 - Focus Neo4j
201301 - Focus Neo4j
 
201301 - Panorama NoSQL
201301 - Panorama NoSQL201301 - Panorama NoSQL
201301 - Panorama NoSQL
 
201209 Lombok & Guava
201209 Lombok & Guava201209 Lombok & Guava
201209 Lombok & Guava
 
201209 LT Clojure
201209 LT Clojure201209 LT Clojure
201209 LT Clojure
 
Spring Batch Workshop (advanced)
Spring Batch Workshop (advanced)Spring Batch Workshop (advanced)
Spring Batch Workshop (advanced)
 
Spring Batch Workshop
Spring Batch WorkshopSpring Batch Workshop
Spring Batch Workshop
 
Engagement des sociétés d'Ingénierie dans la contribution open source : un ce...
Engagement des sociétés d'Ingénierie dans la contribution open source : un ce...Engagement des sociétés d'Ingénierie dans la contribution open source : un ce...
Engagement des sociétés d'Ingénierie dans la contribution open source : un ce...
 
GlassFish, Application versioning et rolling upgrade en haute disponibilité
GlassFish, Application versioning et rolling upgrade en haute disponibilitéGlassFish, Application versioning et rolling upgrade en haute disponibilité
GlassFish, Application versioning et rolling upgrade en haute disponibilité
 
Développement dans le cloud - Sacha Labourey
Développement dans le cloud - Sacha LaboureyDéveloppement dans le cloud - Sacha Labourey
Développement dans le cloud - Sacha Labourey
 
Présentation Granite ds lyon 2011 par William Draï
Présentation Granite ds lyon 2011 par William DraïPrésentation Granite ds lyon 2011 par William Draï
Présentation Granite ds lyon 2011 par William Draï
 
20091020 JPA2
20091020 JPA220091020 JPA2
20091020 JPA2
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

DIY: Analyse statique en Java