SlideShare a Scribd company logo

The End of the world as we know it - AKA your last NullPointerException $1B bugs!

Eclipse JDT Java null analysis to prevent NullPointerException presentation given at EclipseCon Europe 2016 in Ludwigsburg Germany

1 of 46
Download to read offline
The End of the world as we know it?
AKA your last NullPointerException $1B bugs!
Michael @Vorburger.ch
EclipseCon Europe 2016, October 25, 2016
EclipseCon NullPointerException2
Agenda
1. Topic Intro
2. “How to” (incl. mvn build & IDE config)
3. Some experiences from ongoing work
4. Call to community action++
EclipseCon NullPointerException3
null analysis
is not at all by Red Hat!
AFAIK contributions mostly
by Stephan Herrmann; as
volunteer! #ACK
is a Linux Foundation hosted
platform, leading the future of open
Software Defined Networking
(SDN), based on OSGi (Karaf),
backed by a strong multi vendor
community with 100s of Devs. Red
Hat contributes to ODL, for which
I’ve started to use Eclipse null
analysis @work, and extended
some tooling, and will share some
experiences from #dayjob.
BTW: Red Hat is a
great company to work
for…
redhat.com/jobs
#LifeAtRedHat
EclipseCon NullPointerException4
History
C. A. R. Hoare (Mr. QuickSort et al) jokingly apologized in 2009 for
“adding null reference to ALGOL [=> C => Java], which probably caused
a billion dollars of pain and damage in the last 40 years” (AKA $1B
mistake)
NB: There actually are alt. (JVM) langs with types systems without any
null at all. (Try, for fun.) Meanwhile in the real world, Java has null - and
that ain’t never gonna change anymore…. but still not all hope is lost! ;-)
EclipseCon NullPointerException5
Why
NPE
Blog
Post
most
viewed?
EclipseCon NullPointerException6
What?
Static (compile-time)
code analysis re. po.
null-ness of method
parameters, local
variables, fields.
Why?
Aim to prove that your
code is null safe, so
NullPointerException
will never occur anymore.
How?
Let’s see together...

Recommended

Meet the Eclipse SmartHome powered Mars Rover
Meet the Eclipse SmartHome powered Mars RoverMeet the Eclipse SmartHome powered Mars Rover
Meet the Eclipse SmartHome powered Mars RoverMichael Vorburger
 
Vagrant - the essence of DevOps in a tool
Vagrant - the essence of DevOps in a toolVagrant - the essence of DevOps in a tool
Vagrant - the essence of DevOps in a toolPaul Stack
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...Puppet
 
Do you know all of Puppet?
Do you know all of Puppet?Do you know all of Puppet?
Do you know all of Puppet?Julien Pivotto
 
Jenkins Shared Libraries Workshop
Jenkins Shared Libraries WorkshopJenkins Shared Libraries Workshop
Jenkins Shared Libraries WorkshopJulien Pivotto
 
BUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIOBUILDING APPS WITH ASYNCIO
BUILDING APPS WITH ASYNCIOMykola Novik
 
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Conference
 
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOP
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOPHOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOP
HOW TO DEAL WITH BLOCKING CODE WITHIN ASYNCIO EVENT LOOPMykola Novik
 

More Related Content

What's hot

Docker experience @inbotapp
Docker experience @inbotappDocker experience @inbotapp
Docker experience @inbotappJilles van Gurp
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflowTomas Doran
 
Understanding and building Your Own Docker
Understanding and building Your Own DockerUnderstanding and building Your Own Docker
Understanding and building Your Own DockerMotiejus Jakštys
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
GateKeeper - bypass or not bypass?
GateKeeper - bypass or not bypass?GateKeeper - bypass or not bypass?
GateKeeper - bypass or not bypass?Csaba Fitzl
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkeyjervin
 
Dockerize it! @ Codemotion 2016 in Rome
Dockerize it! @ Codemotion 2016 in RomeDockerize it! @ Codemotion 2016 in Rome
Dockerize it! @ Codemotion 2016 in RomeAlessandro Nadalin
 
Modern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetModern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetPuppet
 
An introduction to Ansible
An introduction to AnsibleAn introduction to Ansible
An introduction to AnsibleJulien Pivotto
 
Docker and Puppet — Puppet Camp L.A. — SCALE12X
Docker and Puppet — Puppet Camp L.A. — SCALE12XDocker and Puppet — Puppet Camp L.A. — SCALE12X
Docker and Puppet — Puppet Camp L.A. — SCALE12XJérôme Petazzoni
 
