java 9, and beyond! @ eclipsecon na...
TRANSCRIPT
Mark Reinhold (@mreinhold)Chief Architect, Java Pla1orm GroupOracle
Java 9, and Beyond!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
2015/3/12EclipseCon
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
9
3 hDps://www.flickr.com/photos/ekilby/5938705159
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4hDp://www.flickr.com/photos/viagallery/2290654438
jre
compact3
30
compact2
17
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
55 MB
compact1
11
6 hDp://www.flickr.com/photos/thatguyfromcchs08/2300190277
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 7
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
java.iojava.langjava.lang.annotationjava.lang.invokejava.lang.refjava.lang.reflectjava.mathjava.netjava.niojava.nio.channelsjava.nio.channels.spijava.nio.charsetjava.nio.charset.spijava.nio.filejava.nio.file.attributejava.nio.file.spijava.securityjava.security.certjava.security.interfacesjava.security.specjava.textjava.text.spijava.timejava.time.chronojava.time.formatjava.time.temporaljava.time.zonejava.utiljava.util.concurrentjava.util.concurrent.atomicjava.util.concurrent.locks
java.util.functionjava.util.jarjava.util.regexjava.util.spijava.util.streamjava.util.zipjavax.cryptojavax.crypto.interfacesjavax.crypto.specjavax.security.authjavax.security.auth.callbackjavax.security.auth.loginjavax.security.auth.spijavax.security.auth.x500jdkjdk.internal.org.objectweb.asmjdk.internal.org.xml.saxjdk.internal.util.xmljdk.internal.util.xml.impljdk.jigsaw.modulejdk.jigsaw.tools.jlinkjdk.joptsimplejdk.joptsimple.internaljdk.joptsimple.utilsun.invokesun.invoke.anonsun.invoke.emptysun.invoke.utilsun.launchersun.launcher.resourcessun.misc
sun.misc.resourcessun.netsun.net.ftpsun.net.ftp.implsun.net.idnsun.net.sdpsun.net.smtpsun.net.spisun.net.spi.nameservicesun.net.utilsun.net.wwwsun.net.www.content.textsun.net.www.httpsun.net.www.protocol.filesun.net.www.protocol.ftpsun.net.www.protocol.httpsun.net.www.protocol.jarsun.net.www.protocol.mailtosun.net.www.protocol.netdocsun.niosun.nio.chsun.nio.cssun.nio.fssun.reflectsun.reflect.annotationsun.reflect.generics.factorysun.reflect.generics.parsersun.reflect.generics.scopesun.reflect.generics.treesun.reflect.generics.visitorsun.reflect.misc
sun.security.actionsun.security.jcasun.security.pkcssun.security.pkcs12sun.security.providersun.security.provider.certpathsun.security.rsasun.security.timestampsun.security.utilsun.security.validatorsun.security.x509sun.textsun.text.bidisun.text.normalizersun.text.resourcessun.text.resources.cldrsun.text.resources.cldr.ensun.text.resources.ensun.utilsun.util.calendarsun.util.cldrsun.util.localesun.util.locale.providersun.util.loggingsun.util.logging.resourcessun.util.resourcessun.util.resources.cldrsun.util.resources.cldr.ensun.util.resources.ensun.util.spi
java.lang.SecurityManager::checkPackageAccess
8
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 9
sun.**.internal.*
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 10
-‐classpath
11
12 hDps://www.flickr.com/photos/notbrucelee/5696238930
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Project Jigsaw
13
JEP 200: The Modular JDKJEP 201: Modular Source CodeJEP 220: Modular Run-‐Time ImagesJEP TBD / JSR 376: Java Pla[orm Module System
h8p://openjdk.java.net/projects/jigsaw
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 14
naming.rmi
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
base
se
compact3
compact2
compact1
logging scrip2ng
security.acl
security.sasl
sqlrmi
xmlxml.crypto
prefsdesktop
ac2va2on
corba
compiler management
sql.rowset
security.jgss
instrument
naming
xml.ws
xml.soap
xml.bind
annota2ons.common
h?pserver
rmic
javadoc
xml.ws
xml.bind
compiler
security.auth
scrip2ng.nashorn
hotspot.agent
jconsole jcmd jdi
a?ach
jvmstat
naming.dns
charsets
smartcardio
crypto.ec
crypto.pkcs11
hprof.agent
jdwp.agent
localedata
sctp
zipfs
15
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 16
jlink
*.jmod
$JRE/bin/app /lib/...
*.jar
*.class
JVM image
package java.sql;
public interface Connection {
PreparedStatement prepareStatement(String sql) throws SQLException { ...
package java.sql;
import sun.reflect.CallerSensitive;import sun.reflect.Reflection;
public class DriverManager {
...java.sql
*
*Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 17
sun.invoke
java.lang *
java.base
sun.reflect
java.util.logging*
java.loggingjava.sql
java.sqljava.logging java.sql**javax.sql
*
✘ java.lang not exported by java.base✘ sun.reflect not exported by java.base
app
com.foo.app
package com.foo.app;
import java.sql.*;
...
Driver d = DriverManager.getDriver(uri); Connection c = d.connect(uri, props); d.getParentLogger().info("Connection acquired");
package java.sql;
import java.util.logging.Logger;
public class Driver {
public Logger getParentLogger() throws SQLFeatureNotSupportedException;
❖
18 hDp://www.flickr.com/photos/pasukaru76/5268559005
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 19
JEP 201: Modular Source Code
src/{share,$OS}/{classes,native}/$PACKAGE/*.{java,c,h,cpp,hpp}
src/$MODULE/{share,$OS}/classes/$PACKAGE/*.java native/include/*.{h,hpp} $LIBRARY/*.{c,cpp} conf/*
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
JEP 220: Modular Run-‐Time Images
20
$JRE/bin/ /lib/*.{properties,policy} /endorsed /ext /rt.jar /$ARCH/*.so /$VM/*.so /...
$JRE/bin/ /conf/*.{properties,policy} /lib/$ARCH/*.so /$VM/*.so /...
/endorsed /ext /rt.jar
=> jar:file:/usr/local/jdk8/jre/lib/rt.jar!/java/lang/Class.class=> jar:file:/usr/local/jdk8/jre/lib/rt.jar!/java/lang/Class.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
JEP 220: Modular Run-‐Time Images
21
ClassLoader.getSystemResource("java/lang/Class.class");
=> jrt:/java.base/java/lang/Class.class
// NIO filesystem for accessing built-‐in classes & resourcesFileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));byte[] jlo = Files.readAllBytes(fs.getPath("/modules/java.base", "java/lang/Object.class"));
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 22
sun.**.internal.*
JEP TBD / JSR 376: Java Pla[orm Module System
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 23
$ jdeps app.jar
…Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
9
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 25
The preceding and following is intended to outline our general product direc]on. It is intended for informa]on purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or func]onality, and should not be relied upon in making purchasing decisions. The development, release, and ]ming of any features or func]onality described for Oracle’s products remains at the sole discre]on of Oracle.
HIGHLY
SPECULATIVE
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 26
final int x; final int y;}
class Point {
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 27
headerheader
x
x
x
x
x
x
x
x
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
int[] xs = Point[] points = header
x
y
x
y
x
y
x
y
x
y
x
y
x
y
header
y
y
y
y
y
y
y
y
int[] ys =
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 28
synchronized (points[i]) { ... }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 29
if (points[i] == p) { ... }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 30
System.identityHashCode(points[i])
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 31
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. 32
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
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. 33
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. 34
int128ComplexDecimal
Tuple<T,U,V>
Optional<T>Either<T,U>
Cursor<T>
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 35
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. 36
interface Iterator<T> { boolean hasNext(); T next(); void remove();}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 37
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. 38
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. 39
Cursor<String> c = Arrays.cursor(...);while (c.notEmpty()) { doSomething(c.current())); c = c.next();}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 40
new ArrayList<Point>()
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 41
new ArrayList<int>()
ArrayList${T=Complex}.classArrayList${T=Point}.class
ArrayList<Complex>ArrayList<Point>
ArrayList.classArrayList.class
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 42
ArrayList<String>ArrayList<Integer>ArrayList<URL>
ArrayList.class
ArrayList<int> ArrayList${T=int}.class
any
for (int i = 0; i < size; i++) data[i] = null;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 43
private int size; private T[] data;
public void clear() {
public class ArrayList<T> {
size = 0; }
// ...
✘ where ref t {
}
where ref T { default public T remove(int index) { return removeAt(index); } }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 44
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. 45
ArrayList<boolean>
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 46
Project Valhalla
Project Panama
Value TypesSpecialized GenericsVar Handles
Foreign Func]on InterfaceData Layout ControlArrays 2.0
h8p://openjdk.java.net
47
Mark Reinhold (@mreinhold)Chief Architect, Java Pla1orm GroupOracle
Java 9, and Beyond!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
2015/3/12EclipseCon
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Project Jigsaw
49
JEP 200: The Modular JDKJEP 201: Modular Source CodeJEP 220: Modular Run-‐Time ImagesJEP TBD / JSR 376: Java Pla[orm Module System
h8p://openjdk.java.net/projects/jigsaw
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 50
Project Valhalla
Project Panama
Value TypesSpecialized GenericsVar Handles
Foreign Func]on InterfaceData Layout ControlArrays 2.0
h8p://openjdk.java.net