Java 8, Java 9, and Beyond! - jfokus.se · base tls logging auth jdbc jta rmi naming jaxp rowset...

Preview:

Citation preview

Insert Presenterʼs Name HereInsert Presenterʼs Title Here

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13

Java 8, Java 9, and Beyond!

Mark Reinhold (@mreinhold)Chief Architect, Java Platform Group, Oracle

Jfokus 2013

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Java 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Lambda (JSR 335)

Java 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Lambda (JSR 335)

Compact ProfilesJava 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Lambda (JSR 335)

Compact ProfilesJava 8

Nashorn

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Lambda (JSR 335)Date/Time API (JSR 310)

Compact ProfilesJava 8

Nashorn

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Lambda (JSR 335)Date/Time API (JSR 310)

Type Annotations (JSR 308)

Compact ProfilesJava 8

Nashorn

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

Lambda (JSR 335)Date/Time API (JSR 310)

Type Annotations (JSR 308)

Compact Profiles

Lambda-Form Representation for Method Handles

Remove the Permanent Generation

Improve Contended LockingGeneralized Target-Type Inference

DocTree API

Parallel Array Sorting

Bulk Data Operations Unicode 6.2Base64 HTTP ClientNSA Suite B

Prepare for Modularization

Unicode CLDR

TLS Server Name IndicationConfigurable Secure-Random Number Generation

Java 8Nashorn

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.3

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.3

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.4

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.4

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Colors and Shapes

5

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Colors and Shapes

5

enum Color { RED, GREEN, BLUE }

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Colors and Shapes

5

enum Color { RED, GREEN, BLUE }

class Shape {

Shape() { ... } Shape(Shape s, double area) { ... }

Color getColor() { ... } void setColor(Color c) { ... }

double getArea() { ... }

}

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.6

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.6

List<Shape> shapes = ...;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.6

// Sort shapes by colorComparator<Shape> c = new Comparator<Shape>() { public int compare(Shape s, Shape t) { return s.getColor().compareTo(t.getColor()); }};Collections.sort(shapes, c);

List<Shape> shapes = ...;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.7

// Sort shapes by colorComparator<Shape> c = new Comparator<Shape>() { public int compare(Shape s, Shape t) { return s.getColor().compareTo(t.getColor()); }};Collections.sort(shapes, c);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.7

// Sort shapes by color, with a lambdaComparator<Shape> c = (Shape s, Shape t) -> s.getColor().compareTo(t.getColor());Collections.sort(shapes, c);

Lambda expressions

// Sort shapes by colorComparator<Shape> c = new Comparator<Shape>() { public int compare(Shape s, Shape t) { return s.getColor().compareTo(t.getColor()); }};Collections.sort(shapes, c);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.8

Lambda expressions

// Sort shapes by color, with a lambdaComparator<Shape> c = (Shape s, Shape t) -> s.getColor().compareTo(t.getColor());Collections.sort(shapes, c);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.8

// Sort shapes by color, with a lambda using type inferenceComparator<Shape> c = (s, t) -> s.getColor().compareTo(t.getColor());Collections.sort(shapes, c);

Lambda expressions

// Sort shapes by color, with a lambdaComparator<Shape> c = (Shape s, Shape t) -> s.getColor().compareTo(t.getColor());Collections.sort(shapes, c);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Lambda expressions

9

// Sort shapes by color, with a lambda using type inferenceComparator<Shape> c = (s, t) -> s.getColor().compareTo(t.getColor());Collections.sort(shapes, c);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Lambda expressions

9

// Sort shapes by color, in one statementCollections.sort(shapes, (s, t) -> s.getColor().compareTo(t.getColor()));

// Sort shapes by color, with a lambda using type inferenceComparator<Shape> c = (s, t) -> s.getColor().compareTo(t.getColor());Collections.sort(shapes, c);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.10

Functional interfaces

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.10

Functional interfaces

// Compare shapes by colorComparator<Shape> c = (s, t) -> s.getColor().compareTo(t.getColor());

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.10

Functional interfaces

// Compare shapes by colorComparator<Shape> c = (s, t) -> s.getColor().compareTo(t.getColor());

// Test whether a shape is redPredicate<Shape> p = s -> s.getColor() == RED;

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.10

Functional interfaces

