SlideShare a Scribd company logo
1 of 35
The Well-Grounded Java Developer

      Introduction to Java 7
This is not an Oracle legal slide




                              2
No, weā€™re not in sales!
ā€¢ Get in touch
   - Ben is: @kittylist
   - Martijn is: @karianna (and @diabolicaldev)


ā€¢ What we do
   - Authors of ā€œThe Well-Grounded Java Developerā€
   - CEO/CTO of jClarity - JVM/Hardware/Performance stuff


ā€¢ We co-lead the LJC (Londonā€™s Java User Group)
   - Hold a seat on the JCP SE/EE Executive Committee
   - Run Adopt a JSR and Adopt OpenJDK programmes
Or in pictures...
How this session is going to work
 ā€¢ This session may be a little different to advertised...
    - Being a ā€œWell-Grounded Java Developerā€ changes over time


 ā€¢ This session will go fairly quickly
    - But the slides will be made available
    - And you can always get hold of us for any questions


 ā€¢ There are USB keys going around
    - Copy over the WGJD into $WORKSPACE
    - Install Java 7 if you haven't done so already!
    - Your major IDEs should work


 ā€¢ Pair/Group programming works best
    - Have the least experienced person do the actual typing!
Attempted Timetable
Introduction to Java 7 - 0900-0955 (~55 mins)
      ā€“ BREAK (5 minutes)



Polyglot and functional programming - 1000-1030 (~30 mins)



BREAK (30 minutes)



Polyglot and functional programming - 1100-1125 (~25 mins)
      ā€“ BREAK (5 minutes)



Modern Java Concurrency - 1130-1230(~60 mins)
Real developers code through
       bathroom breaks




                          7
The Well-Grounded Java Developer...
   ā€¢ Is not just a Java language whizz
      -   Understands the basics of the JVM
      -   Understands software development is a social activity
      -   Utilises software craftsmanship approaches
      -   Understands physical and logical architectures


   ā€¢ Is using Java 7
      - At least at home if not at work


   ā€¢ Is looking at polyglot and functional programming


   ā€¢ Is looking at modern concurrency practices
Java 7 - Why is it important
ā€¢ The WGJD wants to code rapidly


ā€¢ The WGJD wants to code concisely


ā€¢ The WGJD wants to take advantage of:
   - The compiler (including JIT)
   - The JVM (including GC)


ā€¢ Java 7 gives you many improvements in these areas
OpenJDK - The Java 7/8 split
ā€¢ 20 Sep 2010 - Mark Reinhold announces Plan B
   - Splits OpenJDK plan into Java 7 (July 2011) & Java 8 (2013)
   - Popular choice with the community


ā€¢ July 2011 - Java 7 goes gold
   - Wow, a whole year ago now!


ā€¢ Some new features to be delayed until JDK 8
   - Lambda Expressions
   - Modularisation (aka Jigsaw)


ā€¢ JRockit features to be merged into OpenJDK
   - Enhanced management of the JVM
   - Ongoing merge of the VM engineering groups
Contents of JDK 7 Release
Project Coin



NIO.2



Method Handles



invokedynamic



Concurrency Refresh



Odds & Ends
Project Coin
ā€¢ ā€œSmallā€ changes


ā€¢ Language Level, not VM


ā€¢ Stay away from the type system


ā€¢ Developed in a very OSS manner
   - Was an ā€˜interestingā€™ experience for all involved
Project Coin - Highlights
Strings in switch


try-with-resources (aka ARM or TWR)


Diamond Syntax


Multi-catch with precise re-throw


Enhanced syntax for numeric literals


Varargs / autoboxing warning
Strings in switch




ā€¢ Code along exercise: FeedingSchedule.java
try-with-resources
Diamond syntax




ā€¢ Code along exercise: HordeOfOtters.java
Personally Iā€™d stick to Java 1.4




                             17
NIO.2 - New I/O version 2
ā€¢ A new file system and path abstraction


ā€¢ Based on Path
   - An abstract view of a ā€˜file likeā€™ system


ā€¢ Files class contains many helper methods, including
   - File manipulation (copy, move, rename etc)
   - Walking directory trees
   - Native file system support (e.g. symbolic links)


