SlideShare a Scribd company logo
Java SE 7 {finally}

2011-08-18
Andreas Enbohm

© 2004 Capgemini - All rights reserved
Java SE 7

A evolutionary evolement of Java
6 years since last update
Some things left out, will briefly discuss this at the end
Oracle really pushing Java forward
- a lot political problems with Sun made Java 7 postphoned
several times
Java still growing (1.42%), #1 most used language according to
TIOBE with 19.4% (Aug 2011)
My top 10 new features (not ordered in any way )

Sida 2
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 1:
Before :

Sida 3
15 januari 2014
© 2009 Capgemini - All rights reserved

Try-with-resources Statement (or ARM-blocks)

static String readFirstLineFromFileWithFinallyBlock(String path)
throws IOException {
BufferedReader br = new BufferedReader(new FileReader(path));
try {
return br.readLine();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ignore){
//do nothing
}
}
}
}
Java SE 7 – Language Changes

Number 1:

Try-with-resources Statement (or ARM-blocks)

With Java 7:
static String readFirstLineFromFile(String path) throws IOException {
try (BufferedReader br = new BufferedReader(new FileReader(path))) {
return br.readLine();
}
}

Sida 4
15 januari 2014
© 2009 Capgemini - All rights reserved
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.

Sida 5
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 2:

Strings in switch Statements

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;
}
Sida 6
15 januari 2014
© 2009 Capgemini - All rights reserved
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.

Sida 7
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 3:
Before :

Catching Multiple Exception Types

try {
…
} catch (IOException ex) {
logger.log(ex);
throw ex;
} catch (SQLException ex) {
logger.log(ex);
throw ex;
}

Difficult to eliminate code duplication due to different exceptions!
Sida 8
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 3:

Catching Multiple Exception Types

With Java 7 :
try {
…
} catch (IOException|SQLException ex) {
logger.log(ex);
throw ex;
}

Sida 9
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 3 - NOTE: Catching Multiple Exception Types
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.

Sida 10
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 4:

Type Inference for Generic Instance Creation

Before:
Map<String, List<String>> myMap = new HashMap<String, List<String>>();

How many times have you sworn about this duplicated code? 

Sida 11
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 4:

Type Inference for Generic Instance Creation

With Java 7:
Map<String, List<String>> myMap = new HashMap<>();

Sida 12
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 4 - NOTE: Type Inference for Generic Instance Creation
Writing new HashMap() (without diamond operator) will still use the
raw type of HashMap (compiler warning)

Sida 13
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 5:

Underscores in Numeric Literals

long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumber = 1977_05_18_3312L;
float pi = 3.14_15F;
long hexBytes = 0xFF_EC_DE_5E;
long hexWords = 0xCAFE_BABE;
long maxLong = 0x7fff_ffff_ffff_ffffL;
long bytes = 0b11010010_01101001_10010100_10010010;

Sida 14
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Language Changes

Number 5 - NOTE: Underscores in Numeric Literals
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

Sida 15
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Concurrent Utilities

Number 6:

Fork/Join Framework (JSR 166)

” a lightweight fork/join framework with flexible and reusable
synchronization barriers, transfer queues, concurrent linked
double-ended queues, and thread-local pseudo-random-number
generators.”

Sida 16
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Concurrent Utilities

Number 6:

Fork/Join Framework (JSR 166)

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

Sida 17
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Concurrent Utilities

Number 6:

Sida 18
15 januari 2014
© 2009 Capgemini - All rights reserved

Fork/Join Framework (JSR 166)
Java SE 7 – Concurrent Utilities

Number 6:

Fork/Join Framework (JSR 166)

New Classes
•

ForkJoinTask

•

RecursiveTask

•

RecursiveAction

•

ThreadLocalRandom

•

ForkJoinPool

Sida 19
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – Filesystem API

Number 7:

NIO 2 Filesystem API (Non-Blocking I/O)

Better supports for accessing file systems such and support for
custom file systems (e.g. cloud file systems)

Access to metadata such as file permissions
More effecient support when copy/moving files
Enchanced Exceptions when working on files, i.e.
file.delete() now throws IOException (not just Exception)

Sida 20
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – JVM Enhancement

Number 8:

Invoke Dynamic (JSR292)

Support for dynamic languages so their performance 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

Sida 21
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – JVM Enhancement

Number 9:

G1 and JVM optimization

