SlideShare a Scribd company logo
Java 8: 
Create The Future 
Simon Ritter 
Head of Java Technology Evangelism 
Oracle Corp. 
Twitter: @speakjava 
Copyright © 2012, Oracle and/or its affiliates. 1 All rights reserved.
The following is intended to outline our general product 
direction. It is intended for information purposes only, and may 
not be incorporated into any contract. It is not a commitment 
to deliver any material, code, or functionality, and should not 
be relied upon in making purchasing decisions. 
The development, release, and timing of any features or 
functionality described for Oracle’s products remains at the 
sole discretion of Oracle. 
Copyright © 2012, Oracle and/or its affiliates. 2 All rights reserved.
Java SE 8 New Features 
(Other Than Lambdas and Streams) 
Copyright © 2012, Oracle and/or its affiliates. 3 All rights reserved.
Annotations On Java Types 
§ Annotations can currently only be used on type declarations 
– Classes, methods, variable definitions 
§ Extension for places where types are used 
– e.g. parameters 
§ Permits error detection by pluggable type checkers 
– e.g. null pointer errors, race conditions, etc 
public void process(@notnull List data) {…} 
Copyright © 2012, Oracle and/or its affiliates. 4 All rights reserved.
Access To Parameter Names At Runtime 
§ Mechanism to retrieve parameter names of methods and constructors 
– At runtime via core reflection 
§ Improved code readability 
– Eliminate redundant annotations 
§ Improve IDE capabilities 
– Auto-generate template code 
§ Method and Constructor now inherit from new Executable class 
– getParameters() returns array of Parameter objects 
– Name, type, annotations for each parameter 
Copyright © 2012, Oracle and/or its affiliates. 5 All rights reserved.
Concurrency Updates 
§ Scalable update variables 
– DoubleAccumulator, DoubleAdder, etc 
– Multiple variables avoid update contention 
– Good for frequent updates, infrequent reads 
§ ConcurrentHashMap updates 
– Improved scanning support, key computation 
§ ForkJoinPool improvements 
– Completion based design for IO bound applications 
– Thread that is blocked hands work to thread that is running 
Copyright © 2012, Oracle and/or its affiliates. 6 All rights reserved.
Parallel Array Sorting 
§ Additional utility methods in java.util.Arrays 
– parallelSort (multiple signatures for different primitives) 
§ Anticipated minimum improvement of 30% over sequential sort 
– For dual core system with appropriate sized data set 
§ Built on top of the fork-join framework 
– Uses Doug Lea’s ParallelArray implementation 
– Requires working space the same size as the array being sorted 
Copyright © 2012, Oracle and/or its affiliates. 7 All rights reserved.
Date And Time APIs 
§ A new date, time, and calendar API for the Java SE platform 
§ Supports standard time concepts 
– Partial, duration, period, intervals 
– date, time, instant, and time-zone 
§ Provides a limited set of calendar systems and be extensible to others 
§ Uses relevant standards, including ISO-8601, CLDR, and BCP47 
§ Based on an explicit time-scale with a connection to UTC 
Copyright © 2012, Oracle and/or its affiliates. 8 All rights reserved.
Unicode 6.2 
§ Java SE 7 support Unicode 6.0 
§ Changes in Unicode 6.1 (February, 2012) 
– Add 11 new blocks to java.lang.Character.UnicodeBlock 
– Add 7 new scripts to java.lang.Character.UnicodeScript 
– Support over 700 new characters in java.lang.Character, String, 
and other classes 
§ Changes in Unicode 6.2 (September, 2012) 
– Support a new Turkish currency sign (U+20BA) 
Copyright © 2012, Oracle and/or its affiliates. 9 All rights reserved.
HTTP URL Permissions 
§ New type of network permission 
– Grant access in terms of URLs, rather than IP addresses 
§ Current way to specify network permissions 
– java.net.SocketPermission 
– Not restricted to just HTTP 
– Operates in terms of IP addresses only 
§ New, higher level capabilities 
– Support HTTP operations (POST, GET, etc) 
– Build on limited doPrivileged feature 
Copyright © 2012, Oracle and/or its affiliates. 10 All rights reserved.
Compact Profiles 
Approximate static footprint goals 
Compact1 Profile 
Compact2 Profile 
Compact3 Profile 
11Mb 
16Mb 
Full JRE 54Mb 
Copyright © 2012, Oracle and/or its affiliates. 11 All rights reserved. 
30Mb
Nashorn JavaScript Engine 
§ Lightweight, high-performance JavaScript engine 
– Integrated into JRE 
§ Use existing javax.script API 
§ ECMAScript-262 Edition 5.1 language specification compliance 
§ New command-line tool, jjs to run JavaScript 
§ Internationalised error messages and documentation 
Copyright © 2012, Oracle and/or its affiliates. 12 All rights reserved.
Retire Rarely-Used GC Combinations 
§ Rarely used 
– DefNew + CMS 
– ParNew + SerialOld 
– Incremental CMS 
§ Large testing effort for little return 
§ Will generate deprecated option messages 
– Won’t disappear just yet 
Copyright © 2012, Oracle and/or its affiliates. 13 All rights reserved.
Remove The Permanent Generation 
Permanently 
§ No more need to tune the size of it 
§ Current objects moved to Java heap or native memory 
– Interned strings 
– Class metadata 
– Class static variables 
§ Part of the HotSpot, JRockit convergence 
Copyright © 2012, Oracle and/or its affiliates. 14 All rights reserved.
Lambdas And Streams 
Copyright © 2012, Oracle and/or its affiliates. 15 All rights reserved.
Concurrency in Java Project Lambda 
java.util.concurrent 
(jsr166) 
java.lang.Thread 
1.4 5.0 6 7 8 
2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 
Copyright © 2012, Oracle and/or its affiliates. 16 All rights reserved. 
Fork/Join Framework 
(jsr166y) 
Phasers, etc 
(jsr166)
The Problem: External Iteration 
List<Student> students = ... 
double highestScore = 0.0; 
for (Student s : students) { 
if (s.getGradYear() == 2011) { 
if (s.getScore() > highestScore) { 
highestScore = s.getScore(); 
} 
} 
} 
Copyright © 2012, Oracle and/or its affiliates. 17 All rights reserved. 
• Our code controls iteration 
• Inherently serial: iterate from 
beginning to end 
• Not thread-safe because 
business logic is stateful 
(mutable accumulator 
variable)
Internal Iteration With Inner Classes 
Copyright © 2012, Oracle and/or its affiliates. 18 All rights reserved. 
§ Iteration handled by the library 
§ Not inherently serial – traversal 
may be done in parallel 
§ Traversal may be done lazily – so 
one pass, rather than three 
§ Thread safe – client logic is 
stateless 
§ High barrier to use 
– Syntactically ugly 
More Functional, Fluent 
List<Student> students = ... 
double highestScore = students. 
filter(new Predicate<Student>() { 
public boolean op(Student s) { 
return s.getGradYear() == 2011; 
} 
}). 
map(new Mapper<Student,Double>() { 
public Double extract(Student s) { 
return s.getScore(); 
} 
}). 
max();
Internal Iteration With Lambdas 
SomeList<Student> students = ... 
double highestScore = students. 
filter(Student s -> s.getGradYear() == 2011). 
map(Student s -> s.getScore()). 
max(); 
Copyright © 2012, Oracle and/or its affiliates. 19 All rights reserved. 
• More readable 
• More abstract 
• Less error-prone
Lambda Expressions 
Some Details 
§ Lambda expressions represent anonymous functions 
– Same structure as a method 
§ typed argument list, return type, set of thrown exceptions, and a body 
– Not associated with a class 
§ We now have parameterised behaviour, not just values 
double highestScore = students. 
filter(Student s -> s.getGradYear() == 2011). 
map(Student s -> s.getScore()) 
max(); 
What 
Copyright © 2012, Oracle and/or its affiliates. 20 All rights reserved. 
How
Lambda Expression Types 
• Single-method interfaces are used extensively in Java 
– Definition: a functional interface is an interface with one abstract method 
– Functional interfaces are identified structurally 
– The type of a lambda expression will be a functional interface 
§ Lambda expressions provide implementations of the abstract method 
interface Comparator<T> { boolean compare(T x, T y); } 
interface FileFilter { boolean accept(File x); } 
interface Runnable { void run(); } 
interface ActionListener { void actionPerformed(…); } 
interface Callable<T> { T call(); } 
Copyright © 2012, Oracle and/or its affiliates. 21 All rights reserved.
Local Variable Capture 
• Lambda expressions can refer to effectively final local variables from 
the enclosing scope 
• Effectively final: A variable that meets the requirements for final variables 
(i.e., assigned once), even if not explicitly declared final 
• Closures on values, not variables 
void expire(File root, long before) { 
root.listFiles(File p -> p.lastModified() <= before); 
} 
Copyright © 2012, Oracle and/or its affiliates. 22 All rights reserved.
What Does ‘this’ Mean For Lambdas? 
• ‘this’ refers to the enclosing object, not the lambda itself 
• Think of ‘this’ as a final predefined local 
• Remember the Lambda is an anonymous function 
class SessionManager { 
long before = ...; 
void expire(File root) { 
// refers to ‘this.before’, just like outside the lambda 
root.listFiles(File p -> checkExpiry(p.lastModified(), this.before)); 
} 
boolean checkExpiry(long time, long expiry) { ... } 
} 
Copyright © 2012, Oracle and/or its affiliates. 23 All rights reserved.
Type Inference 
§ The compiler can often infer parameter types in a lambda expression 
§ Inferrence based on the target functional interface’s method signature 
static T void sort(List<T> l, Comparator<? super T> c); 
List<String> list = getList(); 
Collections.sort(list, (String x, String y) -> x.length() - y.length()); 
Collections.sort(list, (x, y) -> x.length() - y.length()); 
§ Fully statically typed (no dynamic typing sneaking in) 
– More typing with less typing 
Copyright © 2012, Oracle and/or its affiliates. 24 All rights reserved.
Method References 
• Method references let us reuse a method as a lambda expression 
• Also work for constructors 
FileFilter x = File f -> f.canRead(); 
FileFilter x = File::canRead; 
Copyright © 2012, Oracle and/or its affiliates. 25 All rights reserved.
Copyright © 2012, Oracle and/or its affiliates. 26 All rights reserved. 
Library Evolution
Library Evolution Goal 
§ Requirement: aggregate operations on collections 
– New methods required on Collections to facilitate this 
int heaviestBlueBlock = blocks. 
filter(b -> b.getColor() == BLUE). 
map(Block::getWeight). 
reduce(0, Integer::max); 
§ This is problematic 
– Can’t add new methods to interfaces without modifying all implementations 
– Can’t necessarily find or control all implementations 
Copyright © 2012, Oracle and/or its affiliates. 27 All rights reserved.
Solution: Default Methods 
• Specified in the interface 
• From the caller’s perspective, just an ordinary interface method 
• Provides a default implementation 
• Default only used when implementation classes do not provide a body for 
the extension method 
• Implementation classes can provide a better version, or not 
interface Collection<E> { 
default Stream<E> stream() { 
return StreamSupport.stream(spliterator()); 
} 
} 
Copyright © 2012, Oracle and/or its affiliates. 28 All rights reserved.
Virtual Extension Methods 
Stop right there! 
• Err, isn’t this implementing multiple inheritance for Java? 
• Yes, but Java already has multiple inheritance of types 
• This adds multiple inheritance of behavior too 
• But not state, which is where most of the trouble is 
• Can still be a source of complexity 
• Class implements two interfaces, both of which have default methods 
• Same signature 
• How does the compiler differentiate? 
• Static methods also allowed in interfaces in Java SE 8 
Copyright © 2012, Oracle and/or its affiliates. 29 All rights reserved.
Functional Interface Definition 
§ Single Abstract Method (SAM) type 
§ A functional interface is an interface that has one abstract method 
– Represents a single function contract 
– Doesn’t mean it only has one method 
§ Interfaces can now have static methods 
§ @FunctionalInterface annotation 
– Helps ensure the functional interface contract is honoured 
– Compiler error if not a SAM 
Copyright © 2012, Oracle and/or its affiliates. 30 All rights reserved.
Lambdas In Full Flow: 
Copyright © 2012, Oracle and/or its affiliates. 31 All rights reserved. 
Streams
Stream Overview 
Pipeline 
§ A stream pipeline consists of three types of things 
– A source 
– Zero or more intermediate operations 
– A terminal operation 
§ Producing a result or a side-effect 
int sum = transactions.stream(). 
filter(t -> t.getBuyer().getCity().equals(“London”)). 
mapToInt(Transaction::getPrice). 
sum(); 
Copyright © 2012, Oracle and/or its affiliates. 32 All rights reserved. 
Source 
Intermediate operation 
Terminal operation
Stream Sources 
Many Ways To Create 
§ From collections and arrays 
– Collection.stream() 
– Collection.parallelStream() 
– Arrays.stream(T array) or Stream.of() 
§ Static factories 
– IntStream.range() 
– Files.walk() 
§ Roll your own 
– java.util.Spliterator 
Copyright © 2012, Oracle and/or its affiliates. 33 All rights reserved.
map and flatMap 
Map Values in a Stream 
§ map (one to one) 
– Each element of the input stream is mapped to an element in the output 
stream 
§ flatMap (one to many) 
– Each element of the input stream is mapped to a new stream 
– Streams from all elements are concatenated to form one output stream 
Copyright © 2012, Oracle and/or its affiliates. 34 All rights reserved.
Optional<T> 
Reducing NullPointerException Occurrences 
§ Indicates that reference may, or may not have a value 
– Makes developer responsible for checking 
– A bit like a stream that can only have zero or one elements 
Optional<GPSData> maybeGPS = Optional.ofNullable(gpsData); 
maybeGPS.ifPresent(GPSData::printPosition); 
GPSData gps = maybeGPS.orElse(new GPSData()); 
maybeGPS.filter(g -> g.lastRead() < 2).ifPresent(GPSData.display()); 
Copyright © 2012, Oracle and/or its affiliates. 35 All rights reserved.
Example 1 
Convert words in list to upper case 
List<String> output = wordList. 
stream(). 
map(String::toUpperCase). 
collect(Collectors.toList()); 
Copyright © 2012, Oracle and/or its affiliates. 36 All rights reserved.
Example 1 
Convert words in list to upper case (in parallel) 
List<String> output = wordList. 
parallelStream(). 
map(String::toUpperCase). 
collect(Collectors.toList()); 
Copyright © 2012, Oracle and/or its affiliates. 37 All rights reserved.
Example 2 
Find words in list with even length 
List<String> output = wordList. 
parallelStream(). 
filter(w -> (w.length() & 1) == 0). 
collect(Collectors.toList()); 
Copyright © 2012, Oracle and/or its affiliates. 38 All rights reserved.
Example 3 
Count lines in a file 
§ BufferedReader has new method 
– Stream<String> lines() 
long count = bufferedReader. 
lines(). 
count(); 
Copyright © 2012, Oracle and/or its affiliates. 39 All rights reserved.
Example 4 
Join lines 3-4 into a single string 
String output = bufferedReader. 
lines(). 
skip(2). 
limit(2). 
collect(Collectors.joining()); 
Copyright © 2012, Oracle and/or its affiliates. 40 All rights reserved.
Example 5 
Collect all words in a file into a list 
List<String> output = reader. 
lines(). 
flatMap(line -> Stream.of(line.split(REGEXP))). 
filter(word -> word.length() > 0). 
collect(Collectors.toList()); 
Copyright © 2012, Oracle and/or its affiliates. 41 All rights reserved.
Example 6 
List of unique words in lowercase, sorted by length 
List<String> output = reader. 
lines(). 
flatMap(line -> Stream.of(line.split(REGEXP))). 
filter(word -> word.length() > 0). 
map(String::toLowerCase). 
distinct(). 
sorted((x, y) -> x.length() - y.length()). 
collect(Collectors.toList()); 
Copyright © 2012, Oracle and/or its affiliates. 42 All rights reserved.
Example 7: Real World 
Infinite stream from thermal sensor 
thermalReader 
.lines() 
.mapToDouble(s -> 
Double.parseDouble(s.substring(0, s.length() - ))) 
.map(t -> ((t – 32) / 5 / 9) 
.filter(t -> t != currentTemperature) 
.peek(t -> listener.ifPresent(l -> l.temperatureChanged(t))) 
.forEach(t -> currentTemperature = t); 
Copyright © 2012, Oracle and/or its affiliates. 43 All rights reserved.
Conclusions 
§ Java SE 8 is a significant change to Java 
– New features in language, libraries and VM 
§ Java needs lambda statements 
– Significant improvements in existing libraries are required 
§ Require a mechanism for interface evolution 
– Solution: virtual extension methods 
§ Bulk operations on Collections 
– Much simpler with Lambdas 
§ Java will continue to evolve to meet developer's needs 
Copyright © 2012, Oracle and/or its affiliates. 44 All rights reserved.
Graphic Section Divider 
Copyright © 2012, Oracle and/or its affiliates. 45 All rights reserved.
Ad

More Related Content

What's hot (20)

Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9
Simon Ritter
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
Stephen Colebourne
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On Lab
Simon Ritter
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
Trung Nguyen
 
Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8
Simon Ritter
 
Apouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-futureApouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-future
OUGTH Oracle User Group in Thailand
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
Leninkumar Koppoju
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
Naveen Hegde
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
Stephen Colebourne
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
DevelopIntelligence
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Emiel Paasschens
 
The Java Carputer
The Java CarputerThe Java Carputer
The Java Carputer
Simon Ritter
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & Streams
C4Media
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
Rohit Verma
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
Takipi
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
Java8 features
Java8 featuresJava8 features
Java8 features
Elias Hasnat
 
JDK8 Streams
JDK8 StreamsJDK8 Streams
JDK8 Streams
Bansilal Haudakari
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon RitterLambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
Lambdas and Streams in Java SE 8: Making Bulk Operations simple - Simon Ritter
JAXLondon2014
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9
Simon Ritter
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On Lab
Simon Ritter
 
Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8Lessons Learnt With Lambdas and Streams in JDK 8
Lessons Learnt With Lambdas and Streams in JDK 8
Simon Ritter
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
Naveen Hegde
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
DevelopIntelligence
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Emiel Paasschens
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & Streams
C4Media
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
Rohit Verma
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
Takipi
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 

Similar to Java SE 8 (20)

Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
jaxLondonConference
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
Martin Fousek
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
JDK 10 Java Module System
JDK 10 Java Module SystemJDK 10 Java Module System
JDK 10 Java Module System
Wolfgang Weigend
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
Simon Ritter
 
Java SE 8 & EE 7 Launch
Java SE 8 & EE 7 LaunchJava SE 8 & EE 7 Launch
Java SE 8 & EE 7 Launch
Digicomp Academy AG
 
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
Chuk-Munn Lee
 
Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018
Oracle Developers
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
jclingan
 
Java 8
Java 8Java 8
Java 8
jclingan
 
ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)
Logico
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
Sivakumar Thyagarajan
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
JAX London
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
Arun Gupta
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
Reza Rahman
 
