0
Java SE 7,そして Java SE 8           Java in the Box                 櫻庭 祐一
Agenda      History          Java SE 7          Java SE 8         Conclusion
History
04                         05              06                               07                        08                  ...
7                      Project Coin            plan A    NIO.2                      InvokeDynamic                      For...
7                      Project Coin            plan A    NIO.2                      InvokeDynamic                      For...
Project Coin         switch 文で文字列         2 進数と区切り文字         例外の multi catch                  と safe rethrow         ジェネリク...
Project Coin                            従来の記述InputStream in = null; OutputStream out = null;try {    in = new FileInputStr...
Project Coin                   try-with-resourcestry (InputStream in = new FileInputStream(src);       OutputStream out = ...
NIO.2          New Filesystem API                   非同期 I/OSocketChannel のマルチキャスト
FileSystem fileSystem.getDefault();Path src = fileSystem.getPath(”foo.txt”);Path dest = fileSystem.getPath(”bar.txt”);// フ...
Path startDir = fileSystem.getPath(".");final String regex = "Test.java";// ディレクトリツリーの探索Files.walkFileTree(startDir,      ...
InvokeDynamic      新しいバイトコード       invokedynamic  動的型付け言語のメソッドコールbootstrap, MethodHandle, CallSite
Fork/Join Framework  more cores, more tasks 分割統治法 + Work Stealing
class FibonacciTask extends RecursiveTask<Integer> {    private final Integer n;    FibonacciTask(Integer n) { this.n = n;...
7           Project Coin           NIO.2           InvokeDynamicMid 2011   Fork/Join Framework               Project Lambd...
簡単にマルチタスク     もちろん細粒度 Internal Iteration         +Lambda Expression
List<Student> students = ...double highestScore = 0.0;for (Student s: students) {    if (s.getGradYear() == 2011) {       ...
List<Student> students = ...double highestScore =   students.filter(new Predicate<Student>() {       public boolean op(Stu...
List<Student> students = ...double highestScore =   students.filter(new Predicate<Student>() {       public boolean op(Stu...
List<Student> students = ...double highestScore =   students.filter(Student s -> s.getGradYear()                          ...
List<Student> students = ...double highestScore =   students.filter(s -> s.getGradYear() == 2011)           .map(s -> s.ge...
List<Student> students = ...double highestScore =                          パラレルに処理   students.parallel()           .filter...
Project Jigsaw Modularity = Grouping              + Dependence              + Versioning              + Encapsulation     ...
ほかにも ... JavaFX 3.0   Nashorn     HotRockit     Device Suport     Annotation Type     Coin 2
Beyond Java SE 8 Iteroperability Cloud Ease of Use Advanced Optimization Works Everywhere     & with Everything
Conclusionいますぐ使える Java SE 7 NIO.2, G1GC Java SE 7u4 java.com で配布あと 1 年で Java SE 8 Lambda, Jigsaw JavaFX, Nashorn
Java SE 7, そして Java SE 8      Java in the Box      櫻庭 祐一
Upcoming SlideShare
Loading in...5
×

Java SE 7、そしてJava SE 8

1,967

Published on

2012/05/26 JavaQne(じゃばきゅん) Fukuoka 2012 発表資料
「Java SE 7、そしてJava SE 8」

Published in: Technology

Transcript of "Java SE 7、そしてJava SE 8"

  1. 1. Java SE 7,そして Java SE 8 Java in the Box 櫻庭 祐一
  2. 2. Agenda History Java SE 7 Java SE 8 Conclusion
  3. 3. History
  4. 4. 04 05 06 07 08 09 10 OpenJDK SE6u10 Sun 買収 Plan A 6と7は J2SE5.0 Java SE6General リリース Plan B 一緒に計画 リリース リリース JavaFX 発表 G.Hamiltion M.Reinhold M.Reinhold friend JSR294Superpackage JigsawModularity JAR の拡張 NewPackaging JSR277JAM JSR277Module Closure BGGA Closure Closure LambdaParallel N.Gafter JSR166y NIO2 NIO2 NIO2 NIO2 JSR296SAF JSR296SAF SmallChanges CoinEoD JSR295BeansBinding JSR295BeansBinding JSR303BeanValidation JSR308Annotation JSR308AnnotationMisc JSR121 NewBytecode JSR292 JSR292 JSR292 JSR292 Isolation XML リテラル JSR310DateTime JSR310DateTime BeanShell BeanShell JMX2.0
  5. 5. 7 Project Coin plan A NIO.2 InvokeDynamic Fork/Join Framework Project LambdaMid 2012 Project Jigsaw 7 Project Coin NIO.2 plan B 8 InvokeDynamic Fork/Join FrameworkMid 2011 Project Lambda Project Jigsaw Late 2012
  6. 6. 7 Project Coin plan A NIO.2 InvokeDynamic Fork/Join Framework Project LambdaMid 2012 Project Jigsaw 7 Project Coin NIO.2 plan B 8 InvokeDynamic Fork/Join FrameworkMid 2011 Project Lambda Project Jigsaw Late 2012 Mid 2013
  7. 7. Project Coin switch 文で文字列 2 進数と区切り文字 例外の multi catch と safe rethrow ジェネリクスの省略記法 try-with-resources 簡潔な可変長引数メソッド
  8. 8. Project Coin 従来の記述InputStream in = null; OutputStream out = null;try { in = new FileInputStream(src); out = new FileOutputStream(src); byte[] buf = new byte[1024]; int n; while((n = in.read(buf)) >= 0) out.write(buf, 0, n);} catch (IOException ex) {} finally { try { if (in != null) in.close(); if (out != null) out.close(); } catch (IOException ex) {}}
  9. 9. Project Coin try-with-resourcestry (InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(src)) { byte[] buf = new byte[1024]; int n; while((n = in.read(buf)) >= 0) { out.write(buf, 0, n); } } catch (IOException ex) { System.err.println(ex.getMessage()); }
  10. 10. NIO.2 New Filesystem API 非同期 I/OSocketChannel のマルチキャスト
  11. 11. FileSystem fileSystem.getDefault();Path src = fileSystem.getPath(”foo.txt”);Path dest = fileSystem.getPath(”bar.txt”);// ファイル操作Files.copy(src, dest);Files.move(src, dest);// シンボリックリンクの生成Path target = fileSystem.getPath(...);Path link = fileSystem.getPath(...);Files.createSymbolicLink(link, target);
  12. 12. Path startDir = fileSystem.getPath(".");final String regex = "Test.java";// ディレクトリツリーの探索Files.walkFileTree(startDir, new SimpleFileVisitor<Path>() { public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) { if (Pattern.matches(regex, path.getFileName().toString())) { System.out.println("File: " + path); } return FileVisitResult.CONTINUE; }});
  13. 13. InvokeDynamic 新しいバイトコード invokedynamic 動的型付け言語のメソッドコールbootstrap, MethodHandle, CallSite
  14. 14. Fork/Join Framework more cores, more tasks 分割統治法 + Work Stealing
  15. 15. class FibonacciTask extends RecursiveTask<Integer> { private final Integer n; FibonacciTask(Integer n) { this.n = n; } protected Integer compute() { if (n <= 1) return n; // n-1 に対してフィボナッチ数を求める FibonacciTask f1 = new FibonacciTask(n - 1); f1.fork(); // n-2 に対してフィボナッチ数を求める FibonacciTask f2 = new FibonacciTask(n - 2); // 処理結果を足し合せて、n のフィボナッチ数とする return f2.compute() + f1.join(); }}
  16. 16. 7 Project Coin NIO.2 InvokeDynamicMid 2011 Fork/Join Framework Project Lambda Project Jigsaw 8 Mid 2013
  17. 17. 簡単にマルチタスク もちろん細粒度 Internal Iteration +Lambda Expression
  18. 18. List<Student> students = ...double highestScore = 0.0;for (Student s: students) { if (s.getGradYear() == 2011) { if (s.getScore() > highestScore) { highestScore = s.getScore(); } }}
  19. 19. List<Student> students = ...double highestScore = students.filter(new Predicate<Student>() { public boolean op(Student s) { return s.getGradYear() == 2011; } }).map(new Mapper<Student、Double>() { public Double extract(Student s) { return s.getScore(); } }).max();
  20. 20. List<Student> students = ...double highestScore = students.filter(new Predicate<Student>() { public boolean op(Student s) { return s.getGradYear() == 2011; } }).map(new Mapper<Student、Double>() { public Double extract(Student s) { return s.getScore(); } 青字の部分が冗長 }).max();
  21. 21. List<Student> students = ...double highestScore = students.filter(Student s -> s.getGradYear() == 2011) .map(Student s -> s.getScore()) .max(); 赤字の部分がラムダ式
  22. 22. List<Student> students = ...double highestScore = students.filter(s -> s.getGradYear() == 2011) .map(s -> s.getScore()) .max(); 引数の型を省略可
  23. 23. List<Student> students = ...double highestScore = パラレルに処理 students.parallel() .filter(s -> s.getGradYear() == 2011) .map(s -> s.getScore()) .max();
  24. 24. Project Jigsaw Modularity = Grouping + Dependence + Versioning + Encapsulation + Optional modules + Module aliases Packaging = Module files + Libraries + Repositories + Native packages
  25. 25. ほかにも ... JavaFX 3.0 Nashorn HotRockit Device Suport Annotation Type Coin 2
  26. 26. Beyond Java SE 8 Iteroperability Cloud Ease of Use Advanced Optimization Works Everywhere & with Everything
  27. 27. Conclusionいますぐ使える Java SE 7 NIO.2, G1GC Java SE 7u4 java.com で配布あと 1 年で Java SE 8 Lambda, Jigsaw JavaFX, Nashorn
  28. 28. Java SE 7, そして Java SE 8 Java in the Box 櫻庭 祐一
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×