SlideShare a Scribd company logo
1 of 65
Download to read offline
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.1
Java 8:
Create The Future
Simon Ritter
Head of Java Technology Evangelism
Oracle Corp.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3
Program Agenda
 Java SE 8: Enhancing the Core Java Platform
– Lambdas and Streams
– Other new features
 Java ME 8: Building The Internet of Things
 NetBeans 8: The IDE For Java 8
 Where Next?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4
Java SE 8:
Lambdas & Streams:
Functional Programming
In Java
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5
2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
1.4 5.0 6 7 8
java.lang.Thread
java.util.concurrent
(jsr166)
Fork/Join Framework
(jsr166y)
Project Lambda
Concurrency in Java
Phasers, etc
(jsr166)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6
The Problem: External Iteration
List<Student> students = ...
double highestScore = 0.0;
for (Student s : students) {
if (s.gradYear == 2011) {
if (s.score > highestScore) {
highestScore = s.score;
}
}
}
• Client controls iteration
• Inherently serial: iterate from
beginning to end
• Not thread-safe because
business logic is stateful
(mutable accumulator
variable)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7
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
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();
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8
Internal Iteration With Lambdas
SomeList<Student> students = ...
double highestScore = students.
filter(Student s -> s.getGradYear() == 2011).
map(Student s -> s.getScore()).
max();
• More readable
• More abstract
• Less error-prone
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9
Lambda Expressions
 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
Some Details
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.10
Lambda Expressions
 Definition
– A functional interface is an interface with only one abstract method
– However, the interface may have more than one method
 Identified structurally
– Type is inferred from the context
– Works for both assignment and method parameter contexts
 The type of a Lambda expression is a functional interface
– Instances of functional interfaces are created with Lambda expressions
– @FunctionalInterface annotation
Functional Interfaces
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11
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
List<String> list = getList();
Collections.sort(list, (String x, String y) -> x.length() - y.length());
Collections.sort(list, (x, y) -> x.length() - y.length());
static T void sort(List<T> l, Comparator<? super T> c);
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12
Lambda Epressions
• Lambda expressions can refer to effectively final local variables from
the enclosing scope
– This means a variable behaves as if it is marked final (even if it is not)
– The variable is assigned once
• Lambda expressions are anonymous functions
– They are not associated with an object
– this will refer to the object in the surrounding scope
Local Variable Capture & The Meaning of ‘this’
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13
Method References
• Method references let us reuse a method as a lambda expression
FileFilter x = (File f) -> f.canRead();
FileFilter x = File::canRead;
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14
Constructor References
 Same concept as a method reference
– For the constructor
Factory<List<String>> f = ArrayList<String>::new;
Factory<List<String>> f = () -> return new ArrayList<String>();
Equivalent to
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15
Default Methods
 Provide a mechanism to add new methods to existing interfaces
– Without breaking backwards compatability
– Gives Java multiple inheritance of behaviour, as well as types
 but not state!