Java jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3mJava jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3m
Steve Elliott
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and Architecture
JavaDayUA
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXB
Martin Grebac
 
Java EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersJava EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c Developers
Bruno Borges
 
Novidades do Java SE 8
Novidades do Java SE 8Novidades do Java SE 8
Novidades do Java SE 8
Bruno Borges
 
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
jaxLondonConference
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
Martin Fousek
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Mert Çalışkan
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
Simon Ritter
 
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
Chuk-Munn Lee
 
Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018Silicon Valley JUG meetup July 18, 2018
Silicon Valley JUG meetup July 18, 2018
Oracle Developers
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
jclingan
 
ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)
Logico
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
Sivakumar Thyagarajan
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
JAX London
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
Arun Gupta
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
Reza Rahman
 
Java jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3mJava jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3m
Steve Elliott
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and Architecture
JavaDayUA
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXB
Martin Grebac
 
Java EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersJava EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c Developers
Bruno Borges
 
Novidades do Java SE 8
Novidades do Java SE 8Novidades do Java SE 8
Novidades do Java SE 8
Bruno Borges
 
Ad

More from Simon Ritter (20)

Java Pattern Puzzles Java Pattern Puzzles
Java Pattern Puzzles Java Pattern PuzzlesJava Pattern Puzzles Java Pattern Puzzles
Java Pattern Puzzles Java Pattern Puzzles
Simon Ritter
 