// Compare shapes by colorComparator<Shape> c = (s, t) -> s.getColor().compareTo(t.getColor());

// Test whether a shape is redPredicate<Shape> p = s -> s.getColor() == RED;

// Extract the area of a shapeFunction<Shape,Double> f = s -> s.getArea();

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.10

Functional interfaces

// Compare shapes by colorComparator<Shape> c = (s, t) -> s.getColor().compareTo(t.getColor());

// Test whether a shape is redPredicate<Shape> p = s -> s.getColor() == RED;

// Extract the area of a shapeFunction<Shape,Double> f = s -> s.getArea();

// Create a bigger shape from a given shapeUnaryOperator<Shape> o = s -> new Shape(s, s.getArea() * 2);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.11

Iteration

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.11

Iteration

// Paint red shapes blueList<Shape> shapes = ...;for (Shape s : shapes) { if (s.getColor() == RED) s.setColor(BLUE);}

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.11

Iteration

// Paint red shapes blueList<Shape> shapes = ...;for (Shape s : shapes) { if (s.getColor() == RED) s.setColor(BLUE);}

, using external iteration

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.11

Iteration

// Paint red shapes blueList<Shape> shapes = ...;for (Shape s : shapes) { if (s.getColor() == RED) s.setColor(BLUE);}

// Paint red shapes blue, using internal iterationshapes.forEach(s -> { if (s.getColor() == RED) s.setColor(BLUE); });

, using external iteration

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Default methods

12

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Default methods

12

interface Iterable<T> {

Iterator<T> iterator();

default void forEach(Consumer<? super T> consumer) { for (T t : this) consumer.accept(t); }

}

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Default methods

13

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Default methods

13

interface Collection<E> { default boolean removeAll(Predicate<? super E> filter) { boolean removed = false; Iterator<E> each = iterator(); while (each.hasNext()) { if (filter.test(each.next())) { each.remove(); removed = true; } } return removed; }}

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Default methods

14

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Default methods

14

interface List<E> { ... default void replaceAll(UnaryOperator<E> op) { final ListIterator<E> li = this.listIterator(); while (li.hasNext()) li.set(op.apply(li.next())); }}

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.15

// Paint red shapes blue, using internal iterationshapes.forEach(s -> { if (s.getColor() == RED) s.setColor(BLUE); });

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.15

// Paint red shapes blue, using internal iterationshapes.forEach(s -> { if (s.getColor() == RED) s.setColor(BLUE); });

Streams

// Paint red shapes blue, using bulk operations on a streamshapes.stream() .filter(s -> s.getColor() == RED) .forEach(s -> { s.setColor(BLUE); });

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.16

Streams

// Paint red shapes blue, using bulk operations on a streamshapes.stream() .filter(s -> s.getColor() == RED) .forEach(s -> { s.setColor(BLUE); });

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.16

Streams

// Paint red shapes blue, using bulk operations on a streamshapes.stream() .filter(s -> s.getColor() == RED) .forEach(s -> { s.setColor(BLUE); });

// Find the first blue shapeShape firstBlue = shapes.stream() .filter(s -> s.getColor() == BLUE) .findFirst().get();

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.17

Streams

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.17

Streams

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(s -> s.getArea()) .reduce(0.0, (a, b) -> a + b);

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.17

Streams

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(s -> s.getArea()) .reduce(0.0, (a, b) -> a + b);

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(s -> s.getArea()) .sum();

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.18

Streams

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(s -> s.getArea()) .sum();

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.18

Streams

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(s -> s.getArea()) .sum();

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(Shape::getArea) .sum();

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.19

Streams

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(Shape::getArea) .sum();

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.19

Streams

// Compute the sum of the areas of blue shapesdouble sumOfAreas = shapes.stream() .filter(s -> s.getColor() == BLUE) .map(Shape::getArea) .sum();

// Compute the sum of the areas of blue shapes, in paralleldouble sumOfAreas = shapes.parallelStream() .filter(s -> s.getColor() == BLUE) .map(Shape::getArea) .sum();

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.20

openjdk.java.net/projects/lambdajdk8.java.net/lambda

Project Lambda

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.20

openjdk.java.net/projects/lambdajdk8.java.net/lambda

Project Lambda

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.20

