Presentation JDK7 Update and Java SE 7
A survey of the key features being developed for JDK 7, by both Sun and non-Sun contributors, followed by a speculative look at potential features for future releases.
Published on: 2009-11-26T12:35:46.000Z
Channel: Devoxx'09 (all)
Tags: Java javase7 devoxx closures 2009 conference JDK7
Speakers:
Mark Reinhold
Mark Reinhold is Chief Architect of the Java Platform Group at Oracle, where he works on the Java Platform, Standard Edition, and OpenJDK. His past contributions to the platform include character-stream readers and writers, reference objects, shutdown hooks, the NIO high-performance I/O APIs, library generification, and service loaders. Mark was the lead engineer for the 1.2 and 5.0 releases and the specification lead for Java SE 6. He is currently leading the Jigsaw and JDK 7 Projects in the OpenJDK Community. Mark holds a Ph.D. in Computer Science from the Massachusetts Institute of Technology.
PDF: slides.pdf
Slides:
JDK 7 & Java SE 7
JDK 7 & Java SE 7
Mark Reinhold
Principal Engineer Sun Microsystems
http://blogs.sun.com/mr
2009/11/18 — Devoxx 2009
7
7
Modular Multi-Lingual Productive Performant
2
JDK Java
JDK Java
1
Image
http://www.flickr.com/photos/viagallery/2290654438
5
6
6
Image
http://www.flickr.com/photos/ragesoss/2286167023
7
javax.tools javax.lang
javax.tools javax.lang
java.dyn
javax.annotation
java.lang
javax.script
java.math
javax.management
java.nio
javax.sound
MODULARIZE THE java.rmi java.awt JAVA PLATFORM javax.swing java.net … AND APPLICATIONS TOO. java.security
javax.net javax.imageio javax.print
java.beans
java.applet
java.text
javax.xml org.xml
?
org.w3c
java.io
javax.rmi
javax.crypto
javax.activation
javax.security org.ietf
java.util
javax.jws
javax.naming
javax.sql
org.omg
javax.accessibility
java.sql
javax.activity
javax.transaction
8
Project Jigsaw
Project Jigsaw
openjdk.java.net/projects/jigsaw
A simple, low-level module system Integrated with the language and VM Applied to the JDK Interoperable with OSGi
http://www.flickr.com/photos/lizadaly/2944362379
1
Project Jigsaw
Project Jigsaw
openjdk.java.net/projects/jigsaw
JSR 294: Improved Modularity Support in the Java Programming Language
http://www.flickr.com/photos/lizadaly/2944362379
1
The Modular Java Platform
The Modular Java Platform
jdk
tools
java
desktop swing sound awt
corba jaxws jaxp
base
10
Code
$ java -cp $APPHOME/lib/ jdom-1.0.jar\ :$APPHOME/lib/jaxen-1.0 .jar\ :$APPHOME/lib/saxpath-1.0 .jar\ :$APPHOME/lib/rome-1.0.jar\ :$APPHOME/lib/rome-fetcher-1.0 .jar\ :$APPHOME/lib/joda-time-1.6 .jar\ :$APPHOME/lib/tagsoup-1.2 .jar\
1
Code
$ java org.planetjdk.aggregator.Main
1
Code
$ java -cp $APPHOME/lib/ jdom-1.0.jar\ :$APPHOME/lib/jaxen-1.0 .jar\ :$APPHOME/lib/saxpath-1.0 .jar\ :$APPHOME/lib/rome-1.0.jar\ :$APPHOME/lib/rome-fetcher-1.0 .jar\ :$APPHOME/lib/joda-time-1.6 .jar\ :$APPHOME/lib/tagsoup-1.2 .jar\
1
Image
org.planetjdk.aggregator joda-time-1.6 jdom-1.0 jaxen-1.0 saxpath-1.0 tagsoup-1.2 rome-fetcher-1.0 rome-1.0 jaxp-7 java-7 base-7
12
Code
// module-info.java module org.planetjdk.aggregator @ 1.0 { requires jdom @ 1.0; requires tagsoup @ 1.2; requires rome @ 1.0; requires rome-fetcher @ 1.0; requires joda-time @ 1.6; requires jaxp @ 7; requires base @ 7; class org.openjdk.aggregator.Main; }
1
Code
// module-info.java module org.planetjdk.aggregator @ 1.0 { requires jdom @ 1.0; requires tagsoup @ 1.2; requires rome @ 1.0; requires rome-fetcher @ 1.0; requires joda-time @ 1.6; requires jaxp @ 7; org.planetjdk.aggregator-1.0.deb requires base @ 7; class org.openjdk.aggregator.Main; }
org.planetjdk.aggregator-1.0.rpm
pkg://org.planetjdk.aggregator@0.5.11,1.0:20090602T201234Z
13
Image
http://www.flickr.com/photos/thatguyfromcchs08/2300190277
14
Project Jigsaw
Project Jigsaw
openjdk.java.net/projects/jigsaw
The Modular Java Platform & Project Jigsaw
Thursday 17:50, Room 8 The Modular Java Platform & Project Jigsaw BOF
Thursday 20:00, Room 1
15
7
7
Modular Multi-Lingual Productive Performant
16
Languages on the VM
Languages on the VM
Bex Script CAL Zigzag Drools Rexx G Tiger Icon Tcl Logo WebL Luck foo FScript Funnel
Scala
JudoScript
Lisp
Forth
JRuby
C#
Pascal Sather Tea Ada Dawn Mini
v-language
BeanShell
JavaFX Script
Groovy
LLP Basic
JavaScript
Processing E Yoix
Oberon
TermWare iScript SALSA Hojo
Smalltalk
JHCR
Jython
Prolog Phobos Pnuts Sleep
PHP
Simkin Eiffel Scheme JESS Correlate Modula-2 ObjectScript Anvil Jickle
Clojure
Piccola
Yassl
PLAN Nice Present
17
18
18
The Da Vinci Machine
The Da Vinci Machine
openjdk.java.net/projects/mlvm
JSR 292: Supporting Dynamically-Typed Languages on the Java™ Platform (InvokeDynamic)
1
The Da Vinci Machine
The Da Vinci Machine
openjdk.java.net/projects/mlvm
Toward a Universal Virtual Machine
Brian Goetz & Alex Buckley Thursday 10:30, Room 8
1
7
7
Modular Multi-Lingual Productive Performant
20
Code
List list = ...; for (Iterator i = c.iterator(); i.hasNext();) { String s = i.next(); ... }
1
Code
List list = ...; for ( String s : c ) { ... }
2
Project Coin (JSR TBD)
Project Coin (JSR TBD)
openjdk.java.net/projects/coin
Small language changes to simplify everyday tasks
http://www.flickr.com/photos/chefranden/908539119/
22
Code
Map > map = new HashMap<>();
1
Code
long cc = 4388449999352988L; 4388_4499_9935_2988L; long pn = 16505554963L; 1_650_555_4963L; long zc = 943036639; 94303_6639; int x = 33825; 0x8421; 0b1000010000100001; 0b1000_0100_0010_0001;
Code
List tmp = Arrays.asList(3, 1, 4, 1, 5, 9, 5, 2, 6, 5, 3, 5); List piDigits = Collections.unmodifiableList(tmp) = [ 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9 ]; Set somePrimes = { 2, 7, 31, 127, 8191, 131071, 524287 }; Set honestPoliticians = { };
Code
Map platonicSolids; static { Map tmp = new LinkedHashMap<>(); tmp.put(4, "tetrahedron"); tmp.put(6, "cube"); tmp.put(8, "octahedron"); tmp.put(12, "dodecahedron"); platonicSolids = Collections.immutableMap(tmp); } = { 4 : "tetrahedron", 6 : "cube", 8 : "octahedron", 12 : "dodecahedron" };
Code
List ls = [ "foo", "bar", "baz", "quux", "huh?" ]; String baz = ls.get(2); = ls[2]; ls.set(4, "rpg"); ls[4] = "rpg";
27
Code
Map platonicSolids = { 4 : "tetrahedron", 6 : "cube", 8 : "octahedron", 12 : "dodecahedron" }; String octo = platonicSolids.get(8); = platonicSolids[8]; platonicSolids[20] = "icosahedron"; String six = platonicSolids.get(piDigits.get(7)); = platonicSolids[piDigits[7]];
28
Code
static void copy(File src, File dst) throws IOException { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dst); try { byte[] buf = new byte[BUFSIZ]; int n; while ((n = in.read(buf)) >= 0) out.write(buf, 0, n); } finally { in.close(); out.close(); } }
✘
29
Code
static void copy(File src, File dst) throws IOException { InputStream in = new FileInputStream(src); try { OutputStream out = new FileOutputStream(dst); try { byte[] buf = new byte[BUFSIZ]; int n; while ((n = in.read(buf)) >= 0) out.write(buf, 0, n); } finally { out.close(); } } finally { in.close(); } }
30
Code
static void copy(File src, File dst) throws IOException { try (InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dst)) { byte[] buf = new byte[8192]; int n; while ((n = in.read(buf)) >= 0) out.write(buf, 0, n); } }
31
Project Coin (JSR TBD)
Project Coin (JSR TBD)
openjdk.java.net/projects/coin
Project Coin — Joe Darcy
TODAY 17:50, Room 8
http://www.flickr.com/photos/chefranden/908539119/
32
7
7
Modular Multi-Lingual Productive Performant
33
Stats
10,000000 1,000,000 100,000 10,000 1,000 100 10 1
Transistors (1,000s)
Clock (MHz)
1970 1975 1980 1985 1990 1995 2000 2005 2010
34
Niagara 1 (2005)
Niagara 1 (2005)
8 x 4 = 32
Niagara 2 (2007)
8 x 8 = 64
Rainbow Falls
16 x 16 = 256
35
Code
class MaxFinder { final int[] data; final int start, end; MaxFinder(int[] d, int s, int e) { data = d; start = s; end = e; } MaxFinder(int[] d) { this(d, 0, d.length); }
1
Code
class MaxFinder { final int[] data; final int start, end; int find() { int max = Integer.MIN_VALUE; for (int i = start; i < end; i++) max = Math.max(max, data[i]); return max; } MaxFinder subFinder(int s, int e) { return new MaxFinder(data, start + s, start + e); }
2
Code
class MaxTask extends RecursiveAction { final MaxFinder maxf; int ans; MaxTask(MaxFinder mf) { maxf = mf; }
3
Code
class MaxTask extends RecursiveAction { protected void compute() { int n = maxf.end - maxf.start; if (n < THRESHOLD) { ans = maxf.find(); } else { int m = n / 2; MaxTask left = new MaxTask(maxf.subFinder(0, m)); MaxTask right = new MaxTask(maxf.subFinder(m, n)); invokeAll(left, right); ans = Math.max(left.ans, right.ans); } }
4
Code
class MaxFinder { int find() { ... } MaxFinder subFinder(int s, int e) { return new MaxFinder(data, start + s, start + e); } int parallelFind() { MaxFinderTask mft = new MaxFinderTask(this); ForkJoinPool pool = new ForkJoinPool(); pool.invoke(mft); return mft.result; }
38
Code
class MaxTask extends RecursiveAction { protected void compute() { int n = maxf.end - maxf.start; if (n < THRESHOLD) { // ??? ans = maxf.find(); } else { int m = n / 2; MaxTask left = new MaxTask(maxf.subFinder(0, m)); MaxTask right = new MaxTask(maxf.subFinder(m, n)); invokeAll(left, right); ans = Math.max(left.ans, right.ans); } }
39
Code
ForkJoinPool pool = new ForkJoinPool(); ParallelIntArray pa = ParallelIntArray.create(data, pool); return pa.max();
40
Code
ParallelIntArray ParallelLongArray ParallelFloatArray ParallelDoubleArray ParallelArray
filter map reduce
41
Code
class Student { String name; int graduationYear; double gpa; } Student[] data = ...; ForkJoinPool pool = new ForkJoinPool(); ParallelArray pa = new ParallelArray.create(data, pool); double highestGPA = pa.withFilter(graduatesThisYear) .withMapping(selectGpa) .max(); // ??? // ???
42
Code
Ops.Predicate graduatesThisYear = new Ops.Predicate() { public boolean op(Student s) { return s.graduationYear == 2008; } }; Ops.ObjectToDouble selectGpa = new Ops.ObjectToDouble() { public double op(Student student) { return student.gpa; } };
43
?
N I T O 7 N K D J
44
THE CALCULI OF LAMBDA-CONVERSION
THE CALCULI OF LAMBDA-CONVERSION
ALONZO CHURCH
45
Simple Closures
Simple Closures
Itʼs time to add them to Java.
46
Code
// Function literals #()(42) #(int x)(x + x) #(int x, int y)(x * y)
#(int x, int y) { int z = expensive(x, y); if (z > 0) return x; if (z < 0) return y; return 0; }
47
Code
double highestGPA = pa.withFilter(graduatesThisYear) .withMapping(selectGpa) .max();
double highestGPA = pa.filter(#(Student s)(s.graduationYear == THIS_YEAR)) .map(#(Student s)(s.gpa)) .max();
3
Code
// Function literals #()(42) #(int x)(x + x) #(int x, int y)(x * y) // Function types #int() fortyTwo = #()(42); #int(int) doubler = #(int x)(x + x); #int(int, int) multiplier = #(int x, int y)(x * y);
4
Code
// Function types #int() fortyTwo = #()(42); #int(int) doubler = #(int x)(x + x); #int(int, int) multiplier = #(int x, int y)(x * y); assert fortyTwo() == 42; assert doubler(fortyTwo()) == 84; assert multiplier(3, 42) == 126;
5
Code
// What about collections? interface Set { public void add(T ob); public void remove(Object ob); ... } public Set map(#S(T) func); import java.util.Set; import java.util.MappableSet extends java.util.Set;
✗ ✗
6
Set doubleSet(Set s) { return s.map(#(int x)(x + x)); }
The closures design space
The closures design space
Function literals Function types Extension methods
✓
Non-local control transfer Capture of non-final variables Library-defined control structures
51
✗
JDK 7
JDK 7
http://openjdk.java.net/projects/jdk7
Java SE 7
http://jcp.org /en/jsr/detail?id=TBD
52
Image
http://www.flickr.com/photos/kozloski/2306510520
53
When?
When?
54
Milestone 1
Milestones
Milestone 3
Milestone 4
Milestone 5
Milestone 6
Milestone 7
Milestone 1
Milestone 2
Milestone 3
Milestone 4
Milestone 5
Milestone 6
Milestone 7
2009/02/19 2009/04/02 2009/05/14
JavaOne Preview 2009/07/23 2009/11/12 2009/12/24 2010/02/18
1
Mielstones
☞
Milestone 1
Milestone 2
Milestone 3
Milestone 4
Milestone 5
Milestone 6
Milestone 7
2009/02/19 2009/04/02 2009/05/14
JavaOne Preview 2009/07/23 2009/11/12
Feature Complete 2009/12/24 2010/02/18
2
Milestones
☞
Milestone 1
Milestone 2
Milestone 3
Milestone 4
Milestone 5
Milestone 6
Milestone 7
2009/02/19 2009/04/02 2009/05/14
JavaOne Preview 2009/07/23 2009/11/12
Feature Complete 2009/12/24 2010/02/18
Release Candidate
3
Milestones
☞
Milestone 1
Milestone 2
Milestone 3
Milestone 4
Milestone 5
Milestone 6
Milestone 7 Milestone 8
Milestone 9
Milestone 10
2009/02/19 2009/04/02 2009/05/14
JavaOne Preview 2009/07/23 2009/11/12 2010/02/18 2010/04/15 2010/06/03
Feature Complete 2010/07/22 2010/09/09
4
G1 Garbage Collector
G1 Garbage Collector
Project Jigsaw + JSR 294
Scalar Replacement Concurrency & TimSort collections updates Dual-Pivot Quicksort Sockets-Direct Protocol
Elliptic-Curve Cryptography Stream-Control Transmission Protocol Compressed Pointers XRender 2D Pipeline
InvokeDynamic (JSR 292)
More New I/O APIs (JSR 203) Swing JLayer Parallel class loaders
Project Coin (JSR TBD)
Unicode 5.1
Swing Nimbus Look-and-Feel
Fork/Join + Closures
Type Annotations (JSR 308)
56
Available today!
Available today!
openjdk.java.net/projects/jdk7 download.java.net/jdk7/m5
57
Questions?
The Concurrency Revolution — Brian Goetz
TODAY 14:00, Room 4 TODAY 17:50, Room 8 TONIGHT 20:00, Room 2
Project Coin — Joe Darcy JDK 7 & Java SE 7 BOF Toward a Universal VM — Brian Goetz & Alex Buckley
Thursday 10:30, Room 8 Thursday 17:50, Room 8
The Modular Java Platform & Project Jigsaw
Questions?
58