Keeping Your Java Hot by Solving the JVM Warmup Problem
Keeping Your Java Hot by Solving the JVM Warmup ProblemKeeping Your Java Hot by Solving the JVM Warmup Problem
Keeping Your Java Hot by Solving the JVM Warmup Problem
Simon Ritter
 
Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native Compiler
Simon Ritter
 
Java On CRaC
Java On CRaCJava On CRaC
Java On CRaC
Simon Ritter
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
Simon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
Simon Ritter
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoring
Simon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
Simon Ritter
 
Getting the Most From Modern Java
Getting the Most From Modern JavaGetting the Most From Modern Java
Getting the Most From Modern Java
Simon Ritter
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVM
Simon Ritter
 
JDK 14 Lots of New Features
JDK 14 Lots of New FeaturesJDK 14 Lots of New Features
JDK 14 Lots of New Features
Simon Ritter
 
Java after 8
Java after 8Java after 8
Java after 8
Simon Ritter
 
How to Choose a JDK
How to Choose a JDKHow to Choose a JDK
How to Choose a JDK
Simon Ritter
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Simon Ritter
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
Simon Ritter
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java Technology
Simon Ritter
 
Is Java Still Free?
Is Java Still Free?Is Java Still Free?
Is Java Still Free?
Simon Ritter
 
