wtf is in Java/JDK/wtf7?

Post on 27-May-2015

3.152 views 4 download

Tags:

description

Slides for a short lightning talk I gave at Near Infinity (www.nearinfinity.com) on what exactly is in JDK7.

Transcript of wtf is in Java/JDK/wtf7?

wtfis in Java/JDK/wtf ???7

Scott Leberknight

"Making Java suck (a little) less..."

jsr-203(NIO.2)

java.nio.file

// old way (deprecated)File file = new File("foo.txt");

// new wayPath path = Paths.get("foo.txt");

Path path = file.toPath();

FileStore

FileSystem(s)

Files(finally, you can copy a file...only took ~15 years)

scalable, asynchronous I/O

socket-channel binding & config

(AsynchronousChannel & friends)

(NetworkChannel & friends)

jsr-292(invokedynamic)

invokestatic invokespecial

invokevirtual invokeinterface

invokedynamic (new)

invokedynamic

"...an invokedynamic instruction is used to call methods which have linkage and dispatch

semantics defined by non-Java languages..."- http://www.infoq.com/articles/invokedynamic

jsr-334(Project Coin)

strings in switch

switch (action) { case "Red": stop(); break; case "Yellow": slowDown(); break; case "Green": go(); break; case "Blue": danceAJig(); break;}

binary literals

int clutchSong = 0b10001110101;

http://www.amazon.com/Robot-Hive-Exodus-Clutch/dp/B0009NSE1K

short/byte literals

byte b = 42y;

short s = 32767s;

underscores in numeric literals

long max = 9_223_372_036_854_775_807L;

int song = 0b0100_0111_0101;

multi-catch

try { // code...}catch (FileNotFoundException | NoSuchFileException | AccessDeniedException ex) { // handle...}

final re-throw

try { actionThatThrowsIOException(); actionThatThrowsSQLException();}catch (final Exception e) { // handle...

throw e; // IOException or SQLException}

ARM

try (InputStream is = url.openStream(); OutputStream os = new FileOutputStream(file)) {

// use resources...

}

(automatic resource

management)

(AutoCloseable)

diamond operator

Map<String, Map<Integer, List<String>>> things = new HashMap<>();

modified JSRsJava Compiler API (jsr 199)

JAXP 1.3 (jsr 206)

JAXB 2.2 (jsr 222)

JAX-WS 2.2 (jsr 224)

Pluggable Annotation Processing (jsr 269)

java.util.Objects

Enhanced JMX agent and MBeans

honorable mention

jsr166y - Concurrency & collections updates

Method to close a URLClassLoader

Autoloading of JDBC drivers

JDBC 4.1

assembly-coding

Class Loader architecture updates (parallel-capable)

Strict class file checking

Elliptic curve cryptography (ECC)

New garbage collector (lower pause times & better predictability than current CMS collector)

deferreduntil JDK 8

(sometime next century)

Project Lambda(a.k.a. closures)

Collection LiteralsList<Integer> items = [1, 2, 3, 4, 5];

Modularity(JSR 294 modules, formerly superpackages)

deferred

http://jdk7.java.net/

http://jdk7.java.net/preview/

http://download.java.net/jdk7/docs/api/

http://www.vineetmanohar.com/2011/03/installing-java-7-on-mac-os-x/

http://www.infoq.com/articles/invokedynamic

http://openjdk.java.net/projects/jdk7/features/

http://marxsoftware.blogspot.com/2011/03/jdk-7-new-interfaces-classes-enums-and.html

references

(the end)

scott.leberknight@nearinfinity.com

www.nearinfinity.com/blogs/

twitter: sleberknight