G1 more predictable and uses multiple cores better than CMS
Tiered Compilation –Both client and server JIT compilers are
used during starup
NUMA optimization - Parallel Scavenger garbage collector has
been extended to take advantage of machines with NUMA (~35%
performance gain)
Escape Analysis - analyze the scope of a new object's and decide
whether to allocate it on the Java heap
Sida 22
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 – JVM Enhancement

Number 9:

Escape Analysis

public class Person {
private String name; private int age;
public Person(String personName, int personAge) {
name = personName; age = personAge; }
public Person(Person p) {
this(p.getName(), p.getAge());
}
}
public class Employee {
private Person person; // makes a defensive copy to protect against modifications by caller
public Person getPerson() {
return new Person(person)
};
public void printEmployeeDetail(Employee emp) {
Person person = emp.getPerson(); // this caller does not modify the object, so defensive copy was unnecessary
System.out.println ("Employee's name: " + person.getName() + "; age: " + person.getAge()); }
}
Sida 23
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 - Networking
Number 10: Support for SDP 
Socket Direct Protocol (SDP) enables JVMs 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.

Sida 24
15 januari 2014
© 2009 Capgemini - All rights reserved
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).

Sida 25
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7

A complete list of all new features can be seen on
http://www.oracle.com/technetwork/java/javase/jdk7-relnotes418459.html

Sida 26
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 8
Some features where left out in Java 7; most important are Project
Lambda (closures) and Project Jigsaw (modules) targeted for
Java 8 (late 2012)
Lambdas (and extension methods) will probably be the biggest single
change ever made on the JVM. Will introduce a powerful
programming model, however it comes with a great deal of
complexity as well.
Modules will made it easier to version modules (no more JAR-hell)
and introduce a new way of defining classpaths
Sida 27
15 januari 2014
© 2009 Capgemini - All rights reserved
Java SE 7 & 8

Questions?

Sida 28
15 januari 2014
© 2009 Capgemini - All rights reserved

More Related Content

Viewers also liked (15)

PPT
Systems Of The Body
ToekneeH
 
PDF
Psm 280 A Best Practices In Advancing Customer Marketing Innovations
Cameron Tew
 
PDF
Casco insurance claims handling, If P&C insurance case study
Mihails Galuška
 
PDF
Debt Management, Collection on Ultimus BPM platform
Mihails Galuška
 
PPS
People Jam!
anshul2
 
PPTX
Hippocrates 2.0
Cristiano
 
PPT
Супермаркет услуг interinformer.com (для продавцов)
Mihails Galuška
 
PDF
Hol webinar summary
Cameron Tew
 
PDF
Concurrency gotchas
Jitender Jain
 
PDF
Elconceptodedisciplinaescolar.roberto l´hotelleríe
Ronald Heisele
 
PPT
Java basics
Jitender Jain
 
PDF
CASCO insurance claims handling
Mihails Galuška
 
PPT
Medical Science Liaison Webinarv 2009
Cameron Tew
 
PPT
Sales Force Short Version
Cameron Tew
 
Systems Of The Body
ToekneeH
 
Psm 280 A Best Practices In Advancing Customer Marketing Innovations
Cameron Tew
 
Casco insurance claims handling, If P&C insurance case study
Mihails Galuška
 
Debt Management, Collection on Ultimus BPM platform
Mihails Galuška
 
People Jam!
anshul2
 
Hippocrates 2.0
Cristiano
 
Супермаркет услуг interinformer.com (для продавцов)
Mihails Galuška
 
Hol webinar summary
Cameron Tew
 
Concurrency gotchas
Jitender Jain
 
Elconceptodedisciplinaescolar.roberto l´hotelleríe
Ronald Heisele
 
Java basics
Jitender Jain
 
CASCO insurance claims handling
Mihails Galuška
 
Medical Science Liaison Webinarv 2009
Cameron Tew
 
Sales Force Short Version
Cameron Tew
 

Similar to Java7 Features (20)

PPTX
Java7 - Top 10 Features
Andreas Enbohm
 
PPTX
Java se7 features
Kumaraswamy M
 
PPTX
JavaOne 2011 Recap
Jim Bethancourt
 
PPT
Java SE 7 New Features and Enhancements
Fu Cheng
 
ODT
Best Of Jdk 7
Kaniska Mandal
 
PPT
Java7
Dinesh Guntha
 
PDF
Java se 7 new language features
Juarez Junior
 