Moving Towards JDK 12
Moving Towards JDK 12Moving Towards JDK 12
Moving Towards JDK 12
Simon Ritter
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and Beyond
Simon Ritter
 
Java Is Still Free
Java Is Still FreeJava Is Still Free
Java Is Still Free
Simon Ritter
 
Java Pattern Puzzles Java Pattern Puzzles
Java Pattern Puzzles Java Pattern PuzzlesJava Pattern Puzzles Java Pattern Puzzles
Java Pattern Puzzles Java Pattern Puzzles
Simon Ritter
 
Keeping Your Java Hot by Solving the JVM Warmup Problem
Keeping Your Java Hot by Solving the JVM Warmup ProblemKeeping Your Java Hot by Solving the JVM Warmup Problem
Keeping Your Java Hot by Solving the JVM Warmup Problem
Simon Ritter
 
Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native Compiler
Simon Ritter
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
Simon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
Simon Ritter
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoring
Simon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
Simon Ritter
 
Getting the Most From Modern Java
Getting the Most From Modern JavaGetting the Most From Modern Java
Getting the Most From Modern Java
Simon Ritter
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVM
Simon Ritter
 
JDK 14 Lots of New Features
JDK 14 Lots of New FeaturesJDK 14 Lots of New Features
JDK 14 Lots of New Features
Simon Ritter
 
