7. A / B 計畫
• JDK 7 Features updated ! Plan B has
apparently been approved
– http://www.baptiste-wicht.com/2010/09/jdk-7-
features-updated-plan-b-is-apparently-here/
8. JDK7 ...
λ Jigsaw
Language support for collections
Annotations on Java types
11. Small language enhancements
• Strings in switch
• Binary integral literals and underscores in
numeric literals
• Multi-catch and more precise rethrow
• Improved Type Inference for Generic
Instance Creation (diamond)
• try-with-resources statement
• Simplified Varargs Method Invocation
17. Multi-catch
• It is a compile-time error if a disjunctive
type contains two alternatives Di, Dj where
Di is a subtype of Dj.
18. Multi-catch
• An exception parameter whose type is a
disjunctive type is implicitly considered to
be final.
try { /* throws some ReflectiveOperationException */ }
catch (final ClassNotFoundException ex1) { /* body */ }
catch (final IllegalAccessException ex2) { /* body */ }
37. Simplified Varargs Method
Invocation
• JDK7...
提醒設計 doSome() 保證不會發生 Heap Pollution
....: warning: [unchecked] Possible heap pollution from parameterized var
arg type T
public static <T> List<T> doSome(T... t) {
^
where T is a type-variable:
T extends Object declared in method <T>doSome(T...)
1 warning
48. NIO2
NIO
• File System API
• Channels API
– Updates to socket channel API
– Asynchronous I/O
• java.nio
– Buffer
– Channel
– Selector
– Charset
49. File System API
• java.io.File 怎麼了?
– Not initially written to be extended
– Many of the methods without exceptions
– Methods behaved inconsistently across volumes and
file systems
– Methods for gaining simultaneous metadata about
files were inefficient
– Developers also requested the ability to develop their
own file system implementations, for examples, zip
files
– ...
50. File System API
• 新套件
– java.nio.file
– java.nio.file.attribute
• Java Tutorials: File I/O (Featuring NIO.2)
– http://download.oracle.com/javase/tutorial/essential/io
/fileio.html
51. 關於 Path
• Methods to access components
• Methods to test and compare
• Methods to combine paths
• File operations
• All methods that access file system throw
IOException
• No other checked exceptions in API
101. JSR 292
• Java Virtual Machine Support for Non-
Java Languages
– http://download.java.net/jdk7/docs/technotes/
guides/vm/multiple-language-support.html
102. JSR 292
• If a programming language was a
boat…
– http://compsci.ca/blog/if-a-programming-
language-was-a-boat/
103. 感謝 Orz...
● 林信良
● caterpillar@openhome.cc
● http://openhome.cc
Recently rediscovered diagrams prove
Leonardo invented the first JVM?
. http://openjdk.java.net/projects/mlvm/