Beyond Java 9 @ Jfokus 2015files.meetup.com/3189882/Beyond Java 9.pdf · Title: Beyond Java 9 @...
Transcript of Beyond Java 9 @ Jfokus 2015files.meetup.com/3189882/Beyond Java 9.pdf · Title: Beyond Java 9 @...
Mark Reinhold (@mreinhold)Chief Architect, Java Pla1orm GroupOracle
Beyond Java 9
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
2015/2/4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2
The preceding is intended to outline our general product direcDon. It is intended for informaDon purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or funcDonality, and should not be relied upon in making purchasing decisions. The development, release, and Dming of any features or funcDonality described for Oracle’s products remains at the sole discreDon of Oracle.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2
The preceding is intended to outline our general product direcDon. It is intended for informaDon purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or funcDonality, and should not be relied upon in making purchasing decisions. The development, release, and Dming of any features or funcDonality described for Oracle’s products remains at the sole discreDon of Oracle.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2
The preceding is intended to outline our general product direcDon. It is intended for informaDon purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or funcDonality, and should not be relied upon in making purchasing decisions. The development, release, and Dming of any features or funcDonality described for Oracle’s products remains at the sole discreDon of Oracle.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2
The preceding is intended to outline our general product direcDon. It is intended for informaDon purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or funcDonality, and should not be relied upon in making purchasing decisions. The development, release, and Dming of any features or funcDonality described for Oracle’s products remains at the sole discreDon of Oracle.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2
HIGHLY
SPECULATIVEThe preceding is intended to outline our general product
direcDon. It is intended for informaDon purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or funcDonality, and should not be relied upon in making purchasing decisions. The development, release, and Dming of any features or funcDonality described for Oracle’s products remains at the sole discreDon of Oracle.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3
final int x; final int y;}
class Point {
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4
Point[] points =
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4
headerPoint[] points =
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4
header
header
x
y
header
x
y
header
x
y
header
x
y
header
x
y
header
x
y
Point[] points = header
x
y
header
x
y
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4
header
x
x
x
x
x
x
x
x
int[] xs = header
y
y
y
y
y
y
y
y
int[] ys =
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4
Point[] points = header
x
y
x
y
x
y
x
y
x
y
x
y
x
y
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5
synchronized (points[i]) { ... }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6
if (points[i] == p) { ... }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 7
System.identityHashCode(points[i])
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 8
final int x; final int y;}
class Point {
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 8
final int x; final int y;}
class Point {value
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 8
final int x; final int y;}
class Point {value
“Codes like a class, works like an int!”
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 9
header
header
x
y
header
x
y
header
x
y
header
x
y
header
x
y
header
x
y
header
x
y
header
x
y
Point[] points =
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 9
header
x
y
x
y
x
y
x
y
x
y
x
y
x
y
Point[] points =
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 10
final int x; final int y;}
class Point {value
“Codes like a class, works like an int!”
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 11
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 11
int128ComplexDecimal
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 11
int128ComplexDecimal
Tuple<T,U,V>
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 11
int128ComplexDecimal
Tuple<T,U,V>
Optional<T>Either<T,U>
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 11
int128ComplexDecimal
Tuple<T,U,V>
Optional<T>Either<T,U>
Cursor<T>
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 12
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 12
public value class Optional<T> {
private final T value;
public T get() { if (value == null) throw new NoSuchElementException(); return value; }
public T orElse(T other) { return value != null ? value : other; }
// ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 13
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 13
interface Iterator<T> { boolean hasNext(); T next(); void remove();}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 14
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 14
class ArrayIterator<T> implements Iterator<T> {
private T[] array; private int offset;
public boolean hasNext() { return offset < array.length; }
public T next() { return array[offset++]; }
// ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 15
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 15
value class ArrayCursor<T> implements Cursor<T> {
private T[] array; private int offset;
public boolean notEmpty() { return offset < array.length; }
public T current() { return array[offset]; }
public T next() { return new Cursor(array, offset + 1); }
// ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 16
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 16
Cursor<String> c = Arrays.cursor(...);while (c.notEmpty()) { doSomething(c.current())); c = c.next();}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 17
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 17
new ArrayList<Point>()
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 18
new ArrayList<int>()
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList<int>
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList<int> ArrayList${T=int}.class
ArrayList<Point>
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList<int> ArrayList${T=int}.class
ArrayList${T=Point}.classArrayList<Point>
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList<int> ArrayList${T=int}.class
ArrayList${T=Point}.classArrayList<Complex>ArrayList<Point>
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList<int> ArrayList${T=int}.class
ArrayList${T=Complex}.classArrayList${T=Point}.class
ArrayList<Complex>ArrayList<Point>
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList<int> ArrayList${T=int}.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 20
for (int i = 0; i < size; i++) data[i] = null;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 20
private int size; private T[] data;
public void clear() {
public class ArrayList<T> {
size = 0; }
// ...
any
for (int i = 0; i < size; i++) data[i] = null;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 20
private int size; private T[] data;
public void clear() {
public class ArrayList< T> {
size = 0; }
// ...
any
for (int i = 0; i < size; i++) data[i] = null;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 20
private int size; private T[] data;
public void clear() {
public class ArrayList< T> {
size = 0; }
// ...
✘
any
for (int i = 0; i < size; i++) data[i] = null;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 20
private int size; private T[] data;
public void clear() {
public class ArrayList< T> {
size = 0; }
// ...
where ref t {
}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 21
public class ArrayList<any T> {
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 21
public class ArrayList<any T> {
public T remove public boolean remove(T element) { ... }
// ...
(int index) { ... }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 21
public class ArrayList<any T> {
public T remove public boolean remove(T element) { ... }
// ...
(int index) { ... }At
where ref T { default public T remove(int index) { return removeAt(index); } }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 21
public class ArrayList<any T> {
public T remove public boolean remove(T element) { ... }
// ...
(int index) { ... }At
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 22
ArrayList<boolean>
23
23
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 24
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 24
Project Valhalla
Project Panama
h8p://openjdk.java.net
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 24
Project Valhalla
Project Panama
Value TypesSpecialized GenericsVar Handles
h8p://openjdk.java.net
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 24
Project Valhalla
Project Panama
Value TypesSpecialized GenericsVar Handles
Foreign FuncDon InterfaceData Layout ControlArrays 2.0
h8p://openjdk.java.net
Mark Reinhold (@mreinhold)Chief Architect, Java Pla1orm GroupOracle
Beyond Java 9
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
2015/2/4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.