ā€¢ Works with existing java.io.File code
NIO.2 - New I/O version 2
ā€¢ Asynchronous (non-blocking) I/O


ā€¢ For sockets and files


ā€¢ Mainly utilises java.util.concurrent.Future


ā€¢ New NetworkChannel
   - Socket/Channel construct
   - Binding, options and multicast
Path and Files - Some examples




ā€¢ Code along exercise: Housekeeping.java
URL stream to file - Java 6 style NIO
URL stream to file in Java 7




ā€¢ Code along exercise: VetNotes.java
NIO.2 - Future base file I/O




ā€¢ See ExceptionExamples.java as well (multi-catch)
Method Handles
ā€¢ We already have Reflection API
   - Itā€™s all pretty horrible


ā€¢ JDK 7 introduces a new way to inspect at runtime


ā€¢ Method Handles
   -   Represent the ability to call a method
   -   Implement subclass java.lang.invoke.MethodHandle
   -   Are strongly-typed and typesafe
   -   Needed for invokedynamic - but also used standalone
Example - ThreadPoolManager
Cancelling using Reflection
Cancelling using MethodHandle
invokedynamic

ā€¢ invokedynamic is a key new JVM feature
   - Itā€™s the first new bytecode since Java 1.0
   - Joins invokevirtual, invokestatic,
     invokeinterface and invokespecial


ā€¢ Relaxes a key part of the static typing system
   - User code can determine dispatch at runtime


ā€¢ Aims to be as fast as regular method dispatch
   - e.g. invokevirtual


ā€¢ No Java syntax in Java 7
   - But maybe for Java 8
invokedynamic contd.
ā€¢ JRuby, Jython, Groovy, Clojure et al all benefit
   - JRuby gains a lot, Clojure not so much
   - Even Scala is using it now!


ā€¢ JRuby works closely with the JSR-292 team
   - Charlie Nutter (winner of JAX special jury award)
   - Big wins
   - Makes JRuby enticing to Ruby developers


ā€¢ Java 8 also gets a boost
   - Lambdas will be implemented with invokedynamic
Other JVM Languages?
Meh - Use the Golden Hammer!




                          30
Java 7 Concurrency Refresh
ā€¢ Java 7 has a number of new concurrency toys


ā€¢ The headline item is Fork / Join
    - Similar to Map/Reduce, useful for a certain class of problems
    - Fork and join executions are not necessarily threads


ā€¢ Weā€™ll cover this in the final hour!
Java 7 - Thatā€™s not all
ā€¢ Nimbus Look & Feel for Swing


ā€¢ New helper classes including Objects
   - deepEquals() and friends


ā€¢ JDBC with try-with-resources support


ā€¢ Better unicode support
   - Thanks in part to Tom Christiansen of Perl fame


ā€¢ More small changes in niche areas
New Faces in the OpenJDK
What We Didnā€™t Have Time To Talk About
    ā€¢ Java 8
       - Java FX 2.x


    ā€¢ Java EE 6/7


    ā€¢ Java ME


    ā€¢ JDK Enhancement Proposals (JEPs)


    ā€¢ Java Community Process (JCP)
       - Java Specification Requests (JSRs)
       - Java User Groups (JUGs) and 'Adopt' programs
What? You still here?
Go take a break will you!




                            35

More Related Content

What's hot

What's the "right" PHP Framework?
What's the "right" PHP Framework?What's the "right" PHP Framework?
What's the "right" PHP Framework?Barry Jones
Ā 
The Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot PersistenceThe Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot PersistenceAbdelmonaim Remani
Ā 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the WildTomer Gabel
Ā 
L1 basics
L1 basicsL1 basics
L1 basicsteach4uin
Ā 
PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015kyphpug
Ā 
Kitware: Qt and Scientific Computing
Kitware: Qt and Scientific ComputingKitware: Qt and Scientific Computing
Kitware: Qt and Scientific Computingaccount inactive
Ā 
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksBuilding Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksAtlassian
Ā 
Java Presentation
Java PresentationJava Presentation
Java PresentationAmr Salah
Ā 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easyroialdaag
Ā 
Go - A Key Language in Enterprise Application Development?
Go - A Key Language in Enterprise Application Development?Go - A Key Language in Enterprise Application Development?
Go - A Key Language in Enterprise Application Development?C4Media
Ā 
A tour of Java and the JVM
A tour of Java and the JVMA tour of Java and the JVM
A tour of Java and the JVMAlex Birch
Ā 
History of java
History of javaHistory of java
History of javaMani Sarkar
Ā 
2009 training - tim m - object oriented programming
2009   training - tim m - object oriented programming2009   training - tim m - object oriented programming
2009 training - tim m - object oriented programmingTim Mahy
Ā 
Whitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to ReactiveWhitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to ReactiveDragos Manolescu
Ā 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting StartedRakesh Madugula
Ā 
Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Martijn Verburg
Ā 
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)Kaunas Java User Group
Ā 
Java gc
Java gcJava gc
Java gcNiit
Ā 
Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updatesVinay H G
Ā 