How to Choose a JDK
How to Choose a JDKHow to Choose a JDK
How to Choose a JDK
Simon Ritter
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans Technology
Simon Ritter
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java Technology
Simon Ritter
 
Is Java Still Free?
Is Java Still Free?Is Java Still Free?
Is Java Still Free?
Simon Ritter
 
Moving Towards JDK 12
Moving Towards JDK 12Moving Towards JDK 12
Moving Towards JDK 12
Simon Ritter
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and Beyond
Simon Ritter
 
Java Is Still Free
Java Is Still FreeJava Is Still Free
Java Is Still Free
Simon Ritter
 
Ad

Recently uploaded (20)

Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 

Java SE 8

  • 1. Java 8: Create The Future Simon Ritter Head of Java Technology Evangelism Oracle Corp. Twitter: @speakjava Copyright © 2012, Oracle and/or its affiliates. 1 All rights reserved.
  • 2. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Copyright © 2012, Oracle and/or its affiliates. 2 All rights reserved.
  • 3. Java SE 8 New Features (Other Than Lambdas and Streams) Copyright © 2012, Oracle and/or its affiliates. 3 All rights reserved.
  • 4. Annotations On Java Types § Annotations can currently only be used on type declarations – Classes, methods, variable definitions § Extension for places where types are used – e.g. parameters § Permits error detection by pluggable type checkers – e.g. null pointer errors, race conditions, etc public void process(@notnull List data) {…} Copyright © 2012, Oracle and/or its affiliates. 4 All rights reserved.
  • 5. Access To Parameter Names At Runtime § Mechanism to retrieve parameter names of methods and constructors – At runtime via core reflection § Improved code readability – Eliminate redundant annotations § Improve IDE capabilities – Auto-generate template code § Method and Constructor now inherit from new Executable class – getParameters() returns array of Parameter objects – Name, type, annotations for each parameter Copyright © 2012, Oracle and/or its affiliates. 5 All rights reserved.
  • 6. Concurrency Updates § Scalable update variables – DoubleAccumulator, DoubleAdder, etc – Multiple variables avoid update contention – Good for frequent updates, infrequent reads § ConcurrentHashMap updates – Improved scanning support, key computation § ForkJoinPool improvements – Completion based design for IO bound applications – Thread that is blocked hands work to thread that is running Copyright © 2012, Oracle and/or its affiliates. 6 All rights reserved.
  • 7. Parallel Array Sorting § Additional utility methods in java.util.Arrays – parallelSort (multiple signatures for different primitives) § Anticipated minimum improvement of 30% over sequential sort – For dual core system with appropriate sized data set § Built on top of the fork-join framework – Uses Doug Lea’s ParallelArray implementation – Requires working space the same size as the array being sorted Copyright © 2012, Oracle and/or its affiliates. 7 All rights reserved.
  • 8. Date And Time APIs § A new date, time, and calendar API for the Java SE platform § Supports standard time concepts – Partial, duration, period, intervals – date, time, instant, and time-zone § Provides a limited set of calendar systems and be extensible to others § Uses relevant standards, including ISO-8601, CLDR, and BCP47 § Based on an explicit time-scale with a connection to UTC Copyright © 2012, Oracle and/or its affiliates. 8 All rights reserved.
  • 9. Unicode 6.2 § Java SE 7 support Unicode 6.0 § Changes in Unicode 6.1 (February, 2012) – Add 11 new blocks to java.lang.Character.UnicodeBlock – Add 7 new scripts to java.lang.Character.UnicodeScript – Support over 700 new characters in java.lang.Character, String, and other classes § Changes in Unicode 6.2 (September, 2012) – Support a new Turkish currency sign (U+20BA) Copyright © 2012, Oracle and/or its affiliates. 9 All rights reserved.
  • 10. HTTP URL Permissions § New type of network permission – Grant access in terms of URLs, rather than IP addresses § Current way to specify network permissions – java.net.SocketPermission – Not restricted to just HTTP – Operates in terms of IP addresses only § New, higher level capabilities – Support HTTP operations (POST, GET, etc) – Build on limited doPrivileged feature Copyright © 2012, Oracle and/or its affiliates. 10 All rights reserved.
  • 11. Compact Profiles Approximate static footprint goals Compact1 Profile Compact2 Profile Compact3 Profile 11Mb 16Mb Full JRE 54Mb Copyright © 2012, Oracle and/or its affiliates. 11 All rights reserved. 30Mb
  • 12. Nashorn JavaScript Engine § Lightweight, high-performance JavaScript engine – Integrated into JRE § Use existing javax.script API § ECMAScript-262 Edition 5.1 language specification compliance § New command-line tool, jjs to run JavaScript § Internationalised error messages and documentation Copyright © 2012, Oracle and/or its affiliates. 12 All rights reserved.
  • 13. Retire Rarely-Used GC Combinations § Rarely used – DefNew + CMS – ParNew + SerialOld – Incremental CMS § Large testing effort for little return § Will generate deprecated option messages – Won’t disappear just yet Copyright © 2012, Oracle and/or its affiliates. 13 All rights reserved.
  • 14. Remove The Permanent Generation Permanently § No more need to tune the size of it § Current objects moved to Java heap or native memory – Interned strings – Class metadata – Class static variables § Part of the HotSpot, JRockit convergence Copyright © 2012, Oracle and/or its affiliates. 14 All rights reserved.
  • 15. Lambdas And Streams Copyright © 2012, Oracle and/or its affiliates. 15 All rights reserved.
  • 16. Concurrency in Java Project Lambda java.util.concurrent (jsr166) java.lang.Thread 1.4 5.0 6 7 8 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 Copyright © 2012, Oracle and/or its affiliates. 16 All rights reserved. Fork/Join Framework (jsr166y) Phasers, etc (jsr166)
  • 17. The Problem: External Iteration List<Student> students = ... double highestScore = 0.0; for (Student s : students) { if (s.getGradYear() == 2011) { if (s.getScore() > highestScore) { highestScore = s.getScore(); } } } Copyright © 2012, Oracle and/or its affiliates. 17 All rights reserved. • Our code controls iteration • Inherently serial: iterate from beginning to end • Not thread-safe because business logic is stateful (mutable accumulator variable)
  • 18. Internal Iteration With Inner Classes Copyright © 2012, Oracle and/or its affiliates. 18 All rights reserved. § Iteration handled by the library § Not inherently serial – traversal may be done in parallel § Traversal may be done lazily – so one pass, rather than three § Thread safe – client logic is stateless § High barrier to use – Syntactically ugly More Functional, Fluent List<Student> students = ... double highestScore = students. filter(new Predicate<Student>() { public boolean op(Student s) { return s.getGradYear() == 2011; } }). map(new Mapper<Student,Double>() { public Double extract(Student s) { return s.getScore(); } }). max();
  • 19. Internal Iteration With Lambdas SomeList<Student> students = ... double highestScore = students. filter(Student s -> s.getGradYear() == 2011). map(Student s -> s.getScore()). max(); Copyright © 2012, Oracle and/or its affiliates. 19 All rights reserved. • More readable • More abstract • Less error-prone
  • 20. Lambda Expressions Some Details § Lambda expressions represent anonymous functions – Same structure as a method § typed argument list, return type, set of thrown exceptions, and a body – Not associated with a class § We now have parameterised behaviour, not just values double highestScore = students. filter(Student s -> s.getGradYear() == 2011). map(Student s -> s.getScore()) max(); What Copyright © 2012, Oracle and/or its affiliates. 20 All rights reserved. How
  • 21. Lambda Expression Types • Single-method interfaces are used extensively in Java – Definition: a functional interface is an interface with one abstract method – Functional interfaces are identified structurally – The type of a lambda expression will be a functional interface § Lambda expressions provide implementations of the abstract method interface Comparator<T> { boolean compare(T x, T y); } interface FileFilter { boolean accept(File x); } interface Runnable { void run(); } interface ActionListener { void actionPerformed(…); } interface Callable<T> { T call(); } Copyright © 2012, Oracle and/or its affiliates. 21 All rights reserved.
  • 22. Local Variable Capture • Lambda expressions can refer to effectively final local variables from the enclosing scope • Effectively final: A variable that meets the requirements for final variables (i.e., assigned once), even if not explicitly declared final • Closures on values, not variables void expire(File root, long before) { root.listFiles(File p -> p.lastModified() <= before); } Copyright © 2012, Oracle and/or its affiliates. 22 All rights reserved.
  • 23. What Does ‘this’ Mean For Lambdas? • ‘this’ refers to the enclosing object, not the lambda itself • Think of ‘this’ as a final predefined local • Remember the Lambda is an anonymous function class SessionManager { long before = ...; void expire(File root) { // refers to ‘this.before’, just like outside the lambda root.listFiles(File p -> checkExpiry(p.lastModified(), this.before)); } boolean checkExpiry(long time, long expiry) { ... } } Copyright © 2012, Oracle and/or its affiliates. 23 All rights reserved.
  • 24. Type Inference § The compiler can often infer parameter types in a lambda expression § Inferrence based on the target functional interface’s method signature static T void sort(List<T> l, Comparator<? super T> c); List<String> list = getList(); Collections.sort(list, (String x, String y) -> x.length() - y.length()); Collections.sort(list, (x, y) -> x.length() - y.length()); § Fully statically typed (no dynamic typing sneaking in) – More typing with less typing Copyright © 2012, Oracle and/or its affiliates. 24 All rights reserved.
  • 25. Method References • Method references let us reuse a method as a lambda expression • Also work for constructors FileFilter x = File f -> f.canRead(); FileFilter x = File::canRead; Copyright © 2012, Oracle and/or its affiliates. 25 All rights reserved.
  • 26. Copyright © 2012, Oracle and/or its affiliates. 26 All rights reserved. Library Evolution
  • 27. Library Evolution Goal § Requirement: aggregate operations on collections – New methods required on Collections to facilitate this int heaviestBlueBlock = blocks. filter(b -> b.getColor() == BLUE). map(Block::getWeight). reduce(0, Integer::max); § This is problematic – Can’t add new methods to interfaces without modifying all implementations – Can’t necessarily find or control all implementations Copyright © 2012, Oracle and/or its affiliates. 27 All rights reserved.
  • 28. Solution: Default Methods • Specified in the interface • From the caller’s perspective, just an ordinary interface method • Provides a default implementation • Default only used when implementation classes do not provide a body for the extension method • Implementation classes can provide a better version, or not interface Collection<E> { default Stream<E> stream() { return StreamSupport.stream(spliterator()); } } Copyright © 2012, Oracle and/or its affiliates. 28 All rights reserved.
  • 29. Virtual Extension Methods Stop right there! • Err, isn’t this implementing multiple inheritance for Java? • Yes, but Java already has multiple inheritance of types • This adds multiple inheritance of behavior too • But not state, which is where most of the trouble is • Can still be a source of complexity • Class implements two interfaces, both of which have default methods • Same signature • How does the compiler differentiate? • Static methods also allowed in interfaces in Java SE 8 Copyright © 2012, Oracle and/or its affiliates. 29 All rights reserved.
  • 30. Functional Interface Definition § Single Abstract Method (SAM) type § A functional interface is an interface that has one abstract method – Represents a single function contract – Doesn’t mean it only has one method § Interfaces can now have static methods § @FunctionalInterface annotation – Helps ensure the functional interface contract is honoured – Compiler error if not a SAM Copyright © 2012, Oracle and/or its affiliates. 30 All rights reserved.
  • 31. Lambdas In Full Flow: Copyright © 2012, Oracle and/or its affiliates. 31 All rights reserved. Streams
  • 32. Stream Overview Pipeline § A stream pipeline consists of three types of things – A source – Zero or more intermediate operations – A terminal operation § Producing a result or a side-effect int sum = transactions.stream(). filter(t -> t.getBuyer().getCity().equals(“London”)). mapToInt(Transaction::getPrice). sum(); Copyright © 2012, Oracle and/or its affiliates. 32 All rights reserved. Source Intermediate operation Terminal operation
  • 33. Stream Sources Many Ways To Create § From collections and arrays – Collection.stream() – Collection.parallelStream() – Arrays.stream(T array) or Stream.of() § Static factories – IntStream.range() – Files.walk() § Roll your own – java.util.Spliterator Copyright © 2012, Oracle and/or its affiliates. 33 All rights reserved.
  • 34. map and flatMap Map Values in a Stream § map (one to one) – Each element of the input stream is mapped to an element in the output stream § flatMap (one to many) – Each element of the input stream is mapped to a new stream – Streams from all elements are concatenated to form one output stream Copyright © 2012, Oracle and/or its affiliates. 34 All rights reserved.
  • 35. Optional<T> Reducing NullPointerException Occurrences § Indicates that reference may, or may not have a value – Makes developer responsible for checking – A bit like a stream that can only have zero or one elements Optional<GPSData> maybeGPS = Optional.ofNullable(gpsData); maybeGPS.ifPresent(GPSData::printPosition); GPSData gps = maybeGPS.orElse(new GPSData()); maybeGPS.filter(g -> g.lastRead() < 2).ifPresent(GPSData.display()); Copyright © 2012, Oracle and/or its affiliates. 35 All rights reserved.
  • 36. Example 1 Convert words in list to upper case List<String> output = wordList. stream(). map(String::toUpperCase). collect(Collectors.toList()); Copyright © 2012, Oracle and/or its affiliates. 36 All rights reserved.
  • 37. Example 1 Convert words in list to upper case (in parallel) List<String> output = wordList. parallelStream(). map(String::toUpperCase). collect(Collectors.toList()); Copyright © 2012, Oracle and/or its affiliates. 37 All rights reserved.
  • 38. Example 2 Find words in list with even length List<String> output = wordList. parallelStream(). filter(w -> (w.length() & 1) == 0). collect(Collectors.toList()); Copyright © 2012, Oracle and/or its affiliates. 38 All rights reserved.
  • 39. Example 3 Count lines in a file § BufferedReader has new method – Stream<String> lines() long count = bufferedReader. lines(). count(); Copyright © 2012, Oracle and/or its affiliates. 39 All rights reserved.
  • 40. Example 4 Join lines 3-4 into a single string String output = bufferedReader. lines(). skip(2). limit(2). collect(Collectors.joining()); Copyright © 2012, Oracle and/or its affiliates. 40 All rights reserved.
  • 41. Example 5 Collect all words in a file into a list List<String> output = reader. lines(). flatMap(line -> Stream.of(line.split(REGEXP))). filter(word -> word.length() > 0). collect(Collectors.toList()); Copyright © 2012, Oracle and/or its affiliates. 41 All rights reserved.
  • 42. Example 6 List of unique words in lowercase, sorted by length List<String> output = reader. lines(). flatMap(line -> Stream.of(line.split(REGEXP))). filter(word -> word.length() > 0). map(String::toLowerCase). distinct(). sorted((x, y) -> x.length() - y.length()). collect(Collectors.toList()); Copyright © 2012, Oracle and/or its affiliates. 42 All rights reserved.
  • 43. Example 7: Real World Infinite stream from thermal sensor thermalReader .lines() .mapToDouble(s -> Double.parseDouble(s.substring(0, s.length() - ))) .map(t -> ((t – 32) / 5 / 9) .filter(t -> t != currentTemperature) .peek(t -> listener.ifPresent(l -> l.temperatureChanged(t))) .forEach(t -> currentTemperature = t); Copyright © 2012, Oracle and/or its affiliates. 43 All rights reserved.
  • 44. Conclusions § Java SE 8 is a significant change to Java – New features in language, libraries and VM § Java needs lambda statements – Significant improvements in existing libraries are required § Require a mechanism for interface evolution – Solution: virtual extension methods § Bulk operations on Collections – Much simpler with Lambdas § Java will continue to evolve to meet developer's needs Copyright © 2012, Oracle and/or its affiliates. 44 All rights reserved.
  • 45. Graphic Section Divider Copyright © 2012, Oracle and/or its affiliates. 45 All rights reserved.