SlideShare a Scribd company logo
1 of 28
Java SE 7 {finally}   2011-08-18 Andreas Enbohm
19 augusti 2011 Sida 2 Java SE 7 A evolutionaryevolement of Java 6 yearssince last update Somethingsleftout, will briefly discuss this at the end Oracle reallypushing Java forward- a lotpolitical problems with Sun made Java 7 postphonedseveraltimes Java still growing (1.42%), #1 mostusedlanguageaccording to TIOBE with 19.4% (Aug 2011) My top 10 new features (not ordered in anyway)
Java SE 7 – Language Changes Number 1:Try-with-resources Statement (or ARM-blocks) Before : 19 augusti 2011 Sida 3 static String readFirstLineFromFileWithFinallyBlock(String path)   throwsIOException { BufferedReaderbr = new BufferedReader(new FileReader(path));   try { returnbr.readLine();   } finally { if (br != null) {         try { br.close();         } catch (IOExceptionignore){          //donothing         }     }   } }
Java SE 7 – Language Changes Number 1:Try-with-resources Statement (or ARM-blocks) With Java 7: 19 augusti 2011 Sida 4 static String readFirstLineFromFile(String path) throws IOException {      try (BufferedReaderbr = new BufferedReader(new FileReader(path))) {            return br.readLine();      }  }
Java SE 7 – Language Changes Number 1 - NOTE: The try-with-resources statement is a try statement that declares one or more resources. A resource is as an object that must be closed after the program is finished with it.  The try-with-resources statement ensures that each resource is closed at the end of the statement.  Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource. 19 augusti 2011 Sida 5
Java SE 7 – Language Changes Number 2: 	Strings in switch Statements 19 augusti 2011 Sida 6 public String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) {      String typeOfDay;      switch (dayOfWeekArg) {          case "Monday": typeOfDay = "Start of work week";              break;          case "Tuesday":          case "Wednesday":          case "Thursday": typeOfDay = "Midweek";              break;          case "Friday": typeOfDay = "End of work week";              break;          case "Saturday":          case "Sunday": typeOfDay = "Weekend";              break;          default:              throw new IllegalArgumentException("Invalid day of the week: " + dayOfWeekArg);      }      return typeOfDay; }
Java SE 7 – Language Changes Number 2 - NOTE: The Java compiler generates generally more efficient bytecode from switch statements that use String objects than from chained if-then-else statements. 19 augusti 2011 Sida 7
Java SE 7 – Language Changes Number 3:Catching Multiple ExceptionTypes Before :  Difficult to eliminatecodeduplicationdue to different exceptions! 19 augusti 2011 Sida 8 try {    … } catch (IOException ex) {  logger.log(ex);  throw ex;  } catch (SQLException ex) {  logger.log(ex);  throw ex;  }
Java SE 7 – Language Changes Number 3:Catching Multiple ExceptionTypes With Java 7 : 19 augusti 2011 Sida 9 try {    … } catch (IOException|SQLException ex) {  logger.log(ex);  throw ex;  }
Java SE 7 – Language Changes Number 3 - NOTE:Catching Multiple ExceptionTypes Bytecode generated by compiling a catch block that handles multiple exception types will be smaller (and thus superior) than compiling many catch blocks that handle only one exception type each.   19 augusti 2011 Sida 10
Java SE 7 – Language Changes Number 4:TypeInference for GenericInstance Creation Before:  Howmanytimeshave you swornabout this duplicatedcode?  19 augusti 2011 Sida 11 Map<String, List<String>> myMap = new HashMap<String, List<String>>();
Java SE 7 – Language Changes Number 4:TypeInference for GenericInstance Creation With Java 7:  19 augusti 2011 Sida 12 Map<String, List<String>> myMap = new HashMap<>();
Java SE 7 – Language Changes Number 4 - NOTE:TypeInference for GenericInstance Creation Writing new HashMap() (withoutdiamond operator) will still use the rawtype of HashMap (compilerwarning) 19 augusti 2011 Sida 13
Java SE 7 – Language Changes Number 5:Underscores in NumericLiterals 19 augusti 2011 Sida 14 longcreditCardNumber = 1234_5678_9012_3456L;  longsocialSecurityNumber = 1977_05_18_3312L;  float pi = 3.14_15F;  longhexBytes = 0xFF_EC_DE_5E;  longhexWords = 0xCAFE_BABE;  longmaxLong = 0x7fff_ffff_ffff_ffffL;   long bytes = 0b11010010_01101001_10010100_10010010;
Java SE 7 – Language Changes Number 5 - NOTE:Underscores in NumericLiterals You can place underscores only between digits; you cannot place underscores in the following places: At the beginning or end of a number Adjacent to a decimal point in a floating point literal Prior to an F or L suffix  In positions where a string of digits is expected 19 augusti 2011 Sida 15
Java SE 7 – ConcurrentUtilities Number 6:Fork/JoinFramework (JSR 166) ” a lightweightfork/joinframework with flexible and reusablesynchronizationbarriers, transfer queues, concurrent linked double-endedqueues, and thread-localpseudo-random-number generators.” 19 augusti 2011 Sida 16
Java SE 7 – ConcurrentUtilities Number 6:Fork/JoinFramework (JSR 166) 19 augusti 2011 Sida 17 if (my portion of the work is small enough)  	do the work directly  else  	split my work into two pieces invoke the two pieces and       	wait for the results
Java SE 7 – ConcurrentUtilities Number 6:Fork/JoinFramework (JSR 166) 19 augusti 2011 Sida 18
Java SE 7 – ConcurrentUtilities Number 6:Fork/JoinFramework (JSR 166) New Classes ,[object Object]
RecursiveTask
RecursiveAction
ThreadLocalRandom
ForkJoinPool19 augusti 2011 Sida 19
Java SE 7 – Filesystem API Number 7: 	NIO 2 Filesystem API (Non-Blocking I/O) Bettersupports for accessingfile systems such and support for customfile systems (e.g. cloudfile systems) Access to metadata such as file permissions Moreeffecient support whencopy/movingfiles EnchancedExceptionswhenworking on files, i.e. file.delete() nowthrowsIOException (not just Exception) 19 augusti 2011 Sida 20
Java SE 7 – JVM Enhancement Number 8:InvokeDynamic (JSR292) Support for dynamiclanguages so theirperformance levels is near to that of the Java language itself At byte code level this means a new operand (instruction) called invokedynamic Make is possible to do efficient method invocation for dynamic languages (such as JRuby) instead of statically (like Java) . Huge performance gain  19 augusti 2011 Sida 21
Java SE 7 – JVM Enhancement Number 9: 	G1 and JVM optimization G1 morepredictable and uses multiple coresbetterthan CMS Tiered Compilation –Bothclient and server JIT compilers are usedduringstarup NUMA optimization - Parallel Scavenger garbage collector has been extended to take advantage of machines with NUMA (~35% performance gain) EscapeAnalysis - analyze the scope of a new object's and decide whether to allocate it on the Java heap 19 augusti 2011 Sida 22
Java SE 7 – JVM Enhancement Number 9:EscapeAnalysis 19 augusti 2011 Sida 23 public class Person {      private String name; private int age;      public Person(String personName, intpersonAge) {  name = personName; age = personAge; }         public Person(Person p) {             this(p.getName(), p.getAge());         } }  public classEmployee {      private Person person; // makes a defensive copy to protectagainstmodifications by caller     public Person getPerson() {     return new Person(person)      };  public voidprintEmployeeDetail(Employeeemp) {      Person person = emp.getPerson(); // this callerdoes not modify the object, so defensive copywasunnecessary System.out.println ("Employee'sname: " + person.getName() + "; age: " + person.getAge()); }  }
Java SE 7 - Networking Number 10: 	Support for SDP  SocketDirectProtocol  (SDP) enablesJVMs to use Remote Direct Memory Access (RDMA). RDMA enables moving data directly from the memory of one computer to another computer, bypassing the operating system of both computers and resulting in significant performance gains.  The result is High throughput and Low latency (minimal delay between processing input and providing output) such as you would expect in a real-time application.  19 augusti 2011 Sida 24

More Related Content

What's hot

Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMTom Lee
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBossJBug Italy
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for KotlinTechMagic
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzJBug Italy
 
SoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringSoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringNayden Gochev
 
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingCracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingLuciano Mammino
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projectsjazzman1980
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyBruno Oliveira
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIGanesh Samarthyam
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Ganesh Samarthyam
 

What's hot (19)

Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Open Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVMOpen Source Compiler Construction for the JVM
Open Source Compiler Construction for the JVM
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBoss
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzz
 
SoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringSoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with Spring
 
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computingCracking JWT tokens: a tale of magic, Node.JS and parallel computing
Cracking JWT tokens: a tale of magic, Node.JS and parallel computing
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projects
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
 
Invoke dynamics
Invoke dynamicsInvoke dynamics
Invoke dynamics
 

Viewers also liked

Behavior-driven Development and Lambdaj
Behavior-driven Development and LambdajBehavior-driven Development and Lambdaj
Behavior-driven Development and LambdajAndreas Enbohm
 
BDD Short Introduction
BDD Short IntroductionBDD Short Introduction
BDD Short IntroductionAndreas Enbohm
 
Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?Andreas Enbohm
 
Java Extension Methods
Java Extension MethodsJava Extension Methods
Java Extension MethodsAndreas Enbohm
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software CraftsmanshipAndreas Enbohm
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new featuresShivam Goel
 
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 дней
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 днейГотовимся к Java SE 7 Programmer: от новичка до профессионала за 45 дней
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 днейSkillFactory
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 

Viewers also liked (8)

Behavior-driven Development and Lambdaj
Behavior-driven Development and LambdajBehavior-driven Development and Lambdaj
Behavior-driven Development and Lambdaj
 
BDD Short Introduction
BDD Short IntroductionBDD Short Introduction
BDD Short Introduction
 
Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?
 
Java Extension Methods
Java Extension MethodsJava Extension Methods
Java Extension Methods
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new features
 
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 дней
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 днейГотовимся к Java SE 7 Programmer: от новичка до профессионала за 45 дней
Готовимся к Java SE 7 Programmer: от новичка до профессионала за 45 дней
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 

Similar to Java7 - Top 10 Features

Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemRafael Winterhalter
 
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ..."Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...Vadym Kazulkin
 
Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Ivelin Yanev
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RaceBaruch Sadogursky
 
JBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java BoxJBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java BoxTikal Knowledge
 
Java 9 features
Java 9 featuresJava 9 features
Java 9 featuresshrinath97
 
Java one 2010
Java one 2010Java one 2010
Java one 2010scdn
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaHenri Tremblay
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklChristoph Pickl
 
Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Hirofumi Iwasaki
 

Similar to Java7 - Top 10 Features (20)

Java7 Features
Java7 FeaturesJava7 Features
Java7 Features
 
Java and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystemJava and OpenJDK: disecting the ecosystem
Java and OpenJDK: disecting the ecosystem
 
Java7
Java7Java7
Java7
 
Panama.pdf
Panama.pdfPanama.pdf
Panama.pdf
 
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ..."Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
"Highlights from Java 10&11 and Future of Java" at Java User Group Bonn 2018 ...
 
Java 7 & 8 New Features
Java 7 & 8 New FeaturesJava 7 & 8 New Features
Java 7 & 8 New Features
 
Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11Java features. Java 8, 9, 10, 11
Java features. Java 8, 9, 10, 11
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools Race
 
JBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java BoxJBUG 11 - Outside The Java Box
JBUG 11 - Outside The Java Box
 
Java 9 features
Java 9 featuresJava 9 features
Java 9 features
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
 
Java one 2010
Java one 2010Java one 2010
Java one 2010
 
Project Coin
Project CoinProject Coin
Project Coin
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
 
55j7
55j755j7
55j7
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph Pickl
 
Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8
 
Best Of Jdk 7
Best Of Jdk 7Best Of Jdk 7
Best Of Jdk 7
 
Tech Days 2010
Tech  Days 2010Tech  Days 2010
Tech Days 2010
 

Recently uploaded

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Recently uploaded (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Java7 - Top 10 Features

  • 1. Java SE 7 {finally} 2011-08-18 Andreas Enbohm
  • 2. 19 augusti 2011 Sida 2 Java SE 7 A evolutionaryevolement of Java 6 yearssince last update Somethingsleftout, will briefly discuss this at the end Oracle reallypushing Java forward- a lotpolitical problems with Sun made Java 7 postphonedseveraltimes Java still growing (1.42%), #1 mostusedlanguageaccording to TIOBE with 19.4% (Aug 2011) My top 10 new features (not ordered in anyway)
  • 3. Java SE 7 – Language Changes Number 1:Try-with-resources Statement (or ARM-blocks) Before : 19 augusti 2011 Sida 3 static String readFirstLineFromFileWithFinallyBlock(String path) throwsIOException { BufferedReaderbr = new BufferedReader(new FileReader(path)); try { returnbr.readLine(); } finally { if (br != null) { try { br.close(); } catch (IOExceptionignore){ //donothing } } } }
  • 4. Java SE 7 – Language Changes Number 1:Try-with-resources Statement (or ARM-blocks) With Java 7: 19 augusti 2011 Sida 4 static String readFirstLineFromFile(String path) throws IOException { try (BufferedReaderbr = new BufferedReader(new FileReader(path))) { return br.readLine(); } }
  • 5. Java SE 7 – Language Changes Number 1 - NOTE: The try-with-resources statement is a try statement that declares one or more resources. A resource is as an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource. 19 augusti 2011 Sida 5
  • 6. Java SE 7 – Language Changes Number 2: Strings in switch Statements 19 augusti 2011 Sida 6 public String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay; switch (dayOfWeekArg) { case "Monday": typeOfDay = "Start of work week"; break; case "Tuesday": case "Wednesday": case "Thursday": typeOfDay = "Midweek"; break; case "Friday": typeOfDay = "End of work week"; break; case "Saturday": case "Sunday": typeOfDay = "Weekend"; break; default: throw new IllegalArgumentException("Invalid day of the week: " + dayOfWeekArg); } return typeOfDay; }
  • 7. Java SE 7 – Language Changes Number 2 - NOTE: The Java compiler generates generally more efficient bytecode from switch statements that use String objects than from chained if-then-else statements. 19 augusti 2011 Sida 7
  • 8. Java SE 7 – Language Changes Number 3:Catching Multiple ExceptionTypes Before : Difficult to eliminatecodeduplicationdue to different exceptions! 19 augusti 2011 Sida 8 try { … } catch (IOException ex) { logger.log(ex); throw ex; } catch (SQLException ex) { logger.log(ex); throw ex; }
  • 9. Java SE 7 – Language Changes Number 3:Catching Multiple ExceptionTypes With Java 7 : 19 augusti 2011 Sida 9 try { … } catch (IOException|SQLException ex) { logger.log(ex); throw ex; }
  • 10. Java SE 7 – Language Changes Number 3 - NOTE:Catching Multiple ExceptionTypes Bytecode generated by compiling a catch block that handles multiple exception types will be smaller (and thus superior) than compiling many catch blocks that handle only one exception type each. 19 augusti 2011 Sida 10
  • 11. Java SE 7 – Language Changes Number 4:TypeInference for GenericInstance Creation Before: Howmanytimeshave you swornabout this duplicatedcode?  19 augusti 2011 Sida 11 Map<String, List<String>> myMap = new HashMap<String, List<String>>();
  • 12. Java SE 7 – Language Changes Number 4:TypeInference for GenericInstance Creation With Java 7: 19 augusti 2011 Sida 12 Map<String, List<String>> myMap = new HashMap<>();
  • 13. Java SE 7 – Language Changes Number 4 - NOTE:TypeInference for GenericInstance Creation Writing new HashMap() (withoutdiamond operator) will still use the rawtype of HashMap (compilerwarning) 19 augusti 2011 Sida 13
  • 14. Java SE 7 – Language Changes Number 5:Underscores in NumericLiterals 19 augusti 2011 Sida 14 longcreditCardNumber = 1234_5678_9012_3456L; longsocialSecurityNumber = 1977_05_18_3312L; float pi = 3.14_15F; longhexBytes = 0xFF_EC_DE_5E; longhexWords = 0xCAFE_BABE; longmaxLong = 0x7fff_ffff_ffff_ffffL; long bytes = 0b11010010_01101001_10010100_10010010;
  • 15. Java SE 7 – Language Changes Number 5 - NOTE:Underscores in NumericLiterals You can place underscores only between digits; you cannot place underscores in the following places: At the beginning or end of a number Adjacent to a decimal point in a floating point literal Prior to an F or L suffix In positions where a string of digits is expected 19 augusti 2011 Sida 15
  • 16. Java SE 7 – ConcurrentUtilities Number 6:Fork/JoinFramework (JSR 166) ” a lightweightfork/joinframework with flexible and reusablesynchronizationbarriers, transfer queues, concurrent linked double-endedqueues, and thread-localpseudo-random-number generators.” 19 augusti 2011 Sida 16
  • 17. Java SE 7 – ConcurrentUtilities Number 6:Fork/JoinFramework (JSR 166) 19 augusti 2011 Sida 17 if (my portion of the work is small enough) do the work directly else split my work into two pieces invoke the two pieces and wait for the results
  • 18. Java SE 7 – ConcurrentUtilities Number 6:Fork/JoinFramework (JSR 166) 19 augusti 2011 Sida 18
  • 19.
  • 24. Java SE 7 – Filesystem API Number 7: NIO 2 Filesystem API (Non-Blocking I/O) Bettersupports for accessingfile systems such and support for customfile systems (e.g. cloudfile systems) Access to metadata such as file permissions Moreeffecient support whencopy/movingfiles EnchancedExceptionswhenworking on files, i.e. file.delete() nowthrowsIOException (not just Exception) 19 augusti 2011 Sida 20
  • 25. Java SE 7 – JVM Enhancement Number 8:InvokeDynamic (JSR292) Support for dynamiclanguages so theirperformance levels is near to that of the Java language itself At byte code level this means a new operand (instruction) called invokedynamic Make is possible to do efficient method invocation for dynamic languages (such as JRuby) instead of statically (like Java) . Huge performance gain 19 augusti 2011 Sida 21
  • 26. Java SE 7 – JVM Enhancement Number 9: G1 and JVM optimization G1 morepredictable and uses multiple coresbetterthan CMS Tiered Compilation –Bothclient and server JIT compilers are usedduringstarup NUMA optimization - Parallel Scavenger garbage collector has been extended to take advantage of machines with NUMA (~35% performance gain) EscapeAnalysis - analyze the scope of a new object's and decide whether to allocate it on the Java heap 19 augusti 2011 Sida 22
  • 27. Java SE 7 – JVM Enhancement Number 9:EscapeAnalysis 19 augusti 2011 Sida 23 public class Person { private String name; private int age; public Person(String personName, intpersonAge) { name = personName; age = personAge; } public Person(Person p) { this(p.getName(), p.getAge()); } } public classEmployee { private Person person; // makes a defensive copy to protectagainstmodifications by caller public Person getPerson() { return new Person(person) }; public voidprintEmployeeDetail(Employeeemp) { Person person = emp.getPerson(); // this callerdoes not modify the object, so defensive copywasunnecessary System.out.println ("Employee'sname: " + person.getName() + "; age: " + person.getAge()); } }
  • 28. Java SE 7 - Networking Number 10: Support for SDP  SocketDirectProtocol (SDP) enablesJVMs to use Remote Direct Memory Access (RDMA). RDMA enables moving data directly from the memory of one computer to another computer, bypassing the operating system of both computers and resulting in significant performance gains. The result is High throughput and Low latency (minimal delay between processing input and providing output) such as you would expect in a real-time application. 19 augusti 2011 Sida 24
  • 29. Java SE 7 - Networking Number 10 - NOTE: Support for SDP The Sockets Direct Protocol (SDP) is a networking protocol developed to support stream connections over InfiniBand fabric. Solaris 10 5/08 has support for InfiniBand fabric (which enables RDMA). On Linux, the InfiniBand package is called OFED (OpenFabrics Enterprise Distribution). 19 augusti 2011 Sida 25
  • 30. Java SE 7 A complete list of all new features can be seen on http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html 19 augusti 2011 Sida 26
  • 31. Java SE 8 Some features whereleftout in Java 7; mostimportant are Project Lambda (closures) and Project Jigsaw (modules) targeted for Java 8 (late 2012) Lambdas (and extension methods) willprobably be the biggestsinglechangeevermade on the JVM. Will introduce a powerfulprogrammingmodel, however it comes with a great deal of complexity as well. Moduleswillmade it easier to version modules (no moreJAR-hell) and introducea new way of definingclasspaths 19 augusti 2011 Sida 27
  • 32. Java SE 7 & 8 Questions? 19 augusti 2011 Sida 28