What's hot (20)

What's the "right" PHP Framework?
What's the "right" PHP Framework?What's the "right" PHP Framework?
What's the "right" PHP Framework?
Ā 
The Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot PersistenceThe Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot Persistence
Ā 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
Ā 
L1 basics
L1 basicsL1 basics
L1 basics
Ā 
PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015PHP Frameworks Review - Mar 19 2015
PHP Frameworks Review - Mar 19 2015
Ā 
Kitware: Qt and Scientific Computing
Kitware: Qt and Scientific ComputingKitware: Qt and Scientific Computing
Kitware: Qt and Scientific Computing
Ā 
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksBuilding Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Ā 
Java Presentation
Java PresentationJava Presentation
Java Presentation
Ā 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
Ā 
Go - A Key Language in Enterprise Application Development?
Go - A Key Language in Enterprise Application Development?Go - A Key Language in Enterprise Application Development?
Go - A Key Language in Enterprise Application Development?
Ā 
A tour of Java and the JVM
A tour of Java and the JVMA tour of Java and the JVM
A tour of Java and the JVM
Ā 
History of java
History of javaHistory of java
History of java
Ā 
2009 training - tim m - object oriented programming
2009   training - tim m - object oriented programming2009   training - tim m - object oriented programming
2009 training - tim m - object oriented programming
Ā 
Whitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to ReactiveWhitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to Reactive
Ā 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
Ā 
Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)Modern Java Concurrency (Devoxx Nov/2011)
Modern Java Concurrency (Devoxx Nov/2011)
Ā 
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Ā 
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Ā 
Java gc
Java gcJava gc
Java gc
Ā 
Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updates
Ā 

Similar to Introduction to Java 7 (OSCON 2012)

Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Mihail Stoynov
Ā 
The Evolution of Java
The Evolution of JavaThe Evolution of Java
The Evolution of JavaFu Cheng
Ā 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11Arto Santala
Ā 
OSGi Community Event 2010 - OSGi and Android
OSGi Community Event 2010 - OSGi and AndroidOSGi Community Event 2010 - OSGi and Android
OSGi Community Event 2010 - OSGi and Androidmfrancis
Ā 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10Arto Santala
Ā 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overviewJesse Warden
Ā 
01-Introduction.ppt
01-Introduction.ppt01-Introduction.ppt
01-Introduction.pptEmanAsem4
Ā 
Java 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the GalleryJava 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the Gallerynjbartlett
Ā 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxMurugesh33
Ā 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxMurugesh33
Ā 
Java for XPages Development
Java for XPages DevelopmentJava for XPages Development
Java for XPages DevelopmentTeamstudio
Ā 
Java Closures
Java ClosuresJava Closures
Java ClosuresBen Evans
Ā 
How can your applications benefit from Java 9?
How can your applications benefit from Java 9?How can your applications benefit from Java 9?
How can your applications benefit from Java 9?EUR ING Ioannis Kolaxis MSc
Ā 
How can your applications benefit from Java 9?
How can your applications benefit from Java 9?How can your applications benefit from Java 9?
How can your applications benefit from Java 9?EUR ING Ioannis Kolaxis MSc
Ā 
Tips For Maintaining OSS Projects
Tips For Maintaining OSS ProjectsTips For Maintaining OSS Projects
Tips For Maintaining OSS ProjectsTaro L. Saito
Ā 
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)Mani Sarkar
Ā 
Java Course 1: Introduction
Java Course 1: IntroductionJava Course 1: Introduction
Java Course 1: IntroductionAnton Keks
Ā 