openjdk.java.net/projects/lambdajdk8.java.net/lambda

Project Lambda

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.21

Lambda (JSR 335)Date/Time API (JSR 310)

Type Annotations (JSR 308)

Compact Profiles

Lambda-Form Representation for Method Handles

Remove the Permanent Generation

Improve Contended LockingGeneralized Target-Type Inference

DocTree API

Parallel Array Sorting

Bulk Data Operations Unicode 6.2Base64 HTTP ClientNSA Suite B

Prepare for Modularization

Unicode CLDR

TLS Server Name IndicationConfigurable Secure-Random Number Generation

Java 8Nashorn

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.22

Project Jigsawopenjdk.java.net/projects/jigsaw

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.22

Project Jigsawopenjdk.java.net/projects/jigsaw

http://www.flickr.com/photos/lizadaly/2944362379

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.23

Modular platform: Before

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.23

50 nodes171 edges

Modular platform: Before

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Modular platform:

24

Before 50 nodes171 edges

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Modular platform:

24

After 32 nodes105 edges

base

tls loggingauthjdbc

jtarmi

jaxpnaming

rowset

kerberos management

compiler

xmldsig

prefssctp

instrument

scripting

crypto

compat

management.iiop

cosnaming

corba

desktop

tools.jre

jaxws

jx.annotations

httpserver

tools

tools.jaxws tools.base

devtools

base

tls loggingauthjdbc

jtarmi

jaxpnaming

rowset

kerberos management

compiler

xmldsig

prefssctp

instrument

scripting

crypto

compat

management.iiop

cosnaming

corba

desktop

tools.jre

jaxws

jx.annotations

httpserver

tools

tools.jaxws tools.base

devtools

52MB

base

tls loggingauthjdbc

jtarmi

jaxpnaming

rowset

kerberos management

compiler

xmldsig

prefssctp

instrument

scripting

crypto

compat

management.iiop

cosnaming

corba

desktop

tools.jre

jaxws

jx.annotations

httpserver

tools

tools.jaxws tools.base

devtools

1052MB

base

tls loggingauthjdbc

jtarmi

jaxpnaming

rowset

kerberos management

compiler

xmldsig

prefssctp

instrument

scripting

crypto

compat

management.iiop

cosnaming

corba

desktop

tools.jre

jaxws

jx.annotations

httpserver

tools

tools.jaxws tools.base

devtools

1052MB 17

base

tls loggingauthjdbc

jtarmi

jaxpnaming

rowset

kerberos management

compiler

xmldsig

prefssctp

instrument

scripting

crypto

compat

management.iiop

cosnaming

corba

desktop

tools.jre

jaxws

jx.annotations

httpserver

tools

tools.jaxws tools.base

devtools

1052MB 1724

base

tls loggingauthjdbc

jtarmi

jaxpnaming

rowset

kerberos management

compiler

xmldsig

prefssctp

instrument

scripting

crypto

compat

management.iiop

cosnaming

corba

desktop

tools.jre

jaxws

jx.annotations

httpserver

tools

tools.jaxws tools.base

devtools

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Compact Profiles

26

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Compact Profiles

26

compact1java.iojava.langjava.mathjava.netjava.niojava.securityjava.textjava.utiljavax.cryptojavax.netjavax.security

10MB

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Compact Profiles

26

compact1java.iojava.langjava.mathjava.netjava.niojava.securityjava.textjava.utiljavax.cryptojavax.netjavax.security

compact2java.rmijava.sqljavax.rmijavax.sqljavax.transactionjavax.xmlorg.w3c.domorg.xml.sax

10MB 17

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Compact Profiles

26

compact1java.iojava.langjava.mathjava.netjava.niojava.securityjava.textjava.utiljavax.cryptojavax.netjavax.security

compact2java.rmijava.sqljavax.rmijavax.sqljavax.transactionjavax.xmlorg.w3c.domorg.xml.sax

compact3java.lang.instrumentjava.lang.managementjava.util.prefsjavax.annotation.processingjavax.lang.modeljavax.managementjavax.namingjavax.scriptjavax.security.acljavax.security.auth.kerberosjavax.security.sasljavax.sql.rowsetjavax.toolsjavax.xml.cryptoorg.ietf.jgss

10MB 17 24

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Compact Profiles

26