A Modest Introduction to Swift
A Modest Introduction to SwiftA Modest Introduction to Swift
A Modest Introduction to SwiftJohn Anderson
 
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and KibanaPuppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibanapkill
 
Jenkins Docker
Jenkins DockerJenkins Docker
Jenkins DockerAlex Soto
 
JFrog container registry - DevOps extravaganza
JFrog container registry - DevOps extravaganza JFrog container registry - DevOps extravaganza
JFrog container registry - DevOps extravaganza Batel Zohar Tova
 
Android developer's toolbox
Android developer's toolboxAndroid developer's toolbox
Android developer's toolboxAlex Verdyan
 
A quick overview of why to use and how to set up iPython notebooks for research
A quick overview of why to use and how to set up iPython notebooks for researchA quick overview of why to use and how to set up iPython notebooks for research
A quick overview of why to use and how to set up iPython notebooks for researchAdam Pah
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerGraham Charters
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Puppet
 
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...Codemotion
 

What's hot (20)

Docker experience @inbotapp
Docker experience @inbotappDocker experience @inbotapp
Docker experience @inbotapp
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Understanding and building Your Own Docker
Understanding and building Your Own DockerUnderstanding and building Your Own Docker
Understanding and building Your Own Docker
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
GateKeeper - bypass or not bypass?
GateKeeper - bypass or not bypass?GateKeeper - bypass or not bypass?
GateKeeper - bypass or not bypass?
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkey
 
Dockerize it! @ Codemotion 2016 in Rome
Dockerize it! @ Codemotion 2016 in RomeDockerize it! @ Codemotion 2016 in Rome
Dockerize it! @ Codemotion 2016 in Rome
 
Modern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetModern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with Puppet
 
An introduction to Ansible
An introduction to AnsibleAn introduction to Ansible
An introduction to Ansible
 
Docker and Puppet — Puppet Camp L.A. — SCALE12X
Docker and Puppet — Puppet Camp L.A. — SCALE12XDocker and Puppet — Puppet Camp L.A. — SCALE12X
Docker and Puppet — Puppet Camp L.A. — SCALE12X
 
A Modest Introduction to Swift
A Modest Introduction to SwiftA Modest Introduction to Swift
A Modest Introduction to Swift
 
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and KibanaPuppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
 
Jenkins Docker
Jenkins DockerJenkins Docker
Jenkins Docker
 
JFrog container registry - DevOps extravaganza
JFrog container registry - DevOps extravaganza JFrog container registry - DevOps extravaganza
JFrog container registry - DevOps extravaganza
 
Android developer's toolbox
Android developer's toolboxAndroid developer's toolbox
Android developer's toolbox
 
Vagrant to-aws-flow
Vagrant to-aws-flowVagrant to-aws-flow
Vagrant to-aws-flow
 
A quick overview of why to use and how to set up iPython notebooks for research
A quick overview of why to use and how to set up iPython notebooks for researchA quick overview of why to use and how to set up iPython notebooks for research
A quick overview of why to use and how to set up iPython notebooks for research
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for Docker
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
 
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...
Steve Sfartz - How to embed Messaging and Video in your apps - Codemotion Mil...
 

Viewers also liked

Viewers also liked (6)

#Make01
#Make01#Make01
#Make01
 
openHAB @ JUG Stuttgart
openHAB @ JUG StuttgartopenHAB @ JUG Stuttgart
openHAB @ JUG Stuttgart
 
openHAB @ rheinJUG Düsseldorf
openHAB @ rheinJUG DüsseldorfopenHAB @ rheinJUG Düsseldorf
openHAB @ rheinJUG Düsseldorf
 
openHAB TechTalk @ DeveloperGarden Darmstadt
openHAB TechTalk @ DeveloperGarden DarmstadtopenHAB TechTalk @ DeveloperGarden Darmstadt
openHAB TechTalk @ DeveloperGarden Darmstadt
 
openHAB @ ECE2011
openHAB @ ECE2011openHAB @ ECE2011
openHAB @ ECE2011
 
openHAB @ Devoxx 2012
openHAB @ Devoxx 2012openHAB @ Devoxx 2012
openHAB @ Devoxx 2012
 

Similar to The End of the world as we know it - AKA your last NullPointerException $1B bugs!

OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansOpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansMichael Vorburger
 
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!Michał Ćmil
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allMarc Dutoo
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware
 
Extending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with KubernetesExtending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with KubernetesNicola Ferraro
 
Run your Java code on Cloud Foundry
Run your Java code on Cloud FoundryRun your Java code on Cloud Foundry
Run your Java code on Cloud FoundryAndy Piper
 
Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016
Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016
Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016Florent BENOIT
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 NurembergMarcel Bruch
 
YAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl CodingYAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl Codingjoshua.mcadams
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview Lars Vogel
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
Eclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsEclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsLars Vogel
 
How to build a tool for operating Flink on Kubernetes
How to build a tool for operating Flink on KubernetesHow to build a tool for operating Flink on Kubernetes
How to build a tool for operating Flink on KubernetesAndreaMedeghini
 
Nantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDE
Nantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDENantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDE
Nantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDEFlorent BENOIT
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...Eric Smalling
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofacmeghantaylor
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...Codemotion
 

Similar to The End of the world as we know it - AKA your last NullPointerException $1B bugs! (20)

OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansOpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
 
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
 
Extending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with KubernetesExtending DevOps to Big Data Applications with Kubernetes
Extending DevOps to Big Data Applications with Kubernetes
 
Run your Java code on Cloud Foundry
Run your Java code on Cloud FoundryRun your Java code on Cloud Foundry
Run your Java code on Cloud Foundry
 
Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016
Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016
Eclipse Che: The Next-Gen Eclipse IDE - Bordeaux jug 2016
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 Nuremberg
 
YAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl CodingYAPC::NA 2007 - Epic Perl Coding
YAPC::NA 2007 - Epic Perl Coding
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
Node.js debugging
Node.js debuggingNode.js debugging
Node.js debugging
 
Eclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsEclipse 2011 Hot Topics
Eclipse 2011 Hot Topics
 
How to build a tool for operating Flink on Kubernetes
How to build a tool for operating Flink on KubernetesHow to build a tool for operating Flink on Kubernetes
How to build a tool for operating Flink on Kubernetes
 
Eclipse Vs Netbeans
Eclipse Vs NetbeansEclipse Vs Netbeans
Eclipse Vs Netbeans
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
Nantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDE
Nantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDENantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDE
Nantes Jug 2016 Eclipse Che: The Next-Gen Eclipse IDE
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofac
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 

More from Michael Vorburger

Never too young for Open Source - Red Hat summit in Boston 2017.5
Never too young for Open Source - Red Hat summit in Boston 2017.5Never too young for Open Source - Red Hat summit in Boston 2017.5
Never too young for Open Source - Red Hat summit in Boston 2017.5Michael Vorburger
 
2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a Time
2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a Time2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a Time
2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a TimeMichael Vorburger
 
Mifos: Ending Poverty One Line of Code at a Time
Mifos: Ending Poverty One Line of Code at a TimeMifos: Ending Poverty One Line of Code at a Time
Mifos: Ending Poverty One Line of Code at a TimeMichael Vorburger
 
Ending poverty with software using globally distributed teams to tackle diff...
Ending poverty with software  using globally distributed teams to tackle diff...Ending poverty with software  using globally distributed teams to tackle diff...
Ending poverty with software using globally distributed teams to tackle diff...Michael Vorburger
 
Pragmatic Model Driven Development using openArchitectureWare
Pragmatic Model Driven Development using openArchitectureWarePragmatic Model Driven Development using openArchitectureWare
Pragmatic Model Driven Development using openArchitectureWareMichael Vorburger
 
JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05
JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05
JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05Michael Vorburger
 
Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)
Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)
Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)Michael Vorburger
 

More from Michael Vorburger (7)

Never too young for Open Source - Red Hat summit in Boston 2017.5
Never too young for Open Source - Red Hat summit in Boston 2017.5Never too young for Open Source - Red Hat summit in Boston 2017.5
Never too young for Open Source - Red Hat summit in Boston 2017.5
 
2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a Time
2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a Time2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a Time
2012 Mifos Update at Open World Forum: Ending Poverty One Line of Code at a Time
 
Mifos: Ending Poverty One Line of Code at a Time
Mifos: Ending Poverty One Line of Code at a TimeMifos: Ending Poverty One Line of Code at a Time
Mifos: Ending Poverty One Line of Code at a Time
 