PDF
What's new in Java 8
jclingan
 
PDF
Java 8
jclingan
 
KEY
Introduction to Java 7 (OSCON 2012)
Martijn Verburg
 
PPTX
Java 7 & 8
Ken Coenen
 
PPTX
Java 7 & 8 New Features
Leandro Coutinho
 
KEY
Back to the future with Java 7 (Geekout June/2011)
Martijn Verburg
 
PDF
engage 2016 - Get ready for moving from Java 6 to Java 8 - Now!
René Winkelmeyer
 
PPTX
Java SE 8 - New Features
Naveen Hegde
 
PPTX
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
PPTX
Java 7 & 8 - A&BP CC
JWORKS powered by Ordina
 
PDF
Java SE 8 & EE 7 Launch
Digicomp Academy AG
 
PPT
Java 7 new features
Shivam Goel
 
PDF
What to expect from Java 9
Ivan Krylov
 
Java7 - Top 10 Features
Andreas Enbohm
 
Java se7 features
Kumaraswamy M
 
JavaOne 2011 Recap
Jim Bethancourt
 
Java SE 7 New Features and Enhancements
Fu Cheng
 
Best Of Jdk 7
Kaniska Mandal
 
Java se 7 new language features
Juarez Junior
 
What's new in Java 8
jclingan
 
Java 8
jclingan
 
Introduction to Java 7 (OSCON 2012)
Martijn Verburg
 
Java 7 & 8
Ken Coenen
 
Java 7 & 8 New Features
Leandro Coutinho
 
Back to the future with Java 7 (Geekout June/2011)
Martijn Verburg
 
engage 2016 - Get ready for moving from Java 6 to Java 8 - Now!
René Winkelmeyer
 
Java SE 8 - New Features
Naveen Hegde
 
Java 7 Whats New(), Whats Next() from Oredev
Mattias Karlsson
 
Java 7 & 8 - A&BP CC
JWORKS powered by Ordina
 
Java SE 8 & EE 7 Launch
Digicomp Academy AG
 
Java 7 new features
Shivam Goel
 
What to expect from Java 9
Ivan Krylov
 
Ad

Recently uploaded (20)

PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Ad

