Java 7 And Beyond

{{jfunreport
 * title = Java 7 And Beyond
 * convenor = Ben Evans and Marc Hoffmann
 * participants = ...
 * summary =

Java 7: New Features
Ben gives a overview of new featured in Java 7:


 * 1) Try-With Resources
 * 2) Invoke Dynamic
 * 3) Strings in Switch
 * 4) Tiered Compilation
 * 5) Binary Literals + underscores, [Multiline Strings]
 * 6) Multi-Catch
 * 7) G1 GC
 * 8) NIO.2
 * 9) (SAMs)
 * 10) Diamond Operator
 * 11) Unicode 5.1
 * 12) Performance!

Feature Categories
These enhancements happen on different levels and can be categories as follows:


 * Lib: 8
 * Synthatic Sugar: 3, 5, 6, 10
 * Classfile Change: 2
 * VM Change: 2
 * Bytecode Change: 2

Notes and examples on the new features
Binary Literals and Underscores: Multiline Strings were intended but too hard to get a consensus on how they should work/rules/etc

Diamond Operator
A Map hm = new HashMap<>; A Map> hm = new HashMap<>; // same thing Also infers a methodCall(new ArrayList<>);

MultiCatch
try { ...         } catch (IOException | FileNotFound | SomethingException e) { // what is e?              // its a disjoint union of types - the compiler works it out. From our perspective its the common super type }

Try-with-exceptions
try (FileOutputStream for = ….; InputStream is = …) { fos.write; } finally { println("All done"); }

Invoke Dynamic
Marc explained a small example, how Java bytecode with an invokedynamic instruction can be created using the ASM library. As the invokedynamic instruction has been created for new script language, the normal Java compiler will not emit such instructions. The example is available for download.

Flip Charts
}}
 * recommendations = ...