過去とこれから

Java SE7 Project Coin

Java SE9 Milling Project Coin

@maaya8585

http://slides.com/maaya/coin-milling-coin

Who am i

@maaya8585

  • 職業:クラウドアーキテクト Lv25

  • ステータス

    • Java : 39

    • Python : 28

    • AWS : 43

    • Azure : 37

強くない!!

http://slides.com/maaya/coin-milling-coin

What I want to say is...

ちりも積もれば

山となり

血となり肉となり

みんなに「便利」を届けます。

http://slides.com/maaya/coin-milling-coin

Agenda

  • Java SE 7 Project Coin

  • Java SE 9 Milling Project Coin

  • matome

http://slides.com/maaya/coin-milling-coin

Agenda

  • Java SE 7 Project Coin

  • Java SE 9 Milling Project Coin

  • matome

ところで。

Java SE 7

触ったことある人?

Java SE 8以降しか

触ったことない人は

歴史の勉強している気分で

聴いててね。

  • OpenJDKで仕様が決められた

  • JSR334

    Small Enhancements to the Java Programming Language

  • リード:Joe Darcy

Project Coin

このプロジェクトでは

言語仕様の小さな変更

を決めるぞ!

Origin of the name

Origin of the name

小さな変更・・・

small change......

Origin of the name

Changes

約70の提案・議論の中から8つを採用

  • try-with-resources

  • ダイヤモンド演算子

  • マルチキャッチ

  • Switchのcase指定時に文字列

  • @SafeVarargs

  • 適切な型を使った例外の再Throw

  • 2進数リテラル

  • 数値リテラルの区切り文字

try-with-resources

FileWriter fw = null;
try {
    fw = new FileWriter("tdsSummer.txt");
    fw.write("Pirates of the Caribbean");
} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        fw.close();
    } catch (IOException e) {
        System.out.println("クローズ失敗");
    }
}

try-with-resources

try( FileWriter fw = new FileWriter("tdsSummer.txt") ){
    fw.write("Pirates of the Caribbean");
}catch(IOException e){
    e.printStackTrace();
}

自動クローズ!

ダイヤモンド演算子

List<String> disneyParks = new ArrayList<String>();
List<String> disneyParks = new ArrayList<>();

@SafeVarargs

static void m(List<String>... stringLists) {
   Object[] array = stringLists;
   List<Integer> tmpList = Arrays.asList(42);
   array[0] = tmpList; 
   String s = stringLists[0].get(0); 
 }

ClassCastException

@SafeVarargs

@SafeVarargs
static void m(List<String>... stringLists) {
   Object[] array = stringLists;
   List<Integer> tmpList = Arrays.asList(42);
   array[0] = tmpList; 
   String s = stringLists[0].get(0); 
 }

@SafeVarargs

  • 使われているところ

    • Arrays.asList(T... a)

    • Stream.of(T... values)

@SafeVarargs

  • 使えるところ

    • final メソッド

    • static メソッド

    • コンストラクタ

ちっちゃくても

優秀。

Agenda

  • Java SE 7 Project Coin

  • Java SE 9 Milling Project Coin

  • matome

  • Project Coinで雑だったところを

    Java SE 9で回収しようぜプロジェクト

  • JEP213

    • 仕様策定ではなく機能拡張

  • リード:Joe Darcy

Milling Project Coin

Milling

  • 粉砕・粉々

  • (コーヒー豆などを)ひく

  • (貨幣周囲の)ギザギザ(をつけること)

Origin of the name

Changes

5つの機能拡張

  • try-with-resources構文変更

  • 匿名クラスでダイヤモンド演算子が使える

  • @SafeVarargsをprivateインスタンスメソッドで使える

  • 変数「アンダースコアのみ」の禁止

  • インタフェースにprivateメソッドが書ける

try-with-resources

private void writeMWords(BufferedWriter writer, String words) 
                                                                                 throws IOException {
        try(BufferedWriter writer2 = writer) {
            writer2.write("ハハッ! " + words);
        }
}
private void writeMWords(final BufferedWriter writer, String words) 
                                                                                 throws IOException {
        try(writer) {
            writer.write("ハハッ! " + words);
        }
}

ダイヤモンド演算子

Tds<String,String> f = new Tds<String,String>(){
    public String create(String name){
        return "ポートディズカバリー";
    }
};
Tds<String,String> f = new Tds<>(){
    public String create(String name){
        return "ポートディズカバリー";
    }
};

@SafeVarargs

  • final メソッド

  • static メソッド

  • コンストラクタ

  • privateインスタンスメソッド

使えるところ

Others

String _ = "Out of";

 

 

String _n = "shadowland";

インタフェースに

privateメソッドがOKに

Agenda

  • Java SE 7 Project Coin

  • Java SE 9 Milling Project Coin

  • matome

What I want to say is...

ちりも積もれば

山となり

血となり肉となり

みんなに「便利」を届けます。

覚えられるか

心配ですか?

大丈夫です。

(たぶん)

IDE の機能で

なんとかなると思います

Fin.

@maaya8585

今回お世話になったもの

  • http://amzn.to/2tZsnVz

  • http://itpro.nikkeibp.co.jp/atcl/column/15/120700278/050800037/

  • http://d.hatena.ne.jp/Kazuhira/20120828/1346157017

milling-project-coin

By maaya ishida

milling-project-coin

  • 1,359