Similar to Introduction to Java 7 (OSCON 2012) (20)

Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Ā 
The Evolution of Java
The Evolution of JavaThe Evolution of Java
The Evolution of Java
Ā 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
Ā 
OSGi Community Event 2010 - OSGi and Android
OSGi Community Event 2010 - OSGi and AndroidOSGi Community Event 2010 - OSGi and Android
OSGi Community Event 2010 - OSGi and Android
Ā 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
Ā 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
Ā 
01-Introduction.ppt
01-Introduction.ppt01-Introduction.ppt
01-Introduction.ppt
Ā 
Java Basics
Java BasicsJava Basics
Java Basics
Ā 
Java 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the GalleryJava 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the Gallery
Ā 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Ā 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
Ā 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
Ā 
Java for XPages Development
Java for XPages DevelopmentJava for XPages Development
Java for XPages Development
Ā 
Java Closures
Java ClosuresJava Closures
Java Closures
Ā 
How can your applications benefit from Java 9?
How can your applications benefit from Java 9?How can your applications benefit from Java 9?
How can your applications benefit from Java 9?
Ā 
How can your applications benefit from Java 9?
How can your applications benefit from Java 9?How can your applications benefit from Java 9?
How can your applications benefit from Java 9?
Ā 
Tips For Maintaining OSS Projects
Tips For Maintaining OSS ProjectsTips For Maintaining OSS Projects
Tips For Maintaining OSS Projects
Ā 
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Java 9 / Jigsaw - LJC / VJUG session (hackday session)
Ā 
Java Course 1: Introduction
Java Course 1: IntroductionJava Course 1: Introduction
Java Course 1: Introduction
Ā 
GWT-Basics
GWT-BasicsGWT-Basics
GWT-Basics
Ā 

More from Martijn Verburg

Garbage Collection - The Useful Parts
Garbage Collection - The Useful PartsGarbage Collection - The Useful Parts
Garbage Collection - The Useful PartsMartijn Verburg
Ā 
Modern software development anti patterns (OSCON 2012)
Modern software development anti patterns (OSCON 2012)Modern software development anti patterns (OSCON 2012)
Modern software development anti patterns (OSCON 2012)Martijn Verburg
Ā 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Martijn Verburg
Ā 
How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)Martijn Verburg
Ā 
Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Martijn Verburg
Ā 

More from Martijn Verburg (6)

NoHR Hiring
NoHR HiringNoHR Hiring
NoHR Hiring
Ā 
Garbage Collection - The Useful Parts
Garbage Collection - The Useful PartsGarbage Collection - The Useful Parts
Garbage Collection - The Useful Parts
Ā 
Modern software development anti patterns (OSCON 2012)
Modern software development anti patterns (OSCON 2012)Modern software development anti patterns (OSCON 2012)
Modern software development anti patterns (OSCON 2012)
Ā 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
Ā 
How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)
Ā 
Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2
Ā 

Recently uploaded

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
Ā 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜RTylerCroy
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
Ā 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
Ā 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
Ā 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
Ā 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
Ā 

