Parleys.com Search Index

Home | Devoxx | Devoxx'09
Title: JDK7 Update and Java SE 7

Summary:
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.

Description:
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.

Speaker(s): Mark Reinhold

Keyword(s): Java JDK7 javase7 devoxx 2009 conference closures

Slide Content:
1) JDK 7 & Java SE 7 Mark Reinhold Principal Engineer Sun Microsystems http://blogs.sun.com/mr 2009/11/18 — Devoxx 2009
2) 7 Modular Multi-Lingual Productive Performant 2
3) JDK Java 1
4) http://www.flickr.com/photos/viagallery/2290654438 5
5) 6
6) http://www.flickr.com/photos/ragesoss/2286167023 7
7) 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
8) 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
9) 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
10) The Modular Java Platform jdk tools java desktop swing sound awt corba jaxws jaxp base 10
11) $ 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
12) $ java org.planetjdk.aggregator.Main 1
13) $ 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
14) 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
15) // 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
16) // 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
17) http://www.flickr.com/photos/thatguyfromcchs08/2300190277 14
18) 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
19) 7 Modular Multi-Lingual Productive Performant 16
20) 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
21) 18
22) The Da Vinci Machine openjdk.java.net/projects/mlvm JSR 292: Supporting Dynamically-Typed Languages on the Java™ Platform (InvokeDynamic) 1
23) The Da Vinci Machine openjdk.java.net/projects/mlvm Toward a Universal Virtual Machine Brian Goetz & Alex Buckley Thursday 10:30, Room 8 1
24) 7 Modular Multi-Lingual Productive Performant 20
25) List list = ...; for (Iterator i = c.iterator(); i.hasNext();) { String s = i.next(); ... } 1
26) List list = ...; for ( String s : c ) { ... } 2
27) Project Coin (JSR TBD) openjdk.java.net/projects/coin Small language changes to simplify everyday tasks http://www.flickr.com/photos/chefranden/908539119/ 22
28) Map > map = new HashMap<>(); 1
29) 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;
30) 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 = { };
31) 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" };
32) List ls = [ "foo", "bar", "baz", "quux", "huh?" ]; String baz = ls.get(2); = ls[2]; ls.set(4, "rpg"); ls[4] = "rpg"; 27
33) 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
34) 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
35) 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
36) 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
37) 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
38) 7 Modular Multi-Lingual Productive Performant 33
39) 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
40) Niagara 1 (2005) 8 x 4 = 32 Niagara 2 (2007) 8 x 8 = 64 Rainbow Falls 16 x 16 = 256 35
41) 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
42) 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
43) class MaxTask extends RecursiveAction { final MaxFinder maxf; int ans; MaxTask(MaxFinder mf) { maxf = mf; } 3
44) 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
45) 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
46) 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
47) ForkJoinPool pool = new ForkJoinPool(); ParallelIntArray pa = ParallelIntArray.create(data, pool); return pa.max(); 40
48) ParallelIntArray ParallelLongArray ParallelFloatArray ParallelDoubleArray ParallelArray filter map reduce 41
49) 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
50) 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
51) N I T O 7 N K D J 44
52) THE CALCULI OF LAMBDA-CONVERSION ALONZO CHURCH 45
53) Simple Closures Itʼs time to add them to Java. 46
54) // 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
55) 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
56) // 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
57) // 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
58) // 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)); }
59) The closures design space Function literals Function types Extension methods ✓ Non-local control transfer Capture of non-final variables Library-defined control structures 51 ✗
60) JDK 7 http://openjdk.java.net/projects/jdk7 Java SE 7 http://jcp.org /en/jsr/detail?id=TBD 52
61) http://www.flickr.com/photos/kozloski/2306510520 53
62) When? 54
63) 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
64) ☞ 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
65) ☞ 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
66) ☞ 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
67) 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
68) Available today! openjdk.java.net/projects/jdk7 download.java.net/jdk7/m5 57
69) 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
(c) Parleys.com NV, 2006-2010 - Technical Info