Ending poverty with software using globally distributed teams to tackle diff...
Ending poverty with software  using globally distributed teams to tackle diff...Ending poverty with software  using globally distributed teams to tackle diff...
Ending poverty with software using globally distributed teams to tackle diff...
 
Pragmatic Model Driven Development using openArchitectureWare
Pragmatic Model Driven Development using openArchitectureWarePragmatic Model Driven Development using openArchitectureWare
Pragmatic Model Driven Development using openArchitectureWare
 
JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05
JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05
JDO Presentation given at Java User Group Switzerland (JUGS) on 31.03.05
 
Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)
Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)
Mifos: Ending Poverty One Line of Code at a Time (Jazoon 2010)
 

Recently uploaded

Enterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book ReviewEnterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book ReviewAshraf Fouad
 
LF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIELF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIEDanBrown980551
 
Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...
Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...
Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...Product School
 
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...MichaelBenis1
 
"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys VasylievFwdays
 
"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor Fesenko"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor FesenkoFwdays
 
ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...
ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...
ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...Neo4j
 
How to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response PlanHow to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response PlanDatabarracks
 
Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)
Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)
Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)François
 
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...DianaGray10
 
"How we created an SRE team in Temabit as a part of FOZZY Group in conditions...
"How we created an SRE team in Temabit as a part of FOZZY Group in conditions..."How we created an SRE team in Temabit as a part of FOZZY Group in conditions...
"How we created an SRE team in Temabit as a part of FOZZY Group in conditions...Fwdays
 
Pragmatic UI testing with Compose Semantics.pdf
Pragmatic UI testing with Compose Semantics.pdfPragmatic UI testing with Compose Semantics.pdf
Pragmatic UI testing with Compose Semantics.pdfinfogdgmi
 
How AI and ChatGPT are changing cybersecurity forever.pptx
How AI and ChatGPT are changing cybersecurity forever.pptxHow AI and ChatGPT are changing cybersecurity forever.pptx
How AI and ChatGPT are changing cybersecurity forever.pptxInfosec
 
Introduction to Multimodal LLMs with LLaVA
Introduction to Multimodal LLMs with LLaVAIntroduction to Multimodal LLMs with LLaVA
Introduction to Multimodal LLMs with LLaVARobert McDermott
 
From Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+PluginsFrom Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+PluginsInflectra
 
IT Nation Evolve event 2024 - Quarter 1
IT Nation Evolve event 2024  - Quarter 1IT Nation Evolve event 2024  - Quarter 1
IT Nation Evolve event 2024 - Quarter 1Inbay UK
 
How we think about an advisor tech stack
How we think about an advisor tech stackHow we think about an advisor tech stack
How we think about an advisor tech stackSummit
 
Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...
Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...
Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...IES VE
 
Act Like an Owner, Challenge Like a VC by former CPO, Tripadvisor
Act Like an Owner,  Challenge Like a VC by former CPO, TripadvisorAct Like an Owner,  Challenge Like a VC by former CPO, Tripadvisor
Act Like an Owner, Challenge Like a VC by former CPO, TripadvisorProduct School
 

Recently uploaded (20)

Enterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book ReviewEnterprise Architecture As Strategy - Book Review
Enterprise Architecture As Strategy - Book Review
 
LF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIELF Energy Webinar: Introduction to TROLIE
LF Energy Webinar: Introduction to TROLIE
 
Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...
Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...
Harnessing the Power of GenAI for Exceptional Product Outcomes by Booking.com...
 
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
 
"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev"AIRe - AI Reliability Engineering", Denys Vasyliev
"AIRe - AI Reliability Engineering", Denys Vasyliev
 
"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor Fesenko"Platform Engineering with Development Containers", Igor Fesenko
"Platform Engineering with Development Containers", Igor Fesenko
 
ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...
ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...
ASTRAZENECA. Knowledge Graphs Powering a Fast-moving Global Life Sciences Org...
 
How to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response PlanHow to write an effective Cyber Incident Response Plan
How to write an effective Cyber Incident Response Plan
 
In sharing we trust. Taking advantage of a diverse consortium to build a tran...
In sharing we trust. Taking advantage of a diverse consortium to build a tran...In sharing we trust. Taking advantage of a diverse consortium to build a tran...
In sharing we trust. Taking advantage of a diverse consortium to build a tran...
 
Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)
Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)
Mind your App Footprint 🐾⚡️🌱 (@FlutterHeroes 2024)
 
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...
 
