SlideShare a Scribd company logo
1 of 44
Improved Developer 
Productivity With Java SE 8 
Simon Ritter 
Head of Java Technology Evangelism 
Oracle Corp 
Twitter: @speakjava 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Safe Harbor Statement 
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 © 2014, Oracle and/or its affiliates. All rights reserved. 
2
Java SE 8 New Features 
(Other Than Lambdas and Streams) 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Copyright © 2014, Oracle and/or its affiliates. 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(@immutable List data) {…}
Copyright © 2014, Oracle and/or its affiliates. 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 © 2014, Oracle and/or its affiliates. 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 © 2014, Oracle and/or its affiliates. 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 © 2014, Oracle and/or its affiliates. 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)
Compact Profiles 
Approximate static footprint goals 
11Mb 
16Mb 
30Mb 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Compact1 Profile 
Compact2 Profile 
Compact3 Profile 
Full JRE 54Mb
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
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
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 © 2014, Oracle and/or its affiliates. All rights reserved.
Remove The Permanent Generation 
• 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 © 2014, Oracle and/or its affiliates. All rights reserved. 
Permanently
Lambdas And Streams 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
The Problem: External Iteration 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
List<Student> students = ... 
double highestScore = 0.0; 
for (Student s : students) { 
if (s.getGradYear() == 2011) { 
if (s.getScore() > highestScore) 
highestScore = s.score; 
} 
} 
• Our code controls iteration 
• Inherently serial: iterate from 
beginning to end 
• Not thread-safe 
• Business logic is stateful 
• Mutable accumulator variable
Internal Iteration With Inner Classes 
• 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 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
More Functional 
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 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
List<Student> students = ... 
double highestScore = students 
.filter(Student s -> s.getGradYear() == 2011) 
.map(Student s -> s.getScore()) 
.max(); 
• More readable 
• More abstract 
• Less error-prone 
NOTE: This is not JDK8 code
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
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 
How
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
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 © 2014, Oracle and/or its affiliates. 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); 
}
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 
– It is not associated with a class 
– Therefore there can be no ‘this’ for the Lambda 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Referencing Instance Variables 
Which are not final, or effectively final 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
class DataProcessor { 
private int currentValue; 
public void process() { 
DataSet myData = myFactory.getDataSet(); 
dataSet.forEach(d -> d.use(currentValue++)); 
} 
}
Referencing Instance Variables 
The compiler helps us out 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
class DataProcessor { 
private int currentValue; 
public void process() { 
DataSet myData = myFactory.getDataSet(); 
dataSet.forEach(d -> d.use(this.currentValue++)); 
} 
} 
‘this’ (which is effectively final) 
inserted by the compiler
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()); 
Copyright © 2014, Oracle and/or its affiliates. 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 
• Fully statically typed (no dynamic typing sneaking in) 
– More typing with less typing
Method And Constructor References 
• Method references let us reuse a method as a lambda expression 
FileFilter x = File f -> f.canRead(); 
FileFilter x = File::canRead; 
• Same syntax works for constructors 
Factory<List<String>> f = ArrayList<String>::new; 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Library Evolution 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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 © 2014, Oracle and/or its affiliates. All rights reserved.
Copyright © 2014, Oracle and/or its affiliates. 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 © 2014, Oracle and/or its affiliates. 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
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 
• @FunctionalInterface annotation 
– Helps ensure the functional interface contract is honoured 
– Compiler error if not a SAM 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Lambdas In Full Flow: 
Streams 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Source 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
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 total = transactions.stream() 
.filter(t -> t.getBuyer().getCity().equals(“London”)) 
.mapToInt(Transaction::getPrice) 
.sum(); 
Intermediate operation 
Terminal operation
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
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
Stream Terminal Operations 
• The pipeline is only evaluated when the terminal operation is called 
– All operations can execute sequentially or in parallel 
– Intermediate operations can be merged 
• Avoiding multiple redundant passes on data 
• Short-circuit operations (e.g. findFirst) 
• Lazy evaluation 
– Stream characteristics help identify optimisations 
• DISTINT stream passed to distinct() is a no-op 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Helping To Eliminate the NullPointerException 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Optional Class 
• Terminal operations like min(), max(), etc do not return a direct result 
• Suppose the input Stream is empty? 
• Optional<T> 
– Container for an object reference (null, or real object) 
– Think of it like a Stream of 0 or 1 elements 
– use get(), ifPresent() and orElse() to access the stored reference 
– Can use in more complex ways: filter(), map(), etc
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Example 1 
Convert words in list to upper case 
List<String> output = wordList 
.stream() 
.map(String::toUpperCase) 
.collect(Collectors.toList());
Example 1 
Convert words in list to upper case (in parallel) 
List<String> output = wordList 
.parralelStream() 
.map(String::toUpperCase) 
.collect(Collectors.toList()); 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Example 2 
Count lines in a file 
• BufferedReader has new method 
– Stream<String> lines() 
long count = bufferedReader 
.lines() 
.count();
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Example 3 
Join lines 3-4 into a single string 
String output = bufferedReader 
.lines() 
.skip(2) 
.limit(2) 
.collect(Collectors.joining());
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Example 4 
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());
Example 5 
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 © 2014, Oracle and/or its affiliates. All rights reserved.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Example 6: Real World 
Infinite stream from thermal sensor 
private int double currentTemperature; 
... 
thermalReader 
.lines() 
.mapToDouble(s -> 
Double.parseDouble(s.substring(0, s.length() - 1))) 
.map(t -> ((t – 32) * 5 / 9) 
.filter(t -> t != currentTemperature) 
.peek(t -> listener.ifPresent(l -> l.temperatureChanged(t))) 
.forEach(t -> currentTemperature = t);
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 
Example 6: Real World 
Infinite stream from thermal sensor 
private int double currentTemperature; 
... 
thermalReader 
.lines() 
.mapToDouble(s -> 
Double.parseDouble(s.substring(0, s.length() - 1))) 
.map(t -> ((t – 32) * 5 / 9) 
.filter(t -> t != this.currentTemperature) 
.peek(t -> listener.ifPresent(l -> l.temperatureChanged(t))) 
.forEach(t -> this.currentTemperature = t);
Copyright © 2014, Oracle and/or its affiliates. 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 © 2014, Oracle and/or its affiliates. All rights reserved. 
Graphic Section Divider

More Related Content

What's hot

Functional Programming With Lambdas and Streams in JDK8
 Functional Programming With Lambdas and Streams in JDK8 Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8IndicThreads
 
Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014Simon Ritter
 
Lambdas And Streams Hands On Lab
Lambdas And Streams Hands On LabLambdas And Streams Hands On Lab
Lambdas And Streams Hands On LabSimon Ritter
 
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 StreamsEmiel Paasschens
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & StreamsC4Media
 
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 8Takipi
 
java 8 new features
java 8 new features java 8 new features
java 8 new features Rohit Verma
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features OverviewSergii Stets
 
java programming - applets
java programming - appletsjava programming - applets
java programming - appletsHarshithaAllu
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsNewCircle Training
 

What's hot (20)

Functional Programming With Lambdas and Streams in JDK8
 Functional Programming With Lambdas and Streams in JDK8 Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
 
Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014Lambdas And Streams Hands On Lab, JavaOne 2014
Lambdas And Streams Hands On Lab, JavaOne 2014
 
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
 
Lambdas And Streams Hands On Lab
Lambdas And Streams Hands On LabLambdas And Streams Hands On Lab
Lambdas And Streams Hands On Lab
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
 
The Java Carputer
The Java CarputerThe Java Carputer
The Java Carputer
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
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)
 
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
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & Streams
 
JDK8 Streams
JDK8 StreamsJDK8 Streams
JDK8 Streams
 
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
 
Java 101
Java 101Java 101
Java 101
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
java programming - applets
java programming - appletsjava programming - applets
java programming - applets
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 

Viewers also liked

Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Simon Ritter
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future KeynoteSimon Ritter
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Simon Ritter
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On LabSimon 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 8Simon Ritter
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerSimon Ritter
 
It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!Simon Ritter
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerSimon Ritter
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Simon Ritter
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9Simon Ritter
 

Viewers also liked (10)

Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014Oracle Keynote from JMagghreb 2014
Oracle Keynote from JMagghreb 2014
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future Keynote
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
 
Lambdas Hands On Lab
Lambdas Hands On LabLambdas Hands On Lab
Lambdas Hands On Lab
 
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
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!It's Java Jim, But Not As We Know It!
It's Java Jim, But Not As We Know It!
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?Is An Agile Standard Possible For Java?
Is An Agile Standard Possible For Java?
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9
 

Similar to Improved Developer Productivity In JDK8

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
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8javafxpert
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8jclingan
 
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuA-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuSrimanta Sahu
 
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 ArchitectureJavaDayUA
 
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckEdward Burns
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigoujaxconf
 
JShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJavaDayUA
 
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, 2018Oracle Developers
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New FeaturesNaveen Hegde
 

Similar to Improved Developer Productivity In JDK8 (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...
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
Java 8
Java 8Java 8
Java 8
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
 
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuA-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
 
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
 
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute InfodeckServlet 4.0 Adopt-a-JSR 10 Minute Infodeck
Servlet 4.0 Adopt-a-JSR 10 Minute Infodeck
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
 
Lambdas in Java 8
Lambdas in Java 8Lambdas in Java 8
Lambdas in Java 8
 
JShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java PlatformJShell: An Interactive Shell for the Java Platform
JShell: An Interactive Shell for the Java Platform
 
Java 8
Java 8Java 8
Java 8
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
JDK 10 Java Module System
JDK 10 Java Module SystemJDK 10 Java Module System
JDK 10 Java Module System
 
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
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
08 subprograms
08 subprograms08 subprograms
08 subprograms
 
Java SE 8 & EE 7 Launch
Java SE 8 & EE 7 LaunchJava SE 8 & EE 7 Launch
Java SE 8 & EE 7 Launch
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 

More from Simon Ritter

Cloud Native Compiler
Cloud Native CompilerCloud Native Compiler
Cloud Native CompilerSimon Ritter
 
The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type PatternsSimon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Java performance monitoring
Java performance monitoringJava performance monitoring
Java performance monitoringSimon Ritter
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Getting the Most From Modern Java
Getting the Most From Modern JavaGetting the Most From Modern Java
Getting the Most From Modern JavaSimon Ritter
 
Building a Better JVM
Building a Better JVMBuilding a Better JVM
Building a Better JVMSimon Ritter
 
JDK 14 Lots of New Features
JDK 14 Lots of New FeaturesJDK 14 Lots of New Features
JDK 14 Lots of New FeaturesSimon Ritter
 
How to Choose a JDK
How to Choose a JDKHow to Choose a JDK
How to Choose a JDKSimon Ritter
 
The Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologyThe Latest in Enterprise JavaBeans Technology
The Latest in Enterprise JavaBeans TechnologySimon Ritter
 
Developing Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologyDeveloping Enterprise Applications Using Java Technology
Developing Enterprise Applications Using Java TechnologySimon 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 12Simon Ritter
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondSimon Ritter
 
Java Is Still Free
Java Is Still FreeJava Is Still Free
Java Is Still FreeSimon Ritter
 
JDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondJDK 9, 10, 11 and Beyond
JDK 9, 10, 11 and BeyondSimon Ritter
 
JDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep DiveJDK 9 and JDK 10 Deep Dive
JDK 9 and JDK 10 Deep DiveSimon Ritter
 

More from Simon Ritter (20)

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

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

Improved Developer Productivity In JDK8

  • 1. Improved Developer Productivity With Java SE 8 Simon Ritter Head of Java Technology Evangelism Oracle Corp Twitter: @speakjava Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 2. Safe Harbor Statement 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 © 2014, Oracle and/or its affiliates. All rights reserved. 2
  • 3. Java SE 8 New Features (Other Than Lambdas and Streams) Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 4. Copyright © 2014, Oracle and/or its affiliates. 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(@immutable List data) {…}
  • 5. Copyright © 2014, Oracle and/or its affiliates. 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
  • 6. Copyright © 2014, Oracle and/or its affiliates. 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
  • 7. Copyright © 2014, Oracle and/or its affiliates. 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
  • 8. Copyright © 2014, Oracle and/or its affiliates. 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)
  • 9. Compact Profiles Approximate static footprint goals 11Mb 16Mb 30Mb Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Compact1 Profile Compact2 Profile Compact3 Profile Full JRE 54Mb
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 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
  • 11. 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 © 2014, Oracle and/or its affiliates. All rights reserved.
  • 12. Remove The Permanent Generation • 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 © 2014, Oracle and/or its affiliates. All rights reserved. Permanently
  • 13. Lambdas And Streams Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 14. The Problem: External Iteration Copyright © 2014, Oracle and/or its affiliates. All rights reserved. List<Student> students = ... double highestScore = 0.0; for (Student s : students) { if (s.getGradYear() == 2011) { if (s.getScore() > highestScore) highestScore = s.score; } } • Our code controls iteration • Inherently serial: iterate from beginning to end • Not thread-safe • Business logic is stateful • Mutable accumulator variable
  • 15. Internal Iteration With Inner Classes • 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 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. More Functional 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();
  • 16. Internal Iteration With Lambdas Copyright © 2014, Oracle and/or its affiliates. All rights reserved. List<Student> students = ... double highestScore = students .filter(Student s -> s.getGradYear() == 2011) .map(Student s -> s.getScore()) .max(); • More readable • More abstract • Less error-prone NOTE: This is not JDK8 code
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 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 How
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 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(); }
  • 19. Copyright © 2014, Oracle and/or its affiliates. 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); }
  • 20. 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 – It is not associated with a class – Therefore there can be no ‘this’ for the Lambda Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 21. Referencing Instance Variables Which are not final, or effectively final Copyright © 2014, Oracle and/or its affiliates. All rights reserved. class DataProcessor { private int currentValue; public void process() { DataSet myData = myFactory.getDataSet(); dataSet.forEach(d -> d.use(currentValue++)); } }
  • 22. Referencing Instance Variables The compiler helps us out Copyright © 2014, Oracle and/or its affiliates. All rights reserved. class DataProcessor { private int currentValue; public void process() { DataSet myData = myFactory.getDataSet(); dataSet.forEach(d -> d.use(this.currentValue++)); } } ‘this’ (which is effectively final) inserted by the compiler
  • 23. 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()); Copyright © 2014, Oracle and/or its affiliates. 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 • Fully statically typed (no dynamic typing sneaking in) – More typing with less typing
  • 24. Method And Constructor References • Method references let us reuse a method as a lambda expression FileFilter x = File f -> f.canRead(); FileFilter x = File::canRead; • Same syntax works for constructors Factory<List<String>> f = ArrayList<String>::new; Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 25. Library Evolution Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 26. 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 © 2014, Oracle and/or its affiliates. All rights reserved.
  • 27. Copyright © 2014, Oracle and/or its affiliates. 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()); } }
  • 28. Copyright © 2014, Oracle and/or its affiliates. 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
  • 29. 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 • @FunctionalInterface annotation – Helps ensure the functional interface contract is honoured – Compiler error if not a SAM Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 30. Lambdas In Full Flow: Streams Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 31. Source Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 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 total = transactions.stream() .filter(t -> t.getBuyer().getCity().equals(“London”)) .mapToInt(Transaction::getPrice) .sum(); Intermediate operation Terminal operation
  • 32. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 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
  • 33. Stream Terminal Operations • The pipeline is only evaluated when the terminal operation is called – All operations can execute sequentially or in parallel – Intermediate operations can be merged • Avoiding multiple redundant passes on data • Short-circuit operations (e.g. findFirst) • Lazy evaluation – Stream characteristics help identify optimisations • DISTINT stream passed to distinct() is a no-op Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 34. Helping To Eliminate the NullPointerException Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Optional Class • Terminal operations like min(), max(), etc do not return a direct result • Suppose the input Stream is empty? • Optional<T> – Container for an object reference (null, or real object) – Think of it like a Stream of 0 or 1 elements – use get(), ifPresent() and orElse() to access the stored reference – Can use in more complex ways: filter(), map(), etc
  • 35. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Example 1 Convert words in list to upper case List<String> output = wordList .stream() .map(String::toUpperCase) .collect(Collectors.toList());
  • 36. Example 1 Convert words in list to upper case (in parallel) List<String> output = wordList .parralelStream() .map(String::toUpperCase) .collect(Collectors.toList()); Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
  • 37. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Example 2 Count lines in a file • BufferedReader has new method – Stream<String> lines() long count = bufferedReader .lines() .count();
  • 38. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Example 3 Join lines 3-4 into a single string String output = bufferedReader .lines() .skip(2) .limit(2) .collect(Collectors.joining());
  • 39. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Example 4 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());
  • 40. Example 5 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 © 2014, Oracle and/or its affiliates. All rights reserved.
  • 41. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Example 6: Real World Infinite stream from thermal sensor private int double currentTemperature; ... thermalReader .lines() .mapToDouble(s -> Double.parseDouble(s.substring(0, s.length() - 1))) .map(t -> ((t – 32) * 5 / 9) .filter(t -> t != currentTemperature) .peek(t -> listener.ifPresent(l -> l.temperatureChanged(t))) .forEach(t -> currentTemperature = t);
  • 42. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Example 6: Real World Infinite stream from thermal sensor private int double currentTemperature; ... thermalReader .lines() .mapToDouble(s -> Double.parseDouble(s.substring(0, s.length() - 1))) .map(t -> ((t – 32) * 5 / 9) .filter(t -> t != this.currentTemperature) .peek(t -> listener.ifPresent(l -> l.temperatureChanged(t))) .forEach(t -> this.currentTemperature = t);
  • 43. Copyright © 2014, Oracle and/or its affiliates. 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
  • 44. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Graphic Section Divider

Editor's Notes

  1. This is a Title Slide with Java FY15 Theme slide ideal for including the Java Theme with a brief title, subtitle and presenter information. To customize this slide with your own picture: Right-click the slide area and choose Format Background from the pop-up menu. From the Fill menu, click Picture and texture fill. Under Insert from: click File. Locate your new picture and click Insert. To copy the Customized Background from Another Presentation on PC Click New Slide from the Home tab's Slides group and select Reuse Slides. Click Browse in the Reuse Slides panel and select Browse Files. Double-click the PowerPoint presentation that contains the background you wish to copy. Check Keep Source Formatting and click the slide that contains the background you want. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Right-click any selected slide, point to Layout, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates. To copy the Customized Background from Another Presentation on Mac Click New Slide from the Home tab's Slides group and select Insert Slides from Other Presentation… Navigate to the PowerPoint presentation file that contains the background you wish to copy. Double-click or press Insert. This prompts the Slide Finder dialogue box. Make sure Keep design of original slides is unchecked and click the slide(s) that contains the background you want. Hold Shift key to select multiple slides. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Click Layout from the Home tab's Slides group, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates.
  2. This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your presentation covers material affected by Oracle’s Revenue Recognition Policy To learn more about this policy, e-mail: Revrec-americasiebc_us@oracle.com For internal communication, Safe Harbor Statements are not required. However, there is an applicable disclaimer (Exhibit E) that should be used, found in the Oracle Revenue Recognition Policy for Future Product Communications. Copy and paste this link into a web browser, to find out more information. http://my.oracle.com/site/fin/gfo/GlobalProcesses/cnt452504.pdf For all external communications such as press release, roadmaps, PowerPoint presentations, Safe Harbor Statements are required. You can refer to the link mentioned above to find out additional information/disclaimers required depending on your audience.
  3. JEP104
  4. JEP 155 Completion based design. Multiple threads getting stalled by one thread. The way round this is to basically pass on the work from a thread that is waiting to the one doing the work. The waiting thread is then free to be reused.
  5. JEP103
  6. JEP150 Internal storage using just the offset in nanosecods from the Epoch. Things like day and date, etc calculated on demand to improve efficiency. Partial, e.g. March 20th (no year). Not specific Duration (nanos), period (minutes, days, etc), interval nanos between two points in time.
  7. JEP 184
  8. Modularisation of the Java platform. Since project Jigsaw was pushed back to Java SE 9 some form of modularisation was needed to make the Java platform more flexible. To do this we now have three compact profiles that subset the standard class libraries to allow applications that only need certain APIs to run in a smaller resource footprint. Compact 1 is the smallest subset of packages that supports the Java language. Includes logging and SSL. This is the migration path for people currently using the compact device configuration (CDC) Compact 2 adds support for XML, JDBC and RMI (specifically JSR 280, JSR 169 and JSR 66) Compact 3 adds management, naming, more securoty and compiler support. None of the compact profiles include any UI APIs, they are all headless. See also JEP 161
  9. JEP 174
  10. JEP 173
  11. JEP 122
  12. Fluent API Monad
  13. Question: how are we going to get there with real collections?
  14. We define a Lambda expression as an anonymous function (like a method, but because it is not associated with a class we call it a function). Like methods there are parameters, a body, a return type and even thrown exceptions. What Lambda expressions really brings to Java is a simple way to parameterise behaviour. The sequence of methods we have here defines what we want to do, i.e. filter the stream, map its values and so on, but how this happens is defined by the Lambda expressions we pass as parameters.
  15. Erased function types are the worst of both worlds
  16. Current fashion: imagine the libraries you want, then build the language features to suit But, are we explicit enough that this is what we're doing? This is hard because lead times on language work are longer than on libraries So temptation is to front-load language work and let libraries slide We should always be prepared to answer: why *these* language features?
  17. Can also say “default none” to reabstract the method
  18. Start talking about how this is a VM feature
  19. Stream is an interface, but in Java SE 8 we can now have static methods in interfaces, hence Stream.of() Files.walk will walk a file tree from a given Path argument Spliterator interface that represents an object for traversing or partitioning elements of a source