Recently uploaded (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
Ā 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Ā 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Ā 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Ā 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Ā 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
Ā 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 

Introduction to Java 7 (OSCON 2012)

  • 1. The Well-Grounded Java Developer Introduction to Java 7
  • 2. This is not an Oracle legal slide 2
  • 3. No, weā€™re not in sales! ā€¢ Get in touch - Ben is: @kittylist - Martijn is: @karianna (and @diabolicaldev) ā€¢ What we do - Authors of ā€œThe Well-Grounded Java Developerā€ - CEO/CTO of jClarity - JVM/Hardware/Performance stuff ā€¢ We co-lead the LJC (Londonā€™s Java User Group) - Hold a seat on the JCP SE/EE Executive Committee - Run Adopt a JSR and Adopt OpenJDK programmes
  • 5. How this session is going to work ā€¢ This session may be a little different to advertised... - Being a ā€œWell-Grounded Java Developerā€ changes over time ā€¢ This session will go fairly quickly - But the slides will be made available - And you can always get hold of us for any questions ā€¢ There are USB keys going around - Copy over the WGJD into $WORKSPACE - Install Java 7 if you haven't done so already! - Your major IDEs should work ā€¢ Pair/Group programming works best - Have the least experienced person do the actual typing!
  • 6. Attempted Timetable Introduction to Java 7 - 0900-0955 (~55 mins) ā€“ BREAK (5 minutes) Polyglot and functional programming - 1000-1030 (~30 mins) BREAK (30 minutes) Polyglot and functional programming - 1100-1125 (~25 mins) ā€“ BREAK (5 minutes) Modern Java Concurrency - 1130-1230(~60 mins)
  • 7. Real developers code through bathroom breaks 7
  • 8. The Well-Grounded Java Developer... ā€¢ Is not just a Java language whizz - Understands the basics of the JVM - Understands software development is a social activity - Utilises software craftsmanship approaches - Understands physical and logical architectures ā€¢ Is using Java 7 - At least at home if not at work ā€¢ Is looking at polyglot and functional programming ā€¢ Is looking at modern concurrency practices
  • 9. Java 7 - Why is it important ā€¢ The WGJD wants to code rapidly ā€¢ The WGJD wants to code concisely ā€¢ The WGJD wants to take advantage of: - The compiler (including JIT) - The JVM (including GC) ā€¢ Java 7 gives you many improvements in these areas
  • 10. OpenJDK - The Java 7/8 split ā€¢ 20 Sep 2010 - Mark Reinhold announces Plan B - Splits OpenJDK plan into Java 7 (July 2011) & Java 8 (2013) - Popular choice with the community ā€¢ July 2011 - Java 7 goes gold - Wow, a whole year ago now! ā€¢ Some new features to be delayed until JDK 8 - Lambda Expressions - Modularisation (aka Jigsaw) ā€¢ JRockit features to be merged into OpenJDK - Enhanced management of the JVM - Ongoing merge of the VM engineering groups
  • 11. Contents of JDK 7 Release Project Coin NIO.2 Method Handles invokedynamic Concurrency Refresh Odds & Ends
  • 12. Project Coin ā€¢ ā€œSmallā€ changes ā€¢ Language Level, not VM ā€¢ Stay away from the type system ā€¢ Developed in a very OSS manner - Was an ā€˜interestingā€™ experience for all involved
  • 13. Project Coin - Highlights Strings in switch try-with-resources (aka ARM or TWR) Diamond Syntax Multi-catch with precise re-throw Enhanced syntax for numeric literals Varargs / autoboxing warning
  • 14. Strings in switch ā€¢ Code along exercise: FeedingSchedule.java
  • 16. Diamond syntax ā€¢ Code along exercise: HordeOfOtters.java
  • 17. Personally Iā€™d stick to Java 1.4 17
  • 18. NIO.2 - New I/O version 2 ā€¢ A new file system and path abstraction ā€¢ Based on Path - An abstract view of a ā€˜file likeā€™ system ā€¢ Files class contains many helper methods, including - File manipulation (copy, move, rename etc) - Walking directory trees - Native file system support (e.g. symbolic links) ā€¢ Works with existing java.io.File code
  • 19. NIO.2 - New I/O version 2 ā€¢ Asynchronous (non-blocking) I/O ā€¢ For sockets and files ā€¢ Mainly utilises java.util.concurrent.Future ā€¢ New NetworkChannel - Socket/Channel construct - Binding, options and multicast
  • 20. Path and Files - Some examples ā€¢ Code along exercise: Housekeeping.java
  • 21. URL stream to file - Java 6 style NIO
  • 22. URL stream to file in Java 7 ā€¢ Code along exercise: VetNotes.java
  • 23. NIO.2 - Future base file I/O ā€¢ See ExceptionExamples.java as well (multi-catch)
  • 24. Method Handles ā€¢ We already have Reflection API - Itā€™s all pretty horrible ā€¢ JDK 7 introduces a new way to inspect at runtime ā€¢ Method Handles - Represent the ability to call a method - Implement subclass java.lang.invoke.MethodHandle - Are strongly-typed and typesafe - Needed for invokedynamic - but also used standalone
  • 28. invokedynamic ā€¢ invokedynamic is a key new JVM feature - Itā€™s the first new bytecode since Java 1.0 - Joins invokevirtual, invokestatic, invokeinterface and invokespecial ā€¢ Relaxes a key part of the static typing system - User code can determine dispatch at runtime ā€¢ Aims to be as fast as regular method dispatch - e.g. invokevirtual ā€¢ No Java syntax in Java 7 - But maybe for Java 8
  • 29. invokedynamic contd. ā€¢ JRuby, Jython, Groovy, Clojure et al all benefit - JRuby gains a lot, Clojure not so much - Even Scala is using it now! ā€¢ JRuby works closely with the JSR-292 team - Charlie Nutter (winner of JAX special jury award) - Big wins - Makes JRuby enticing to Ruby developers ā€¢ Java 8 also gets a boost - Lambdas will be implemented with invokedynamic
  • 30. Other JVM Languages? Meh - Use the Golden Hammer! 30
  • 31. Java 7 Concurrency Refresh ā€¢ Java 7 has a number of new concurrency toys ā€¢ The headline item is Fork / Join - Similar to Map/Reduce, useful for a certain class of problems - Fork and join executions are not necessarily threads ā€¢ Weā€™ll cover this in the final hour!
  • 32. Java 7 - Thatā€™s not all ā€¢ Nimbus Look & Feel for Swing ā€¢ New helper classes including Objects - deepEquals() and friends ā€¢ JDBC with try-with-resources support ā€¢ Better unicode support - Thanks in part to Tom Christiansen of Perl fame ā€¢ More small changes in niche areas
  • 33. New Faces in the OpenJDK
  • 34. What We Didnā€™t Have Time To Talk About ā€¢ Java 8 - Java FX 2.x ā€¢ Java EE 6/7 ā€¢ Java ME ā€¢ JDK Enhancement Proposals (JEPs) ā€¢ Java Community Process (JCP) - Java Specification Requests (JSRs) - Java User Groups (JUGs) and 'Adopt' programs
  • 35. What? You still here? Go take a break will you! 35

Editor's Notes

  1. TODO: Overall if we have time, replace images of code with actual code\n
  2. First laugh of the day\n
  3. We're (Fairly) old (mostly FOSS) hackers and cause trouble at conferences\nBen is known for his performance & concurrency work\nMartijn is also known as the “Diabolical Developer”\n
  4. * Charities, financial services and beer.\n
  5. \n
  6. * No plan survives contact with the enemy, that would be you guys!\n
  7. In reference to timeline\n
  8. \n
  9. \n
  10. * Surprising fact, but the largest group of engineers ever were deployed on Java 7\nWe'll cover Java 8 in our talk later this week!\nClosures, Lambdas, SAM literals\n
  11. \n
  12. Most developers make f&^^%n terrible language designers\nWant to get involved? Talk to us about Adopt OpenJDK\n
  13. \n
  14. * Incidentally JSR 310 provides much better date and time handling, join our Adopt a JSR program to learn more!\n
  15. \n
  16. \n
  17. In reference to how awesome the coin features are\n
  18. \n
  19. \n
  20. \n
  21. \n
  22. * "So we had a bit of a fail with our domain hosting agency..."\n* TODO - We need to provide some text files hosted at a URL\n
  23. * Do the “who knows j.u.c”? question at the start\n* Spot the numeric literal! \n
  24. TODO: “I want my Coffee!” physical theatre\n
  25. See & use interfaces/classes/methods and fields at runtime.\n* Call methods without knowing their names at runtime\n* Think “Reflection done in a safe and modern way\n
  26. TODO: Do we have a simpler example? Perhaps we could extract the Runnable into a local var for readability?\nTODO: Was this the one with the code bug?\n
  27. * Spot the setAccessible() - we need to make the private method accessible\n
  28. Lookup happens in the context where it’s called from.\nMeans that if you lookup() from inside a class, you can see all the private methods.\nThen you can selectively hand out a reference for others to call them.\n* Method handle calls can be inlined through\n* Also unreflect\n
  29. * Method names / signatures will not need to be known at compile time\n* uses MethodHandle\n
  30. \n
  31. In reference to how awesome invokedynamic is\n
  32. \n
  33. * Talk to the pattern in the many Java libraries - Foo / AbstractFoo / Foos\n
  34. \n
  35. \n
  36. \n