Java7 Features

  • 1. Java SE 7 {finally} 2011-08-18 Andreas Enbohm © 2004 Capgemini - All rights reserved
  • 2. Java SE 7 A evolutionary evolement of Java 6 years since last update Some things left out, will briefly discuss this at the end Oracle really pushing Java forward - a lot political problems with Sun made Java 7 postphoned several times Java still growing (1.42%), #1 most used language according to TIOBE with 19.4% (Aug 2011) My top 10 new features (not ordered in any way ) Sida 2 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 3. Java SE 7 – Language Changes Number 1: Before : Sida 3 15 januari 2014 © 2009 Capgemini - All rights reserved Try-with-resources Statement (or ARM-blocks) static String readFirstLineFromFileWithFinallyBlock(String path) throws IOException { BufferedReader br = new BufferedReader(new FileReader(path)); try { return br.readLine(); } finally { if (br != null) { try { br.close(); } catch (IOException ignore){ //do nothing } } } }
  • 4. Java SE 7 – Language Changes Number 1: Try-with-resources Statement (or ARM-blocks) With Java 7: static String readFirstLineFromFile(String path) throws IOException { try (BufferedReader br = new BufferedReader(new FileReader(path))) { return br.readLine(); } } Sida 4 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 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. Sida 5 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 6. Java SE 7 – Language Changes Number 2: Strings in switch Statements 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; } Sida 6 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 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. Sida 7 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 8. Java SE 7 – Language Changes Number 3: Before : Catching Multiple Exception Types try { … } catch (IOException ex) { logger.log(ex); throw ex; } catch (SQLException ex) { logger.log(ex); throw ex; } Difficult to eliminate code duplication due to different exceptions! Sida 8 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 9. Java SE 7 – Language Changes Number 3: Catching Multiple Exception Types With Java 7 : try { … } catch (IOException|SQLException ex) { logger.log(ex); throw ex; } Sida 9 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 10. Java SE 7 – Language Changes Number 3 - NOTE: Catching Multiple Exception Types 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. Sida 10 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 11. Java SE 7 – Language Changes Number 4: Type Inference for Generic Instance Creation Before: Map<String, List<String>> myMap = new HashMap<String, List<String>>(); How many times have you sworn about this duplicated code?  Sida 11 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 12. Java SE 7 – Language Changes Number 4: Type Inference for Generic Instance Creation With Java 7: Map<String, List<String>> myMap = new HashMap<>(); Sida 12 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 13. Java SE 7 – Language Changes Number 4 - NOTE: Type Inference for Generic Instance Creation Writing new HashMap() (without diamond operator) will still use the raw type of HashMap (compiler warning) Sida 13 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 14. Java SE 7 – Language Changes Number 5: Underscores in Numeric Literals long creditCardNumber = 1234_5678_9012_3456L; long socialSecurityNumber = 1977_05_18_3312L; float pi = 3.14_15F; long hexBytes = 0xFF_EC_DE_5E; long hexWords = 0xCAFE_BABE; long maxLong = 0x7fff_ffff_ffff_ffffL; long bytes = 0b11010010_01101001_10010100_10010010; Sida 14 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 15. Java SE 7 – Language Changes Number 5 - NOTE: Underscores in Numeric Literals 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 Sida 15 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 16. Java SE 7 – Concurrent Utilities Number 6: Fork/Join Framework (JSR 166) ” a lightweight fork/join framework with flexible and reusable synchronization barriers, transfer queues, concurrent linked double-ended queues, and thread-local pseudo-random-number generators.” Sida 16 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 17. Java SE 7 – Concurrent Utilities Number 6: Fork/Join Framework (JSR 166) 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 Sida 17 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 18. Java SE 7 – Concurrent Utilities Number 6: Sida 18 15 januari 2014 © 2009 Capgemini - All rights reserved Fork/Join Framework (JSR 166)
  • 19. Java SE 7 – Concurrent Utilities Number 6: Fork/Join Framework (JSR 166) New Classes • ForkJoinTask • RecursiveTask • RecursiveAction • ThreadLocalRandom • ForkJoinPool Sida 19 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 20. Java SE 7 – Filesystem API Number 7: NIO 2 Filesystem API (Non-Blocking I/O) Better supports for accessing file systems such and support for custom file systems (e.g. cloud file systems) Access to metadata such as file permissions More effecient support when copy/moving files Enchanced Exceptions when working on files, i.e. file.delete() now throws IOException (not just Exception) Sida 20 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 21. Java SE 7 – JVM Enhancement Number 8: Invoke Dynamic (JSR292) Support for dynamic languages so their performance 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 Sida 21 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 22. Java SE 7 – JVM Enhancement Number 9: G1 and JVM optimization G1 more predictable and uses multiple cores better than CMS Tiered Compilation –Both client and server JIT compilers are used during starup NUMA optimization - Parallel Scavenger garbage collector has been extended to take advantage of machines with NUMA (~35% performance gain) Escape Analysis - analyze the scope of a new object's and decide whether to allocate it on the Java heap Sida 22 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 23. Java SE 7 – JVM Enhancement Number 9: Escape Analysis public class Person { private String name; private int age; public Person(String personName, int personAge) { name = personName; age = personAge; } public Person(Person p) { this(p.getName(), p.getAge()); } } public class Employee { private Person person; // makes a defensive copy to protect against modifications by caller public Person getPerson() { return new Person(person) }; public void printEmployeeDetail(Employee emp) { Person person = emp.getPerson(); // this caller does not modify the object, so defensive copy was unnecessary System.out.println ("Employee's name: " + person.getName() + "; age: " + person.getAge()); } } Sida 23 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 24. Java SE 7 - Networking Number 10: Support for SDP  Socket Direct Protocol (SDP) enables JVMs 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. Sida 24 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 25. 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). Sida 25 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 26. Java SE 7 A complete list of all new features can be seen on http://www.oracle.com/technetwork/java/javase/jdk7-relnotes418459.html Sida 26 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 27. Java SE 8 Some features where left out in Java 7; most important are Project Lambda (closures) and Project Jigsaw (modules) targeted for Java 8 (late 2012) Lambdas (and extension methods) will probably be the biggest single change ever made on the JVM. Will introduce a powerful programming model, however it comes with a great deal of complexity as well. Modules will made it easier to version modules (no more JAR-hell) and introduce a new way of defining classpaths Sida 27 15 januari 2014 © 2009 Capgemini - All rights reserved
  • 28. Java SE 7 & 8 Questions? Sida 28 15 januari 2014 © 2009 Capgemini - All rights reserved