public interface Set<T> extends Collection<T> {
... // The existing Set methods
default Spliterator<E> spliterator() {
return Spliterators.spliterator(this, Spliterator.DISTINCT);
}
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16
Static Methods In Interfaces
 Previously it was not possible to include static methods in an interface
 Static methods, by definition, are not abstract
– @FunctionalInterface can have zero or more static methods
static <T> Predicate<T> isEqual(Object target) {
return (null == target)
? Objects::isNull
: object -> target.equals(object);
}
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17
Streams API
 Most business logic is about aggregate operations
– “Most profitable product by region”
– “Group transactions by currency”
 As we have seen, up to now, Java mostly uses external iteration
– Inherently serial
– Frustratingly imperative
 Java SE 8’s answer: Streams
– With help from Lambdas
Aggregate Operations
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18
Stream Overview
 Abstraction for specifying aggregate computations
– Not a data structure
– Can be infinite
 Simplifies the description of aggregate computations
– Exposes opportunities for optimisation
– Fusing, laziness and parrallelism
High Level
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19
Stream Overview
 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
Pipeline
int sum = transactions.stream().
filter(t -> t.getBuyer().getCity().equals(“London”)).
mapToInt(Transaction::getPrice).
sum();
Source
Intermediate operation
Terminal operation
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20
Stream Overview
 The filter and map methods don’t really do any work
– They set up a pipeline of operations and return a new Stream
 All work happens when we get to the sum() operation
– filter()/map()/sum() fused into one pass on the data
 For both sequential and parallel pipelines
Execution
int sum = transactions.stream().
filter(t -> t.getBuyer().getCity().equals(“London”)). // Lazy
mapToInt(Transaction::getPrice). // Lazy
sum(); // Execute the pipeline
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21
Stream Sources
 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()
Many Ways To Create
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.22
Stream Sources
 Access to stream elements
 Decomposition (for parallel operations)
– Fork-join framework
 Stream characteristics
– ORDERED
– DISTINCT
– SORTED
– SIZED
– NONNULL
– IMMUTABLE
– CONCURRENT
Manage Three Aspects
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23
Stream Intermediate Operations
 Uses lazy evaluation where possible
 Can affect stream characteristics
– map() preserves SIZED but not DISTINCT or SORTED
 Some operations fuse/convert to parallel better than others
– Stateless operations (map, filter) fuse/convert perfectly
– Stateful operations (sorted, distint, limit) fuse/convert to varying
degrees
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24
Stream Terminal Operations
 Invoking a terminal operation executes the pipeline
– All operations can execute sequentially or in parallel
 Terminal operations can take advantage of pipeline characteristics
– toArray() can avoid copying for SIZED pipelines by allocating in
advance
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25
Optional<T>
 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
Reducing NullPointerException Occurences
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 © 2014, Oracle and/or its affiliates. All rights reserved.26
java.util.function Package
 Predicate<T>
– Determine if the input of type T matches some criteria
 Consumer<T>
– Accept a single input argumentof type T, and return no result
 Function<T, R>
– Apply a function to the input type T, generating a result of type R
 Plus several more type specific versions
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.27
Stream Example 1
Convert words in list to upper case
List<String> output = wordList.
stream().
map(String::toUpperCase).
collect(Collectors.toList());
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.28
Stream Example 1
Convert words in list to upper case (in parallel)
List<String> output = wordList.
parallelStream().
map(String::toUpperCase).
collect(Collectors.toList());
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.29
Stream Example 2
Find words in list with even length
List<String> output = wordList.
stream().
filter(w -> (w.length() & 1 == 0).
collect(Collectors.toList());
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.30
Stream Example 3
 BufferedReader has new method
– Stream<String> lines()
Count lines in a file
long count = bufferedReader.
lines().
count();
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.31
Stream Example 4
Find the length of the longest line in a file
int longest = reader.
lines().
mapToInt(String::length).
max().
getAsInt();
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.32
Stream 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 © 2014, Oracle and/or its affiliates. All rights reserved.33
Stream 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 © 2014, Oracle and/or its affiliates. All rights reserved.34
Java SE 8:
Other New Features
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.35
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 © 2014, Oracle and/or its affiliates. All rights reserved.36
Concurrency Updates
 Scalable update variables
– DoubleAccumulator, DoubleAdder, etc
– Multiple variables avoid update contention
– Good for frequent updates, infrequent reads
 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.37
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.38
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.39
Base64 Encoding and Decoding
 Currently developers are forced to use non-public APIs
– sun.misc.BASE64Encoder
– sun.misc.BASE64Decoder
 Java SE 8 now has a standard way
– java.util.Base64.Encoder
– java.util.Base64.Decoder
– encode, encodeToString, decode, wrap methods
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.40
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 © 2014, Oracle and/or its affiliates. All rights reserved.41
Removal Of 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
Permanently
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.42
JavaFX 8
 DatePicker
 TreeTableView
New Controls
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.43
JavaFX 8
 Gestures
– Swipe
– Scroll
– Rotate
– Zoom
 Touch events and touch points
Touch Support
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.44
JavaFX 8
 Predefined shapes
– Box
– Cylinder
– Sphere
 User-defined shapes
– TriangleMesh, MeshView
 PhongMaterial
 Lighting
 Cameras
3D Support
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.45
Compact Profiles
Approximate static footprint goals
Compact1 Profile
Compact2 Profile
Compact3 Profile
Full JRE 54Mb
30Mb
16Mb
11Mb
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.46
Java SE Embedded
 Optimised binary for embedded use from devices to gateways
 Latest Java innovations in the smallest footprint
 Use of compact profiles
– Approximate JRE size 20.4Mb (ARM v7 VFS, Hard Float)
 Compact profile 1: 10.4Mb
 JavaFX: 10Mb
 Production ready binary for popular platforms that run Linux
– ARM v6/7 with Hard floating point
– Raspberry Pi is one of the reference platforms
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.47
Java ME 8:
Building The Internet of
Things
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.48
Java ME 8 Focus
Java ME EmbeddedJava Card
SECURITY SMALL EMBEDDED MEDIUM EMBEDDED LARGE EMBEDDED DESKTOP SERVER
50KB-1MB
1MB-10MB
10MB-100MB
Footprint
Java SE Embedded
Java Embedded Suite
Oracle Event Processing Embedded
100MB+
Java SE
ARM Cortex M3/M4
ARM Cortex-A
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.49
Java ME 8 Platform Overview
Java VM
Additional
APIs
(Examples)
Java ME Connected Limited Device Configuration (CLDC) 8 (JSR 360)
Additional
Optional APIs
On-Device I/O
Access
Vertical Specific
APIs
Location
Messaging
Wireless
Communication
Web Services
Protocols and
Data Conversion
Sensors
Additional
Optional JSRs
Security and
Management
Use Case Software
(e.g. smart pen)
Use Case Software
(e.g. wireless module)
Use Case Software
(e.g. control unit)
Use Case Software
(e.g. smart meter)
Application Platform
Java ME Embedded Profile
(MEEP) 8 (JSR 361)
On-Device I/O
Access
Device I/O
API
SATSA
(JSR 177)
Security and Trust
Services
Generic Connection
Framework
GCF 8
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.50
Java ME 8 Key Features
 Aligned with Java SE 8
– Language, libraries, VM
 Designed for embedded
– Fully headless operation
– Remote software provisioning and management
 Highly portable and scalable
– Minimum RAM footprint of 1Mb
 Consistent across devices
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.51
Java ME 8 Key Features
 Advanced application platform
– Multi-application model
 Modularised software services
– Faster and more flexible software development and deployment
 Multi-client domains (“partitioning”)
– Different clients can have different security domains
 Access to peripheral devices (Device I/O API)
 Compatible with JCP/JSR standard APIs
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.52
Generic Connection Framework 8
 SecureServerConnection
 SecureDatagramConnection
 ModemConnection
 UDPMulticastConnection
 CommConnection
 HttpConnection
 HttpsConnection
 SecureConnection
 ServerSocketConnection
 SocketConnection
 UDPDatagramConnection
Substantially Increased Range of Connection Types
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.53
MEEP 8
Java ME Embedded Profile (MEEP) 8
Architecture
CLDC 8
javax.
microedition.
midlet
NEW
UPDATED
javax.
microedition.
io
(optional)
javax.
microedition.
event
(optional)
javax.
microedition.
key
(optional)
javax.
microedition.
lui
(optional)
javax.
microedition.
media
(optional)
javax.
microedition.
power
(optional)
javax.
microedition.
rms
(optional)
javax.
microedition.
swm
(optional)
javax.
microedition.
cellular
(optional)
Application or Service
Application or Service
Application or Service
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.54
NetBeans 8:
The IDE For Java 8
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.55
Tools for Java SE 8
 Quickly convert
anonymous
inner
classes
to lambdas
Lambda Expressions
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.56
Tools for Java SE 8
 Static analysis
to ensure
safe transformation,
automatically
add cast
for correct type
Lambda Expressions
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.57
Tools for Java SE 8
 Smoothly convert
to internal iterators
via hints and tips
Internal Iterators via Java 8 Streams
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.58
Tools for Java SE 8
 Easily convert
from lambdas
to method references
Method References
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.59
Tools for Java SE 8
 Specify a scope
for upgrading to Java 8
– All/current projects
– Specific package
– Specific class
 Run converters
 Visually preview
proposals for
refactoring
Refactoring in Batch Mode
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.60
Tools for Java SE Embedded 8
 Full Development Cycle support
against a remote platform
– Intuitive development
– One-click deploy
– Remote debugging
– Comprehensive remote profiling
 Complete end to end integration
for Raspberry Pi and other
embedded devices,
– e.g.Web Services.
Seamless Integration
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.61
Tools for Java ME Embedded 8
 Java ME 8 CLDC
Platform Emulator
 Intuitive tools and editors
for JDK 8 on Java ME
 Simple customization
of optional packages
Seamless Integration
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.62
Where Next?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.63
To Java SE 9 and Beyond!
Jigsaw
Cloud
Ease of use
Optimizations Generic Lang Interoperability
Penrose
OpenJFX
Project Sumatra – Java for GPUs
Ports: Power PC/AIX
Multi-Tenancy Support
Self Tuning JVM
Improved Integration with Native
Resource Management
Lang Enhancements
Unified Type System
Data Structure Optimizations
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.64
Conclusions
 Java SE 8 adds powerful new features to the core
– Lambda expressions, streams and functions
– New controls, stylesheet and 3D support in JavaFX
 Java ME 8 focused on embedded development
– Device I/O APIs
 NetBeans 8, ready for Java 8 development
– Lambda support, embedded support
 Java continues to evolve
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.65

More Related Content

What's hot

Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9Simon 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
 
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 RitterJAXLondon2014
 
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
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
 
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
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New FeaturesNaveen Hegde
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & StreamsC4Media
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features OverviewSergii Stets
 
java 8 new features
java 8 new features java 8 new features
java 8 new features Rohit Verma
 
Rdf Processing On The Java Platform
Rdf Processing On The Java PlatformRdf Processing On The Java Platform
Rdf Processing On The Java Platformguestc1b16406
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigoujaxconf
 

What's hot (20)

Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9
 
Lambdas And Streams Hands On Lab
Lambdas And Streams Hands On LabLambdas And Streams Hands On Lab
Lambdas And Streams Hands On Lab
 
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
 
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
 
JDK8 Streams
JDK8 StreamsJDK8 Streams
JDK8 Streams
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
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 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
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...
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
Java 8
Java 8Java 8
Java 8
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & Streams
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Major Java 8 features
Major Java 8 featuresMajor Java 8 features
Major Java 8 features
 
Rdf Processing On The Java Platform
Rdf Processing On The Java PlatformRdf Processing On The Java Platform
Rdf Processing On The Java Platform
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
 

Similar to Apouc 2014-java-8-create-the-future

What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8javafxpert
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Simon Ritter
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 itiAhmed mar3y
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesRaffi Khatchadourian
 
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
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...AMD Developer Central
 
A Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its APIA Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its APIJörn Guy Süß JGS
 
Belfast JUG 23-10-2013
Belfast JUG 23-10-2013Belfast JUG 23-10-2013
Belfast JUG 23-10-2013eamonnlong
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
 
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 PrimeFacesMert Çalışkan
 
Effective Java, Third Edition - Keepin' it Effective
Effective Java, Third Edition - Keepin' it EffectiveEffective Java, Third Edition - Keepin' it Effective
Effective Java, Third Edition - Keepin' it EffectiveC4Media
 
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 2013Martin Fousek
 

Similar to Apouc 2014-java-8-create-the-future (20)

What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Java8
Java8Java8
Java8
 
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
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
Keynote (Nandini Ramani) - The Role of Java in Heterogeneous Computing & How ...
 
A Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its APIA Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its API
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 
Completable future
Completable futureCompletable future
Completable future
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Belfast JUG 23-10-2013
Belfast JUG 23-10-2013Belfast JUG 23-10-2013
Belfast JUG 23-10-2013
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
 
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
 
Effective Java, Third Edition - Keepin' it Effective
Effective Java, Third Edition - Keepin' it EffectiveEffective Java, Third Edition - Keepin' it Effective
Effective Java, Third Edition - Keepin' it Effective
 
Lambda.pdf
Lambda.pdfLambda.pdf
Lambda.pdf
 
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
 

More from OUGTH Oracle User Group in Thailand

More from OUGTH Oracle User Group in Thailand (18)

Quarterly leader-call-dec-2014
Quarterly leader-call-dec-2014Quarterly leader-call-dec-2014
Quarterly leader-call-dec-2014
 
Oracle Database Monitoring with AAS
Oracle Database Monitoring with AASOracle Database Monitoring with AAS
Oracle Database Monitoring with AAS
 
How oracle 12c flexes its muscles against oracle 11g r2
How oracle 12c flexes its muscles against oracle 11g r2How oracle 12c flexes its muscles against oracle 11g r2
How oracle 12c flexes its muscles against oracle 11g r2
 
Presentation joelperez thailand2014
Presentation joelperez thailand2014Presentation joelperez thailand2014
Presentation joelperez thailand2014
 
How to-work-with-the-oracle-user-group-team
How to-work-with-the-oracle-user-group-teamHow to-work-with-the-oracle-user-group-team
How to-work-with-the-oracle-user-group-team
 
Apouc 2014-enterprise-manager-12c
Apouc 2014-enterprise-manager-12cApouc 2014-enterprise-manager-12c
Apouc 2014-enterprise-manager-12c
 
Apouc 2014-learn-from-oracle-support
Apouc 2014-learn-from-oracle-supportApouc 2014-learn-from-oracle-support
Apouc 2014-learn-from-oracle-support
 
Apouc 2014-business-analytics-and-big-data
Apouc 2014-business-analytics-and-big-dataApouc 2014-business-analytics-and-big-data
Apouc 2014-business-analytics-and-big-data
 
Apouc 2014-oracle-applications-update
Apouc 2014-oracle-applications-updateApouc 2014-oracle-applications-update
Apouc 2014-oracle-applications-update
 
Apouc 2014-oracle mobile platform
Apouc 2014-oracle mobile platformApouc 2014-oracle mobile platform
Apouc 2014-oracle mobile platform
 
Apouc 2014-oracle-ace-program
Apouc 2014-oracle-ace-programApouc 2014-oracle-ace-program
Apouc 2014-oracle-ace-program
 
Apouc 2014-oracle-community-programs
Apouc 2014-oracle-community-programsApouc 2014-oracle-community-programs
Apouc 2014-oracle-community-programs
 
Apouc 2014-oracle-cloud-strategy
Apouc 2014-oracle-cloud-strategyApouc 2014-oracle-cloud-strategy
Apouc 2014-oracle-cloud-strategy
 
Apouc 2014-wrapup
Apouc 2014-wrapupApouc 2014-wrapup
Apouc 2014-wrapup
 
How to install oracle 12c release 1
How to install oracle 12c release 1How to install oracle 12c release 1
How to install oracle 12c release 1
 
User 2013-oracle-big-data-analytics-1971985
User 2013-oracle-big-data-analytics-1971985User 2013-oracle-big-data-analytics-1971985
User 2013-oracle-big-data-analytics-1971985
 
Session 307 ravi pendekanti engineered systems
Session 307  ravi pendekanti engineered systemsSession 307  ravi pendekanti engineered systems
Session 307 ravi pendekanti engineered systems
 
Session 203 iouc summit database
Session 203 iouc summit databaseSession 203 iouc summit database
Session 203 iouc summit database
 

Apouc 2014-java-8-create-the-future

  • 1. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.1
  • 2. Java 8: Create The Future Simon Ritter Head of Java Technology Evangelism Oracle Corp.
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3 Program Agenda  Java SE 8: Enhancing the Core Java Platform – Lambdas and Streams – Other new features  Java ME 8: Building The Internet of Things  NetBeans 8: The IDE For Java 8  Where Next?
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4 Java SE 8: Lambdas & Streams: Functional Programming In Java
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 1.4 5.0 6 7 8 java.lang.Thread java.util.concurrent (jsr166) Fork/Join Framework (jsr166y) Project Lambda Concurrency in Java Phasers, etc (jsr166)
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6 The Problem: External Iteration List<Student> students = ... double highestScore = 0.0; for (Student s : students) { if (s.gradYear == 2011) { if (s.score > highestScore) { highestScore = s.score; } } } • Client controls iteration • Inherently serial: iterate from beginning to end • Not thread-safe because business logic is stateful (mutable accumulator variable)
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7 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 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();
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8 Internal Iteration With Lambdas SomeList<Student> students = ... double highestScore = students. filter(Student s -> s.getGradYear() == 2011). map(Student s -> s.getScore()). max(); • More readable • More abstract • Less error-prone
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9 Lambda Expressions  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 Some Details double highestScore = students. filter(Student s -> s.getGradYear() == 2011) map(Student s -> s.getScore()) max(); What How
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10 Lambda Expressions  Definition – A functional interface is an interface with only one abstract method – However, the interface may have more than one method  Identified structurally – Type is inferred from the context – Works for both assignment and method parameter contexts  The type of a Lambda expression is a functional interface – Instances of functional interfaces are created with Lambda expressions – @FunctionalInterface annotation Functional Interfaces
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11 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 List<String> list = getList(); Collections.sort(list, (String x, String y) -> x.length() - y.length()); Collections.sort(list, (x, y) -> x.length() - y.length()); static T void sort(List<T> l, Comparator<? super T> c);
  • 12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12 Lambda Epressions • Lambda expressions can refer to effectively final local variables from the enclosing scope – This means a variable behaves as if it is marked final (even if it is not) – The variable is assigned once • Lambda expressions are anonymous functions – They are not associated with an object – this will refer to the object in the surrounding scope Local Variable Capture & The Meaning of ‘this’
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13 Method References • Method references let us reuse a method as a lambda expression FileFilter x = (File f) -> f.canRead(); FileFilter x = File::canRead;
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14 Constructor References  Same concept as a method reference – For the constructor Factory<List<String>> f = ArrayList<String>::new; Factory<List<String>> f = () -> return new ArrayList<String>(); Equivalent to
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15 Default Methods  Provide a mechanism to add new methods to existing interfaces – Without breaking backwards compatability – Gives Java multiple inheritance of behaviour, as well as types  but not state! public interface Set<T> extends Collection<T> { ... // The existing Set methods default Spliterator<E> spliterator() { return Spliterators.spliterator(this, Spliterator.DISTINCT); } }
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16 Static Methods In Interfaces  Previously it was not possible to include static methods in an interface  Static methods, by definition, are not abstract – @FunctionalInterface can have zero or more static methods static <T> Predicate<T> isEqual(Object target) { return (null == target) ? Objects::isNull : object -> target.equals(object); }
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17 Streams API  Most business logic is about aggregate operations – “Most profitable product by region” – “Group transactions by currency”  As we have seen, up to now, Java mostly uses external iteration – Inherently serial – Frustratingly imperative  Java SE 8’s answer: Streams – With help from Lambdas Aggregate Operations
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18 Stream Overview  Abstraction for specifying aggregate computations – Not a data structure – Can be infinite  Simplifies the description of aggregate computations – Exposes opportunities for optimisation – Fusing, laziness and parrallelism High Level
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19 Stream Overview  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 Pipeline int sum = transactions.stream(). filter(t -> t.getBuyer().getCity().equals(“London”)). mapToInt(Transaction::getPrice). sum(); Source Intermediate operation Terminal operation
  • 20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20 Stream Overview  The filter and map methods don’t really do any work – They set up a pipeline of operations and return a new Stream  All work happens when we get to the sum() operation – filter()/map()/sum() fused into one pass on the data  For both sequential and parallel pipelines Execution int sum = transactions.stream(). filter(t -> t.getBuyer().getCity().equals(“London”)). // Lazy mapToInt(Transaction::getPrice). // Lazy sum(); // Execute the pipeline
  • 21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21 Stream Sources  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() Many Ways To Create
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.22 Stream Sources  Access to stream elements  Decomposition (for parallel operations) – Fork-join framework  Stream characteristics – ORDERED – DISTINCT – SORTED – SIZED – NONNULL – IMMUTABLE – CONCURRENT Manage Three Aspects
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23 Stream Intermediate Operations  Uses lazy evaluation where possible  Can affect stream characteristics – map() preserves SIZED but not DISTINCT or SORTED  Some operations fuse/convert to parallel better than others – Stateless operations (map, filter) fuse/convert perfectly – Stateful operations (sorted, distint, limit) fuse/convert to varying degrees
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24 Stream Terminal Operations  Invoking a terminal operation executes the pipeline – All operations can execute sequentially or in parallel  Terminal operations can take advantage of pipeline characteristics – toArray() can avoid copying for SIZED pipelines by allocating in advance
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25 Optional<T>  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 Reducing NullPointerException Occurences 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());
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.26 java.util.function Package  Predicate<T> – Determine if the input of type T matches some criteria  Consumer<T> – Accept a single input argumentof type T, and return no result  Function<T, R> – Apply a function to the input type T, generating a result of type R  Plus several more type specific versions
  • 27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.27 Stream Example 1 Convert words in list to upper case List<String> output = wordList. stream(). map(String::toUpperCase). collect(Collectors.toList());
  • 28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.28 Stream Example 1 Convert words in list to upper case (in parallel) List<String> output = wordList. parallelStream(). map(String::toUpperCase). collect(Collectors.toList());
  • 29. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.29 Stream Example 2 Find words in list with even length List<String> output = wordList. stream(). filter(w -> (w.length() & 1 == 0). collect(Collectors.toList());
  • 30. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.30 Stream Example 3  BufferedReader has new method – Stream<String> lines() Count lines in a file long count = bufferedReader. lines(). count();
  • 31. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.31 Stream Example 4 Find the length of the longest line in a file int longest = reader. lines(). mapToInt(String::length). max(). getAsInt();
  • 32. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.32 Stream 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());
  • 33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.33 Stream 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());
  • 34. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.34 Java SE 8: Other New Features
  • 35. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.35 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) {…}
  • 36. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.36 Concurrency Updates  Scalable update variables – DoubleAccumulator, DoubleAdder, etc – Multiple variables avoid update contention – Good for frequent updates, infrequent reads  ForkJoinPool improvements – Completion based design for IO bound applications – Thread that is blocked hands work to thread that is running
  • 37. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.37 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
  • 38. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.38 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
  • 39. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.39 Base64 Encoding and Decoding  Currently developers are forced to use non-public APIs – sun.misc.BASE64Encoder – sun.misc.BASE64Decoder  Java SE 8 now has a standard way – java.util.Base64.Encoder – java.util.Base64.Decoder – encode, encodeToString, decode, wrap methods
  • 40. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.40 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
  • 41. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.41 Removal Of 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 Permanently
  • 42. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.42 JavaFX 8  DatePicker  TreeTableView New Controls
  • 43. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.43 JavaFX 8  Gestures – Swipe – Scroll – Rotate – Zoom  Touch events and touch points Touch Support
  • 44. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.44 JavaFX 8  Predefined shapes – Box – Cylinder – Sphere  User-defined shapes – TriangleMesh, MeshView  PhongMaterial  Lighting  Cameras 3D Support
  • 45. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.45 Compact Profiles Approximate static footprint goals Compact1 Profile Compact2 Profile Compact3 Profile Full JRE 54Mb 30Mb 16Mb 11Mb
  • 46. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.46 Java SE Embedded  Optimised binary for embedded use from devices to gateways  Latest Java innovations in the smallest footprint  Use of compact profiles – Approximate JRE size 20.4Mb (ARM v7 VFS, Hard Float)  Compact profile 1: 10.4Mb  JavaFX: 10Mb  Production ready binary for popular platforms that run Linux – ARM v6/7 with Hard floating point – Raspberry Pi is one of the reference platforms
  • 47. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.47 Java ME 8: Building The Internet of Things
  • 48. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.48 Java ME 8 Focus Java ME EmbeddedJava Card SECURITY SMALL EMBEDDED MEDIUM EMBEDDED LARGE EMBEDDED DESKTOP SERVER 50KB-1MB 1MB-10MB 10MB-100MB Footprint Java SE Embedded Java Embedded Suite Oracle Event Processing Embedded 100MB+ Java SE ARM Cortex M3/M4 ARM Cortex-A
  • 49. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.49 Java ME 8 Platform Overview Java VM Additional APIs (Examples) Java ME Connected Limited Device Configuration (CLDC) 8 (JSR 360) Additional Optional APIs On-Device I/O Access Vertical Specific APIs Location Messaging Wireless Communication Web Services Protocols and Data Conversion Sensors Additional Optional JSRs Security and Management Use Case Software (e.g. smart pen) Use Case Software (e.g. wireless module) Use Case Software (e.g. control unit) Use Case Software (e.g. smart meter) Application Platform Java ME Embedded Profile (MEEP) 8 (JSR 361) On-Device I/O Access Device I/O API SATSA (JSR 177) Security and Trust Services Generic Connection Framework GCF 8
  • 50. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.50 Java ME 8 Key Features  Aligned with Java SE 8 – Language, libraries, VM  Designed for embedded – Fully headless operation – Remote software provisioning and management  Highly portable and scalable – Minimum RAM footprint of 1Mb  Consistent across devices
  • 51. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.51 Java ME 8 Key Features  Advanced application platform – Multi-application model  Modularised software services – Faster and more flexible software development and deployment  Multi-client domains (“partitioning”) – Different clients can have different security domains  Access to peripheral devices (Device I/O API)  Compatible with JCP/JSR standard APIs
  • 52. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.52 Generic Connection Framework 8  SecureServerConnection  SecureDatagramConnection  ModemConnection  UDPMulticastConnection  CommConnection  HttpConnection  HttpsConnection  SecureConnection  ServerSocketConnection  SocketConnection  UDPDatagramConnection Substantially Increased Range of Connection Types
  • 53. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.53 MEEP 8 Java ME Embedded Profile (MEEP) 8 Architecture CLDC 8 javax. microedition. midlet NEW UPDATED javax. microedition. io (optional) javax. microedition. event (optional) javax. microedition. key (optional) javax. microedition. lui (optional) javax. microedition. media (optional) javax. microedition. power (optional) javax. microedition. rms (optional) javax. microedition. swm (optional) javax. microedition. cellular (optional) Application or Service Application or Service Application or Service
  • 54. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.54 NetBeans 8: The IDE For Java 8
  • 55. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.55 Tools for Java SE 8  Quickly convert anonymous inner classes to lambdas Lambda Expressions
  • 56. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.56 Tools for Java SE 8  Static analysis to ensure safe transformation, automatically add cast for correct type Lambda Expressions
  • 57. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.57 Tools for Java SE 8  Smoothly convert to internal iterators via hints and tips Internal Iterators via Java 8 Streams
  • 58. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.58 Tools for Java SE 8  Easily convert from lambdas to method references Method References
  • 59. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.59 Tools for Java SE 8  Specify a scope for upgrading to Java 8 – All/current projects – Specific package – Specific class  Run converters  Visually preview proposals for refactoring Refactoring in Batch Mode
  • 60. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.60 Tools for Java SE Embedded 8  Full Development Cycle support against a remote platform – Intuitive development – One-click deploy – Remote debugging – Comprehensive remote profiling  Complete end to end integration for Raspberry Pi and other embedded devices, – e.g.Web Services. Seamless Integration
  • 61. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.61 Tools for Java ME Embedded 8  Java ME 8 CLDC Platform Emulator  Intuitive tools and editors for JDK 8 on Java ME  Simple customization of optional packages Seamless Integration
  • 62. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.62 Where Next?
  • 63. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.63 To Java SE 9 and Beyond! Jigsaw Cloud Ease of use Optimizations Generic Lang Interoperability Penrose OpenJFX Project Sumatra – Java for GPUs Ports: Power PC/AIX Multi-Tenancy Support Self Tuning JVM Improved Integration with Native Resource Management Lang Enhancements Unified Type System Data Structure Optimizations
  • 64. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.64 Conclusions  Java SE 8 adds powerful new features to the core – Lambda expressions, streams and functions – New controls, stylesheet and 3D support in JavaFX  Java ME 8 focused on embedded development – Device I/O APIs  NetBeans 8, ready for Java 8 development – Lambda support, embedded support  Java continues to evolve
  • 65. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.65