compact1java.iojava.langjava.mathjava.netjava.niojava.securityjava.textjava.utiljavax.cryptojavax.netjavax.security

compact2java.rmijava.sqljavax.rmijavax.sqljavax.transactionjavax.xmlorg.w3c.domorg.xml.sax

compact3java.lang.instrumentjava.lang.managementjava.util.prefsjavax.annotation.processingjavax.lang.modeljavax.managementjavax.namingjavax.scriptjavax.security.acljavax.security.auth.kerberosjavax.security.sasljavax.sql.rowsetjavax.toolsjavax.xml.cryptoorg.ietf.jgss

Full JREjava.appletjava.awtjava.beansjavax.accessibilityjavax.activationjavax.activityjavax.annotationjavax.imageiojavax.jwsjavax.printjavax.rmijavax.rmi.CORBAjavax.soundjavax.swingjavax.xml.bindjavax.xml.soapjavax.xml.wsorg.omg

10MB 17 24 52

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.27

Lambda (JSR 335)Date/Time API (JSR 310)

Type Annotations (JSR 308)

Compact Profiles

Lambda-Form Representation for Method Handles

Remove the Permanent Generation

Improve Contended LockingGeneralized Target-Type Inference

DocTree API

Parallel Array Sorting

Bulk Data Operations Unicode 6.2Base64 HTTP ClientNSA Suite B

Prepare for Modularization

Unicode CLDR

TLS Server Name IndicationConfigurable Secure-Random Number Generation

Java 8Nashorn

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.28

Java 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.28

Java 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.28

openjdk.java.net/projects/jdk8openjdk.java.net/projects/jdk8/specjdk8.java.net

Java 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.29

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.29

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.29

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.30

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.30

Java 9 … and beyond!

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.30

Jigsaw

ReificationEase of use

OpenJFX Self Tuning JVM

Unified Type System

Java 9 … and beyond!

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.30

Jigsaw

ReificationEase of use

Optimizations

Generic Lang Interoperability

Penrose

OpenJFXProject Sumatra – Java for GPUs

More and More Ports

Multi-Tenancy

Self Tuning JVMImproved Native Integration

Resource Management

Unified Type System

Data Structure Optimizations

Java 9 … and beyond!

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.31

JDK Enhancement Proposals (JEPs)openjdk.java.net/jeps

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.31

JDK Enhancement Proposals (JEPs)openjdk.java.net/jeps

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.32

JDK Enhancement Proposals (JEPs)138 Autoconf-Based Build System139 Enhance javac to Improve Build Speed140 Limited doPrivileged141 Increase the Client VM's Default Heap Size142 Reduce Cache Contention on Specified Fields143 Improve Contended Locking144 Reduce GC Latency for Large Heaps145 Cache Compiled Code146 Improve Fatal Error Logs147 Reduce Class Metadata Footprint148 Small VM149 Reduce Core-Library Memory Usage150 Date & Time API151 Compress Time-Zone Data152 Crypto Operations with Network HSMs153 Launch JavaFX Applications154 Remove Serialization155 Concurrency Updates156 G1 GC: Reduce need for full GCs

157 G1 GC: NUMA-Aware Allocation158 Unified JVM Logging159 Enhanced Class Redefinition160 Lambda-Form Representation for Method Handles161 Compact Profiles162 Prepare for Modularization163 Enable NUMA Mode by Default When Appropriate164 Leverage CPU Instructions for AES Cryptography 165 Compiler Control166 Overhaul JKS-JCEKS-PKCS12 Keystores167 Event-Based JVM Tracing168 Network Discovery of Manageable Java Processes169 Value Objects170 JDBC 4.2171 Fence Intrinsics172 DocLint173 Retire Some Rarely-Used GC Combinations174 Nashorn JavaScript Engine175 Integrate PowerPC/AIX Port into JDK 8

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.33

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.33

The preceding material 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 © 2013, Oracle and/or its affiliates. All rights reserved.34

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.34

openjdk.java.net/projects/jdk8jdk8.java.net

Insert Presenterʼs Name HereInsert Presenterʼs Title Here

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13

Java 8, Java 9, and Beyond!

Mark Reinhold (@mreinhold)Chief Architect, Java Platform Group, Oracle

Jfokus 2013

Recommended