KEMBAR78
wtf is in Java/JDK/wtf7? | PDF
wtf
 is in Java/JDK/wtf 7      ???


                        Scott Leberknight
"Making Java suck (a little) less..."
jsr-203
(NIO.2)
// old way (deprecated)
File file = new File("foo.txt");




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


Path path = file.toPath();



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




FileSystem(s)


FileStore
scalable, asynchronous I/O
                      (AsynchronousChannel & friends)




socket-channel binding
& config
(NetworkChannel & friends)
jsr-292
(invokedynamic)
invokedynamic
invokestatic                    invokespecial

invokevirtual                   invokeinterface

invokedynamic (new)



       "...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
                                             (automatic
                                               resource
                                           management)


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

    // use resources...

}




                (AutoCloseable)
diamond operator



Map<String, Map<Integer, List<String>>> things =
  new HashMap<>();
modified JSRs
Java 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)
honorable mention
java.util.Objects
                          jsr166y - Concurrency &
                          collections updates

Enhanced JMX agent and
MBeans
                          Autoloading of JDBC
                          drivers

Method to close a
URLClassLoader
                          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)
deferred
    until JDK 8
   (sometime next century)
Project Lambda

       re d
      r
                                    (a.k.a. closures)




de fe       Collection Literals
         List<Integer> items = [1, 2,    3, 4, 5];




                                Modularity
          (JSR 294 modules, formerly superpackages)
references
http://jdk7.java.net/

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

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

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

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

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

http://marxsoftware.blogspot.com/2011/03/jdk-7-new-interfaces-
classes-enums-and.html
(the end)
scott.leberknight@nearinfinity.com
www.nearinfinity.com/blogs/
twitter: sleberknight

wtf is in Java/JDK/wtf7?