"How we created an SRE team in Temabit as a part of FOZZY Group in conditions...
"How we created an SRE team in Temabit as a part of FOZZY Group in conditions..."How we created an SRE team in Temabit as a part of FOZZY Group in conditions...
"How we created an SRE team in Temabit as a part of FOZZY Group in conditions...
 
Pragmatic UI testing with Compose Semantics.pdf
Pragmatic UI testing with Compose Semantics.pdfPragmatic UI testing with Compose Semantics.pdf
Pragmatic UI testing with Compose Semantics.pdf
 
How AI and ChatGPT are changing cybersecurity forever.pptx
How AI and ChatGPT are changing cybersecurity forever.pptxHow AI and ChatGPT are changing cybersecurity forever.pptx
How AI and ChatGPT are changing cybersecurity forever.pptx
 
Introduction to Multimodal LLMs with LLaVA
Introduction to Multimodal LLMs with LLaVAIntroduction to Multimodal LLMs with LLaVA
Introduction to Multimodal LLMs with LLaVA
 
From Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+PluginsFrom Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
From Challenger to Champion: How SpiraPlan Outperforms JIRA+Plugins
 
IT Nation Evolve event 2024 - Quarter 1
IT Nation Evolve event 2024  - Quarter 1IT Nation Evolve event 2024  - Quarter 1
IT Nation Evolve event 2024 - Quarter 1
 
How we think about an advisor tech stack
How we think about an advisor tech stackHow we think about an advisor tech stack
How we think about an advisor tech stack
 
Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...
Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...
Empowering Net-Zero: Digital Insights and Funding Opportunities for Industria...
 
Act Like an Owner, Challenge Like a VC by former CPO, Tripadvisor
Act Like an Owner,  Challenge Like a VC by former CPO, TripadvisorAct Like an Owner,  Challenge Like a VC by former CPO, Tripadvisor
Act Like an Owner, Challenge Like a VC by former CPO, Tripadvisor
 

