明日から使える
                  Java SE 7

Java in the Box
 櫻庭 祐一
祝
7/28
JavaSE7
リリース
ほんとは

2008 年
リリース
 予定
だったけど
なぜ遅れた
          Project Lambda
       機能 Project Jigsaw
 買収

           移行 JDK OpenJDK

 JavaFX?
Java SE 7 Themes

  Compatibility
  Productivity    Project Coin
  Performance     G1GC JSR166y
  Universality    InvokeDynamic
  Integration     NIO2
Try-with-resources
Multi Catch/Precise Rethrow




+1
NIO2

Upgrade ClassLoader
try-with-resources




           +1
 try (InputStream in = new FileInputStream(src);
      OutputStream out = new FileOutputStream(dest)) {

     byte[] buf = new byte[1024];
     int n;
     while((n = in.read(buf)) >= 0) {
         out.write(buf, 0, n);
     }
 } catch (IOException ex) {
     // 例外処理
 }
Multi Catch/Precise Rethrow




            +1
   try {
       DocumentBuilderFactory factory
           = DocumentBuilderFactory.newInstance();
       DocumentBuilder builder
           = factory.newDocumentBuilder();
       Document doc = builder.parse(stream);

       // パース

   } catch (final    IOException
                 |   IllegalArgumentException
                 |   ParserConfigurationException
                 |   SAXException ex) {
       log(ex);
       throw ex;
   }
NIO2       FileVisitor を使ったファイルの検索




               +1
Path start = ...;
String regex = ...;

Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
    public FileVisitResult visitFile(Path path,
             BasicFileAttributes attrs) throws IOException {
        if (Pattern.matches(regex,
                            path.getFileName().toString()) {
            System.out.println("File: " + path);
        }
        return FileVisitResult.CONTINUE;
    }
});
+0.5
 Diamond Operator   <>
 数値リテラル
javafx.scene.control.Button button = new Button("OK");




    +0.5
EventHandler<ActionEvent> handler = new EventHandler<>() {
    public void handle(ActionEvent t) {
        // イベント処理
    }
};
button.setOnAction(handler);


button.setOnAction(new EventHandler<>() {
    public void handle(ActionEvent t) {
        // イベント処理
    }
});
道半ば
JSR166y Fork/Join Framework
JSR292 InvokeDynamic

             JSR335 Project Lambda

   実戦投入一歩手前
Garbage First Garbage Collection (G1GC)
微妙 ...
   String Switch
     JDBC 4.1
        MXBean 拡張
     Nimbus L&F

プラットフォーム依存
   SCTP/SDP
  Unicode 6.0
なぜなくなった !!
   XML リテラル
                   JSR255 JMX 2.0
 JSR296 Beans Binding

               JSR303 Bean Validation
JSR274 BeanShell Script Language
                    JSR260 Javadoc
なぜなくなった !!
   XML リテラル
                   JSR255 JMX 2.0
 JSR296 Beans Binding

               JSR303 Bean Validation
JSR274 BeanShell Script Language
コードネーム
     もなくなった
                    JSR260 Javadoc
Conclusion
    全体的に小粒のアップデート
      Java SE 8 につながる技術に注目

 ファイルを扱うなら NIO2!!

       いきなり Java SE 8 はつらいよ

 参考
    ITpro Java SE 7 徹底理解
明日から使える
                  Java SE 7


Java in the Box
   櫻庭 祐一

明日から使える Java SE 7

  • 1.
    明日から使える Java SE 7 Java in the Box 櫻庭 祐一
  • 2.
  • 3.
  • 4.
    なぜ遅れた Project Lambda 機能 Project Jigsaw 買収 移行 JDK OpenJDK JavaFX?
  • 5.
    Java SE 7Themes Compatibility Productivity Project Coin Performance G1GC JSR166y Universality InvokeDynamic Integration NIO2
  • 6.
  • 7.
    try-with-resources +1 try (InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dest)) { byte[] buf = new byte[1024]; int n; while((n = in.read(buf)) >= 0) { out.write(buf, 0, n); } } catch (IOException ex) { // 例外処理 }
  • 8.
    Multi Catch/Precise Rethrow +1 try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(stream); // パース } catch (final IOException | IllegalArgumentException | ParserConfigurationException | SAXException ex) { log(ex); throw ex; }
  • 9.
    NIO2 FileVisitor を使ったファイルの検索 +1 Path start = ...; String regex = ...; Files.walkFileTree(start, new SimpleFileVisitor<Path>() { public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { if (Pattern.matches(regex, path.getFileName().toString()) { System.out.println("File: " + path); } return FileVisitResult.CONTINUE; } });
  • 10.
    +0.5 Diamond Operator <> 数値リテラル
  • 11.
    javafx.scene.control.Button button =new Button("OK"); +0.5 EventHandler<ActionEvent> handler = new EventHandler<>() { public void handle(ActionEvent t) { // イベント処理 } }; button.setOnAction(handler); button.setOnAction(new EventHandler<>() { public void handle(ActionEvent t) { // イベント処理 } });
  • 12.
    道半ば JSR166y Fork/Join Framework JSR292InvokeDynamic JSR335 Project Lambda 実戦投入一歩手前 Garbage First Garbage Collection (G1GC)
  • 13.
    微妙 ... String Switch JDBC 4.1 MXBean 拡張 Nimbus L&F プラットフォーム依存 SCTP/SDP Unicode 6.0
  • 14.
    なぜなくなった !! XML リテラル JSR255 JMX 2.0 JSR296 Beans Binding JSR303 Bean Validation JSR274 BeanShell Script Language JSR260 Javadoc
  • 15.
    なぜなくなった !! XML リテラル JSR255 JMX 2.0 JSR296 Beans Binding JSR303 Bean Validation JSR274 BeanShell Script Language コードネーム もなくなった JSR260 Javadoc
  • 16.
    Conclusion 全体的に小粒のアップデート Java SE 8 につながる技術に注目 ファイルを扱うなら NIO2!! いきなり Java SE 8 はつらいよ 参考 ITpro Java SE 7 徹底理解
  • 17.
    明日から使える Java SE 7 Java in the Box 櫻庭 祐一