You are on page 1of 16

Whats New in Java 7

for
San Antonio Java User Group
May 2010
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
Top 5 Main features in Java 7
Modularity
Language Changes
Multi Language Virtual Machine
Garbage Collector
New File I/O API
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
Modularity What is the need?

Java SE has grown


More and more functionality is added in Java SE
Java SE the foundation of Java EE
Underlying Implementation code is interconnected
Class path ell
!o version management for J"#s
!o dependencies mechanism
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
Module an Example
module A !"#
$
re%uires & '"!(
re%uires C !"!(
)
module definition stored in module$
info%&ava
module A(
*ac+age com"sam*le(
*ublic class sam*le class
$
*ublic ,oid sam*le-.
$)
)
$'he sample class (elongs to the module
" version )%*
$ 'his class is pu(lic
$ If class or one of its mem(ers or
constructors is declared module+ it will (e
accessi(le from a type that (elongs to the
same module
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
an!ua!e "han!es
/ Additions to the 0a,a Language itsel1
/ 2un ,ery much conser,ation to language additions
/ because language changes are *ermanent and cannot
be remo,ed
/ No big 1eatures li+e su**ort 1or closures
/ Only sim*le and use1ul language changes in 0a,a 3
/ 4nder the O*en 2ource Pro5ect Coin -signi1ies small
changes.
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
an!ua!e "han!es #trin!s in swit$h
2tring s 6 7"(
switch-s.
$
case 8subbu89
2ystem"err"*rintln-8It is subbu man:8.(
brea+(
case 8ryan89
2ystem"err"*rintln-8It is ryan man:8.(
brea+(
case 85ohn89
de1ault9
2ystem"err"*rintln-8;e1ault8.(
brea+(
)
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
an!ua!e "han!es Multiple Ex$eption %andlin!
try
$
//do someting(
)
catch-<=ce*tion!> <=ce*tion' e.
$
handle<=ce*tion-e.
)
try
$
//do someting(
)
catch-<=ce*tion! e.
$
handle<=ce*tion-e.
)
catch-2?L<=ce*tion e.
$
handle<=ce*tion-e.
)
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
an!ua!e "han!es &mproved Type
&nferen$e
Ma*@2tring> IntegerA 6 new BashMa*@2tring> IntegerA-.(
Ma*@2tring> IntegerA 6 new BashMa*@A-.(
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
an!ua!e "han!es Elvis 'perator
Standard example:
2tring s 6 may&eNullC"to2tring-. C9 8null8(
Auto-unboxing example:
Integer i,al 6 """( // may be null
int i 6 i,al C9 /!( // no NP< 1rom unbo=ing
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
an!ua!e "han!es Elvis 'perator
Standard example:
2tring s 6 may&eNullC"to2tring-. C9 8null8(
Auto-unboxing example:
Integer i,al 6 """( // may be null
int i 6 i,al C9 /!( // no NP< 1rom unbo=ing
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
Multi an!ua!e (irtual Ma$hine
0a,a D *ro,ided the ca*ability to *lug/in other languages in the
VM
0a,a 3 to be strengthened to ma+e the other languages run e,en
better in the 0VM
0VM to be o*timiEed to ma+e the language s*eci1ic 1eatures run
better -<=9 Closures.
Pro,ided by O*en 2ource Pro5ect ;aVinci
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
imitation of $urrent &)' *+&
;eletion is not guaranteed" Need to do a chec+ to determine i1 the
1ile is deleted"
O*erations on directory are not scalable and run on the *arent
thread
Polling will need to be done 1or changes on 1iles
New &)' *+&s
New File 2ystem API
File Noti1ications
;irectory O*erations
Asynchronous I/#
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
New &)' *+&s , Example
Path searcPath 6 Paths"get-Fc9/sam*leG.(
1inal Path 1indFile 6 Paths"get-Fsam*le1ileG.(
FileVisitor ,isitor 6 new 2im*leFileVisitor-.
$
*ublic FileVisitHesult ,isitFile-Path 1ile> &asicFileAttributes
attrs.
$
i1-1ile"getName-."startsIith-1indFile.
$
//do something
)
)
)(
Files"wal+FileJree-searcPath> ,isitor.(
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
-ar.a!e /irst
New Garbage Collector introduced in 0a,a 3
It is called the Garbage First Collector
Memory s*lit into multi*le regions as o**osed to ' regions in the
current ,ersion
?uite *redictable and *ro,ides greater through *ut 1or memory
intensi,e a**lications
Per1orms 1aster than the current *arallel collectors"
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
New &)' *+&s , Example
Path searcPath 6 Paths"get-Fc9/sam*leG.(
1inal Path 1indFile 6 Paths"get-Fsam*le1ileG.(
FileVisitor ,isitor 6 new 2im*leFileVisitor-.
$
*ublic FileVisitHesult ,isitFile-Path 1ile> &asicFileAttributes
attrs.
$
i1-1ile"getName-."startsIith-1indFile.
$
//do something
)
)
)(
Files"wal+FileJree-searcPath> ,isitor.(
Whats New in Java 7
San Antonio Java User Group Subramanian Murali
May 2010
Any Questions? Thank You

You might also like