The End of the world as we know it - AKA your last NullPointerException $1B bugs!

  • 1. The End of the world as we know it? AKA your last NullPointerException $1B bugs! Michael @Vorburger.ch EclipseCon Europe 2016, October 25, 2016
  • 2. EclipseCon NullPointerException2 Agenda 1. Topic Intro 2. “How to” (incl. mvn build & IDE config) 3. Some experiences from ongoing work 4. Call to community action++
  • 3. EclipseCon NullPointerException3 null analysis is not at all by Red Hat! AFAIK contributions mostly by Stephan Herrmann; as volunteer! #ACK is a Linux Foundation hosted platform, leading the future of open Software Defined Networking (SDN), based on OSGi (Karaf), backed by a strong multi vendor community with 100s of Devs. Red Hat contributes to ODL, for which I’ve started to use Eclipse null analysis @work, and extended some tooling, and will share some experiences from #dayjob. BTW: Red Hat is a great company to work for… redhat.com/jobs #LifeAtRedHat
  • 4. EclipseCon NullPointerException4 History C. A. R. Hoare (Mr. QuickSort et al) jokingly apologized in 2009 for “adding null reference to ALGOL [=> C => Java], which probably caused a billion dollars of pain and damage in the last 40 years” (AKA $1B mistake) NB: There actually are alt. (JVM) langs with types systems without any null at all. (Try, for fun.) Meanwhile in the real world, Java has null - and that ain’t never gonna change anymore…. but still not all hope is lost! ;-)
  • 6. EclipseCon NullPointerException6 What? Static (compile-time) code analysis re. po. null-ness of method parameters, local variables, fields. Why? Aim to prove that your code is null safe, so NullPointerException will never occur anymore. How? Let’s see together...
  • 9. EclipseCon NullPointerException package-info.java, in EACH package, src/main before /test: @org.eclipse.jdt.annotation.NonNullByDefault package yourpackage; 9 @NonNullByDefault (Recommendation) Activating null analysis via Project Properties alone won’t do much yet. You’ll need to express what you want analysed with Java annotations. And occasionally, where you must, use @Nullable in (existing..) code.
  • 11. EclipseCon NullPointerException11 Enjoy your extended coffee break… ;-) init() close() Done! Shortest presentation ever.
  • 12. EclipseCon NullPointerException12 Done? 1. How will a (Maven) build enforce this, same as IDE? 2. How will each project get configured for this in-IDE? 3. Libraries, huh? (#existingcode #nogreenfield) 3.1 Library EEA & the build...
  • 13. EclipseCon NullPointerException13 This was the most useful I was able to find, and (significantly...) extended and built upon: ● https://github.com/sylvainlaurent/eclipse-external-annotations-m2e-plugin ● https://github.com/sylvainlaurent/null-pointer-analysis-examples ● https://github.com/sylvainlaurent/eclipse-external-annotations Curious: Sylvain lives literally next door, and we have common friends - what are the odds?? #FLOSS Research existing attempts to address this #ACK: Others have explored the same space before me - but I hadn’t found a full solution...
  • 14. EclipseCon NullPointerException <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> ... <compilerId>jdt</compilerId> <compilerArguments> <properties>.settings/org.eclipse.jdt.core.prefs</properties> ? ^ ${basedir}/ ? <dependencies> <dependency> <!-- of maven-compiler-plugin, not project --> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-compiler-jdt</artifactId> 14 Build 1. https://wiki.eclipse.org/Tycho/FAQ#Can_I_use_the_Tycho_compiler_support_in_non-OSGi_projects.2C_too.3F 2. https://github.com/jbosstools/m2e-jdt-compiler 3. https://issues.apache.org/jira/browse/MCOMPILER-123
  • 15. EclipseCon NullPointerException https://github.com/vorburger/eclipse-null-eea-augments illustrates 3. in full example project. https://github.com/vorburger/eclipse-external-annotations-m2e-plugin/commits/individualEEAs is a M2E AbstractProjectConfigurator which copies JDT compilerArguments properties from artifact in compiler-plugin dependency, or compilerArguments properties, into IDE. (TBD ⇒ ? #helpwanted) 15 Project Configuration Depends on where you sit on having .settings/** in SCM… ;-) Basically you can either: 1. use workspace wide default preferences (recommended: Oomph!); NOK for gradually.. 2. save .settings/*jdt.core.prefs project preferences properties per project in SCM 3. .settings/ in .gitignore & org.eclipse.jdt.core.prefs in Maven artifact, and: a. use maven-dependency-plugin to unpack it into target/ for build point maven-compiler-plugin to use that instead of .settings/ b. declare <dependency> and use M2E extension to set into each project (JDT API)
  • 16. EclipseCon NullPointerException java.util java.util Optional.ofNullable(null) /* @Nullable */ V Map.get(Object key) Null type mismatch: required ... '@NonNull String' but the provided value is null 16 The underlying problem is interfacing with existing library code which you cannot modify... or... can we?! Libraries... You always use external 3rd-party libraries in all of your projects. Even if you think you don’t, you do - JDK! Look at 1st of many you’ll hit:
  • 18. EclipseCon NullPointerException18 External *.eea annotation files “augment” (not in the Star Trek sense..) Eclipse Java Build Path entries with additional @NonNull VS @Nullablable information. Useful when working with 3rd-party library JARs you cannot easily change - including the JDK RT. Eclipse External null Annotations (EEA)
  • 21. EclipseCon NullPointerException21 https://github.com/vorburger/eclipse-null-eea-augments (TBD ⇒ ? #helpwanted #449653) Producing EEA JARs as Maven artifacts slf4j-api-eea ch.vorburger.null:eea-parent maven-resources-plugin config. maven-compiler-plugin disabled maven-surefire-plugin disabled /pom.xml /org/slf4j/LoggerFactory.eea /eea-for-gav NOT using Maven classifier - just naming convention of artifactId ending in *-eea (for filtering list of dependencies for performance in M2E plugin). Maven Classifiers don’t work great in M2E, and aren’t a fit here anyway - the EEA isn’t really an additional artifact for one (≉ GAV).
  • 22. EclipseCon NullPointerException <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <annotationpath>CLASSPATH</annotationpath> <dependencies> <!-- of project, not maven-compiler-plugin --> <dependency> <groupId>ch.vorburger.null.eea</groupId> <artifactId>slf4j-api-eea</artifactId> <version>1.0.0-SNAPSHOT</version> <scope>provided</scope> 22 EEA & the build 1. Granularity not identical to in-IDE, but this works just fine… #pragmatic 2. Not REALLY needed on CP, but this approach avoids rebuilding infra. for DL, dist, etc. #itworks
  • 23. EclipseCon NullPointerException External Annotations & M2E Maven in IDE 23 I’ve extended M2E Project Configurator (same which sets Compiler Properties) to set External annotations for Maven Dependencies classpath container. Problem: How to map JAR (or Project) with *.eea to Maven GAVs / JRE? I’ve used a file in JAR (eea-for-gav: org.slf4j:slf4j-api). It has N lines; useful e.g. for org.mockito:mockito-all & :mockito-core & “fat” J. Supports: Open/Close (=> binary) project - standard Maven Workspace Dependency Resolution (TBD ⇒ ? #helpwanted #457792)
  • 24. EclipseCon NullPointerException24 In an ideal world, we should all have a common repo of EEA artifacts where we share null annotations... How-to new Git repo. @ eclipse.org? GitHub PRs how? Or simply a GitHub Org?? (Soft on IP CLA?) I’m willing to kick something off… Is there anyone here who would be willing to contribute to this effort? External Annotations repository #helpwanted Eclipse.org Bug 449653 and Bug 457792
  • 26. EclipseCon NullPointerException26 How-to move existing product to be NullPointerException free? 1. Set up your product’s org.eclipse.jdt.core.prefs & IDE Setup infra etc. It has to “just work” (OOB)… for Maven-based projects, see prez. part 1! ;) 2. Iterate submitting small incremental changes, project by project, src/main before src/test; @NonNullByDefault package by package: Add package-info.java => lots red, adapt, some @Nullable, etc. 3. Contribute to (my) shared EEA library manually as required as you go 4. If push back, can start with IDE only, enforcement in build later (but do target build enforcement, else quickly regressions from others) Process (ODL: 60+ .git * 10s .project * 10s .java)
  • 27. EclipseCon NullPointerException27 1. FindBugs: Oldest, but (supposedly) more limited null analysis. Still great for other static code analysis (just being ext. intro. in ODL) 2. Checker Framework: Interesting… actually. Extensive external annotations for JDK (*.jaif); IDE integration (TBC; must have IMHO) 3. JetBrains.com IntelliJ IDEA: Some inference by bytecode analysis, also external annotations (XML); but no Java 8 generics, and how-to in build? Alternatives?
  • 28. EclipseCon NullPointerException ● org.eclipse.jdt.annotation ■ Android’s, Lombok’s… ● javax.annotation from com.google.code.findbugs:annotation (NOT :jsr305 BTW...) ● org.jetbrains:annotations ■ org.checkerframework ● com.sun.istack.internal (rt.jar) 28 They’re NOT all the same… JDT’s & Checker’s are null type annotations (Java 8 @Target TYPE_USE), for generics! FB/JSR-305 is NOT, others IDK. The semantics differ, too; FB’s @Nullable :( You could also create your own. But simplest to get started is to just use JDT’s. Yeah, there are several “competing” annotations for (non) nullability… Accept it, pick one as primary for your project with your tool, move on! ;) @ which @Nullable & @NonNull (NotNull)
  • 29. EclipseCon NullPointerException29 Gotcha! (Quiz Time) @Nullable File file() { return null; } @Nullable java.io.File file() { return null; } java.io.@Nullable File file() { return null; }
  • 30. EclipseCon NullPointerException30 Gotcha! (Quiz Time) @Nullable File file() { return null; } @javax.annotation.Nullable java.io.File file() { return null; } java.io.@org.eclipse.jdt.annotation.Nullable File file() { return null; } https://bugs.eclipse.org/bugs/show_bug.cgi?id=506376
  • 31. EclipseCon NullPointerException31 FindBugs annotations interop? ● Configure javax.annotation.Nullable & NonNull (used e.g. in Google Guava! and ODL...) as secondary annotations in “Annotations for Null Specifications” preference intro. Since Neon (4.6) M5, save EEA. I’m still gaining experience with InterOp… diff. only evaluated when reading class files external to the project? That’s inconsistent… see Hello.java prob with fileMayBeNull2. ● Use Eclipse’s null analysis instead of FindBugs’, in both build and IDE (use FB for other code analysis; exclude)
  • 32. EclipseCon NullPointerException32 As of 2016.10.12: 441 closed VS 135 open bugs in CDT with “[null] …” in summary. (As usual: Not all 135 are true “bugs”; some are unclear, some lingering old “discussions”.) Sense of “not ideal solution, we had to compromise” in some areas (e.g. Bug #505828) Filed / found during evaluation: 1. Bug #443146 Code Completion unnecessary @NonNull when @NonNullByDefault 2. Bug #506375 Allow NonNullByDefault in external library annotation 3. Bug #505828 Inherit stronger than @NonNullByDefault 4. Bug #500885 NullPointerException at jdt.internal.compiler.lookup.BinaryTypeBinding 5. Bug #489900 annotation 2.1.0 in Maven central Status & Bugs
  • 33. EclipseCon NullPointerException33 Annotations & @Override (with EEA…) @Override public boolean equals(Object obj) Illegal redefinition of parameter obj, inherited method from Object does not constrain this parameter @Override public boolean equals(@Nullable Object obj) Can be worked around by adding @Nullable - at every use! (Bug #505828 …)
  • 34. EclipseCon NullPointerException34 ● ODL: (0) APPLY.. (1) OMG build on ecj… TBC! ;-) (2) @eclipse & @javax & (3) IntelliJ cohabitation? #me ● EEA: Repo with more contribs, releasing #me&you? Maybe conversion tool of Checker Framework JDK (*.jaif) metadata to EEA ?? Gen. EEA by automatic analysis? ● Plug-in Dependencies CP container? Gradle?? #you? ● Try it all out, contribute eea, provide feedback! #you Future Ideas (YOU? #helpwanted)
  • 35. Q & A and YOUR feedback / experiences?
  • 39. EclipseCon NullPointerException @NonNullByDefault({}) // deactivate it :-( public class Bean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } 39 Zoom: Java Beans - null by default?
  • 40. EclipseCon NullPointerException40 Zoom: Java Beans - Collection properties public class Bean { private final List<String> names = new ArrayList<>(); public List<String> getNames() { return names; } // no setNames() }
  • 41. EclipseCon NullPointerException public class Bean { private Optional<String> name = Optional.empty(); public Optional<String> getName() { return name; } public void setName(String name) { this.name = Optional.of(name); } // void unsetName() ? } 41 Zoom: Java Beans - Optional<> properties public class Bean { private @Nullable String name; public Optional<String> getName() { return Optional.ofNullable(name); } public void setName(String name) { this.name = name; } // void unsetName() ? }
  • 42. EclipseCon NullPointerException42 Zoom: Java Beans - mandatory properties Traditionally we don’t think about mandatory (required) bean properties.. if (some) clearly always are (beware..), use final and constructor or Builder pattern which throws Exception. public class Bean { private final String name; public Bean(String name) { this.name = name; } public String getName() { return name; } } public class Bean { private final String name; public static Builder builder() { … public static class Builder { public Bean build() { … }
  • 43. EclipseCon NullPointerException43 Zoom: Java Beans - mandatory properties (II) If you would like static compile-time checking of mandatory bean properties instead of (checked or unchecked) exceptions at run-time from the Builder, you can… It’s a PITA to hand-write, but ideal for code generators! Recommendation: Use http://Immutables.org For an example Builder of a Bean with some mandatory and some optional properties which enforces setting all required at compile time, in fixed order, by returning a particular (inner static) Build class for each (!) mandatory property, AKA “staged Builder”, follow https://github.com/google/auto/issues/370 (originally in Person.java in vorburger/eclipse-null-eea-augments)
  • 44. EclipseCon NullPointerException44 Zoom: Fields TODO huh, seriously?! WTF. This is a significant obstacle to migrating existing code! Options? public int hashCode() { (...) + (field == null ? 0 : field.hashCode()); Potential null pointer access: this expression has a '@Nullable' type Quick Fix “Extract to local variable (all occurrences)” public int hashCode() { Type field2 = field; (...) + (field2 == null ? 0 : field2.hashCode()); PS: For hashCode() in particular, use Objects.hash(...) - but problem in general remains.
  • 45. EclipseCon NullPointerException45 Zoom: Beans’ Fields: hashCode() & equals() In Beans’ hashCode() and equals() implementations, instead of introducing field indirection, use Java 7’s Objects.hash(...) and equalsHelper (* by yours truly). Or, again, consider using some bean code generator, such as e.g. Google’s AutoValue or http://immutables.github.io, etc. (BTW https://github.com/google/guava/issues/2521) public int hashCode() { Type field2 = field; (...) + (field2 == null ? 0 : field2.hashCode());
  • 46. EclipseCon NullPointerException46 ● https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/ ● https://wiki.eclipse.org/JDT_Core/Null_Analysis/Options ● ... Recommended reading