Java SE 7、そしてJava SE 8

  • 1,810 views
Uploaded on

2012/05/26 JavaQne(じゃばきゅん) Fukuoka 2012 発表資料 …

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,810
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
13
Comments
0
Likes
10

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Java SE 7,そして Java SE 8 Java in the Box 櫻庭 祐一
  • 2. Agenda History Java SE 7 Java SE 8 Conclusion
  • 3. History
  • 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. 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. 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. Project Coin switch 文で文字列 2 進数と区切り文字 例外の multi catch と safe rethrow ジェネリクスの省略記法 try-with-resources 簡潔な可変長引数メソッド
  • 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. 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. NIO.2 New Filesystem API 非同期 I/OSocketChannel のマルチキャスト
  • 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. 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. InvokeDynamic 新しいバイトコード invokedynamic 動的型付け言語のメソッドコールbootstrap, MethodHandle, CallSite
  • 14. Fork/Join Framework more cores, more tasks 分割統治法 + Work Stealing
  • 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. 7 Project Coin NIO.2 InvokeDynamicMid 2011 Fork/Join Framework Project Lambda Project Jigsaw 8 Mid 2013
  • 17. 簡単にマルチタスク もちろん細粒度 Internal Iteration +Lambda Expression
  • 18. List<Student> students = ...double highestScore = 0.0;for (Student s: students) { if (s.getGradYear() == 2011) { if (s.getScore() > highestScore) { highestScore = s.getScore(); } }}
  • 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. 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. List<Student> students = ...double highestScore = students.filter(Student s -> s.getGradYear() == 2011) .map(Student s -> s.getScore()) .max(); 赤字の部分がラムダ式
  • 22. List<Student> students = ...double highestScore = students.filter(s -> s.getGradYear() == 2011) .map(s -> s.getScore()) .max(); 引数の型を省略可
  • 23. List<Student> students = ...double highestScore = パラレルに処理 students.parallel() .filter(s -> s.getGradYear() == 2011) .map(s -> s.getScore()) .max();
  • 24. Project Jigsaw Modularity = Grouping + Dependence + Versioning + Encapsulation + Optional modules + Module aliases Packaging = Module files + Libraries + Repositories + Native packages
  • 25. ほかにも ... JavaFX 3.0 Nashorn HotRockit Device Suport Annotation Type Coin 2
  • 26. Beyond Java SE 8 Iteroperability Cloud Ease of Use Advanced Optimization Works Everywhere & with Everything
  • 27. Conclusionいますぐ使える Java SE 7 NIO.2, G1GC Java SE 7u4 java.com で配布あと 1 年で Java SE 8 Lambda, Jigsaw JavaFX, Nashorn
  • 28. Java SE 7, そして Java SE 8 Java in the Box 櫻庭 祐一