Java 7 was released in July 2011 with improvements to performance, concurrency, and memory management. Plans for Java 8 include modularity, lambda expressions, and date/time APIs. The Java Community Process is also being improved to increase transparency, participation, and agility through JSR 348. Overall, the Java ecosystem continues to grow with new languages on the JVM and an active community.
10. History
JDK/YEAR Comment
Feb 1997 Retooling of the AWT event model, inner
JDK 1.1 classes added, JavaBeans and JDBC.
Dec 1998 Reflection, a Collections framework, Java
J2SE 1.2 (Playground) Swing API Java Plug-in, JIT compiler.
May 2000 HotSpot JVM, JavaSound, JNDI and JPDA
J2SE 1.3 (Kestrel)
Feb 2002 RegEx, exception chaining, XML parser and
Java SE 1.4 (Merlin) XSLT (JAXP), Java Web Start
Sep 2004 for-each loop, generics, autoboxing and var-
Java SE 5 (Tiger) args
Dec 2006 scripting languages with the JVM, VB lang
Java SE 6 (Mustang) support. Annotations (JSR 269)
12. Why was 7 delayed
• Open Sourcing JDK
• Conflicts Blocking JCP
• Sun Finance
• JavaFX
• Oracle Deal
13. Trouble in paradise
• James Gosling leaving Oracle
• Oracle vs Google
• Apache leaving JCP
• Doug Lea, Bob Lee leaving JCP
14.
15. Java 7
Plan A,
JDK 7
Late 2012
”It„s been clear for some time that the
most recent JDK 7 development
schedule is, to put it mildly, Unrealistic”
(Mark Reinhold, 8 Sep 2010)
16. Plan B (Mark R)
8 Sep 2010 ”Re-thinking JDK 7”
20 Sep 2010 ”It‟s time for…Plan B”
10 Oct 2010 ”Plan B: The details”
21. G1 Garbage collector
• Still considered experimental
• Leads to much smaller pause times
• Parallelism and Concurrency
• Generational
• Compaction
• Predictability (over CMS)
22. Using G1
• Replace CMS (Concurrent mark sweep) GC
• Enable with:
-XX:+UnlockExperimentalVMOptions –XX:+UseG1GC
• GC Paus time goal:
-XX:MaxGCPauseMillis=50
www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html
23. Benchmarks
• Test 1. Add 5 Million String values (each calculated with
some complex Math arithmetic)
• Test 2. ArrayList <String> with 5 Million insertions (with
values from Test1)
• Test 3. HashMap <String, Integer> with 5 million keys,
values. Each key, value pair is being calculated via
concurrent thread)
• Test 4. Printing 5 million items of ArrayList
http://geeknizer.com/java-7-whats-new-performance-benchmark-1-5-1-6-1-7/
28. JSR 166y Fork/Join
• similar to MapReduce
• useful for a certain class of problems
29. JSR 166y Fork/Join
Result solve(Problem problem) {
if (problem is small enough)
directly solve problem
else {
split problem into independent parts
fork new subtasks to solve each part
join all subtasks
compose result from subresults
}
}
30. JSR 166y Fork/Join
• Create one ForkJoinPool
• Wrap code in ForkJoinTask
• Subclass RecursiveAction or RecursiveTask<E>
• Need to override compute() method
download.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html
31. class Sum extends RecursiveTask<Long> {
static final int SEQUENTIAL_THRESHOLD = 1000;
Sum(int[] arr, int lo, int hi) {
array = arr; low = lo; high = hi;
}
protected Long compute() {
if(high - low <= SEQUENTIAL_THRESHOLD) {
long sum = 0;
for(int i=low; i < high; ++i)
sum += array[i];
return sum;
} else {
int mid = low + (high - low) / 2;
Sum left = new Sum(array, low, mid);
Sum right = new Sum(array, mid, high);
invokeAll(left, right);
return right.join() + left.join();
}
}
}
33. Still too complicated?
mutable state, locks and visible by default is outdated
java.util.concurrent helps, but can only go so far
move from explicit to implicit parallelism
34. Other JVM Languages
(free to innovate)
Scala/Akka
• Powerful actors model
• Parallel Collections
Clojure
• Immutable by default
• Thread-isolation by default
• STM subsystem
• Multiple concurrency models
36. Project Coin
A set of small language changes
should be added to JDK 7
(OpenJDK)
37. Strings in switch
Add the ability to switch on string values
analogous to the existing ability to switch
on values of the primitive types.
38. Strings in switch
String s = ...
switch(s) {
case "quux":
processQuux(s);
// fall-through
case "bar":
processFooOrBar(s);
break;
case "baz":
processBaz(s);
default:
processDefault(s);
break;
}
39. Improved Exception
Handling
• Catching multiple exception types
• A single catch clause can now catch
more than one exception types
• Improved checking for re-thrown
exceptions
41. Underscore in numbers
public static void main(String... args) {
// THE OLD WAY
int oldBillion = 1000000000;
// THE NEW WAY
int newBillion = 1_000_000_000;
}
42. Automatic Resource Management
• A *resource* is as an object that used to be closed
manually
• java.io.InputStream
• OutputStream
• Reader, Writer
• java.sql.Connection, Statement, ResultSet
• When the statement completes, whether normally or
abruptly, all of its resources are closed automatically.
43. Pre Java 7
public void copy(String src, String dest) throws IOEx{
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest);
try {
byte[] buf = new byte[8 * 1024];
int n;
while ((n = in.read(buf)) >= 0)
out.write(buf, 0, n);
} finally {
in.close();
out.close();
}
}
44. Pre Java 7
public void copy(String src, String dest) throws IOEx{
InputStream in = new FileInputStream(src);
try {
OutputStream out = new FileOutputStream(dest);
try {
byte[] buf = new byte[8 * 1024];
int n;
while ((n = in.read(buf)) >= 0)
out.write(buf, 0, n);
} finally {
out.close();
}
} finally {
in.close();
}
}
45. Automatic Resource Management
public void copy(String src, String dest) throws IOEx{
try ( InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest)){
byte[] buf = new byte[8 * 1024];
int n;
while ((n = in.read(buf)) >= 0)
out.write(buf, 0, n);
}
//in and out closes automagically
}
47. Improved Type Inference for
Generic Instance
Map<String, List<String>> anagrams =
new HashMap<String, List<String>>();
Map<String, List<String>> anagrams =
new HashMap<>();
53. Da Vinci Machine Project
• Support for dynamically typed languages
• Python, Ruby, Perl, Javascript, Groovy...
• Implementations will be more efficient
• JVM level support
• for such languages and their implementers
68. Java 7 Runtimes
• Windows x86
• Server 2008, Server 2008 R2, 7 & 8
• Windows Vista, XP
• Linux x86
• Oracle Linux 5.5+, 6.x
• Red Hat Enterprise Linux 5.5+, 6.x
• SuSE Linux Enterprise Server 10.x, 11.x
• Ubuntu Linux 10.04 LTS, 11.04
• Solaris x86/SPARC
• Solaris 10.9+, 11.x
69. Other runtimes
”The IBM SDK for Java V7 is now available for
the following platforms:” - 20 Sep 2011
• AIX
• Linux
• z/OS
74. Plan B
Modularization (Jigsaw)
Language and VM Support
Platform Modularization
Project Lambda (JSR 335)
Lambda Expressions for Java
Type Annotations (JSR 308)
JDK 8
Project Coin part II
Date and Time API (JSR 310)
JSR 337
75. Plan B++
Project Nashorn
New implementation of JavaScript
Built from the ground up
Leverage JVM and invoke dynamic
Java FX 3.0
Open Sourced
Bundled with Java 8 JDK 8
JSR 337
76. Schedule
May 2011: Expert Group formation
Sep 2011: Early Draft Review
Feb 2012: Public Review
May 2012: Proposed Final Draft
Oct 2012: Final Release JDK 8
JSR 337
77. Schedule
May 2011: Expert Group formation
Sep 2011: Early Draft Review
Feb 2012: Public Review
May 2012: Proposed Final Draft
Summer 2013: Final Release JDK 8
JSR 337
79. JCP.next
• Using the process to improve the process
• JSR 348
• Transparency
• Participation
• Agility
• Governance
• A second JSR will be filed soon
• JavaSE and JavaME EC - merged
81. We‟re moving again
• The JCP Dead Lock Needed to be Broken
• OpenJDK is liberated (GPL)
• JUG attendances are growing
• Oracle marketing estimates 9-10 million devs
• Dozens of new JVM languages
• A Vibrant Java Ecosystem