47
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 今年はJava進化の年! 今知っておくべき新しいJava 2017217日本オラクル株式会社 クラウド・テクノロジー事業統括 Fusion Middleware事業本部 伊藤 @itakash

今年はJava進化の年!今知っておくべき新しいJava

Embed Size (px)

Citation preview

Page 1: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

今年はJava進化の年! 今知っておくべき新しいJava

2017年2月17日 日本オラクル株式会社 クラウド・テクノロジー事業統括 Fusion Middleware事業本部 伊藤 敬 @itakash

Page 2: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java SE最新動向

Page 3: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java SE Roadmap

JDK 8

• Lambda & Stream API

• New Date and Time API

• Nashorn: JavaScript Interoperability

• JavaFX Enhancements

• Etc..

8u40 • Performance Improvements

• Density and Resource Management

• Multi-Language Support Improvements

• Accessibility Enhancements

• Continued Java SE Advanced Features

JDK 9 • Modularity – Jigsaw

• Jshell (Java Shell)

• HTTP 2.0

• G1GC as default

• JDK 5 source code can not compile

• Continued Java SE Advanced Features

8u20 • G1 Performance Improvement

• JVM Performance Improvements

• Java Mission Control 5.4

• Advanced Management Console 1.0

• MSI Enterprise JRE Installer

8u60 • Bug Fixes

• Continued Java SE Advanced Features

2016 2014 2015 2017

3

Page 4: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java 9リリースまでのスケジュール (as of 2/17/2017) • 2016/05/26 Feature Complete(JDK9の仕様・実装確定)

• 2016/12/22 Feature Extension Complete (その他マイナーな仕様・実装確定)

• 2017/01/05 Rampdown Start (テストで露見したBugの修正開始)

• 2017/02/09 All Tests Run(最終総合テスト開始)

• 2017/02/16 Zero Bug Bounce(露見した全てのBugの手当て・方策確定)

• 2017/03/16 Rampdown Phase 2(Bug修正最終段階)

• 2017/07/06 Final Release Candidate(正式リリース版の最終候補確定)

• 2017/07/27 General Availability(リリース版提供開始)

4

https://jdk9.java.net/

Page 5: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

JDK 9紹介

Page 6: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

主要機能

• Jigsaw

• jshell: The Java Shell (JEP 222)

• Javadoc機能改善 – HTML5(JEP 224) / Search (JEP 225)

• Encapsulate Most Internal APIs (JEP 260)

• Process API Updates (JEP 102)

• Multi Release Jar Files (JEP 238)

• Security強化・関連JEP

• Deprecated/Removed機能

Page 7: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Jigsaw – JDK/JREのモジュール化

7

• Java 8

– Compact Profile 1, 2, 3, Fullの4種類を提供

• Java 9

– 任意のモジュールを組み合わせてランタイムが作成できる

– 不要なモジュールをJREに含めないことで、 軽量化、セキュリティ向上が期待できる

JEP 200: The Modular JDK http://openjdk.java.net/jeps/200

Page 8: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java SE 9 – モジュールの導入(Project Jigsaw)

• Javaプログラム構造の変更 – ”Module”の導入

Package

Class & Interface

public class sample { public void main(…) { string str: int x; void sampleMethod(); …

Package

Class & Interface

public class sample { public void main(…) { string str: int x; void sampleMethod(); …

Module

8

Page 9: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 9

モジュールの定義はmodule-info.javaで行う

module com.foo.app { requires com.foo.bar; requires java.sql; }

com.foo.app

java.sql com.foo.bar

module-info.java

依存性

Page 10: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 10

module-info.java: 公開範囲の宣言

module com.foo.bar { exports com.foo.bar.alpha; exports com.foo.bar.beta; }

com.foo.bar

com.foo.bar.alpha com.foo.bar.beta

com.foo.bar.internal

module-info.java

Page 11: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Jigsaw - jlink: The Java Linker (JEP 282)

• jlink - Jigsawのためのコマンドツール

•必要なモジュールだけをまとめたカスタムJREを作成できる

11

jlink --modulepath mods;"C:¥Program Files¥Java¥jdk-9¥jmods" --addmods xxx --output yyy

Page 13: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

jshell: The Java Shell (JEP 222)

13

• JavaのREPL環境 (Read-Eval-Print Loop)を提供

• ちょっとしたJavaコード・新しいAPI、ロジックの確認に役立つ機能

jshell> int k = 14

k ==> 14

jshell> long fibonacci(int n) {

...> return n <= 1? n : fibonacci(n-1) + fibonacci(n-2);

...> }

| created method fibonacci(int)

jshell> fibonacci(3)

$3 ==> 2

jshell> fibonacci(k)

$4 ==> 377

jshell> for (int i = 1; i <= k; ++i) printf("%7d: %12d¥n", i, fibonacci(i))

1: 1

2: 1

3: 2

4: 3

5: 5

・・・

Page 14: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Javadoc機能改善 – HTML5(JEP 224) / Search (JEP 225)

14

• JavadocのHTML5対応

• Javadocに検索機能を追加

Java 8 Javadoc: https://docs.oracle.com/javase/8/docs/api/

Java 9 Javadoc: http://download.java.net/java/jdk9/docs/api/index.html

Page 15: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Encapsulate Most Internal APIs (JEP 260)

15

•内部APIのカプセル化

• Java 9からはほとんどの内部APIはデフォルトでアクセスできなくなる

• ただし、代替APIの提供が完了していない内部APIは(当分は)利用可能

• Java 9でもアクセス可能な内部APIは以下の通り – sun.misc.Unsafe

– sun.misc.{Signal,SignalHandler}

– sun.reflect.Reflection::getCallerClass

– sun.reflect.ReflectionFactory

– sun.misc.Cleaner

Page 16: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Multi Release Jar Files (JEP 238)

• 1つのJarファイルの中で、複数のJavaバージョンを指定できる

16

META-INF

Content Root A.class B.class C.class D.class

Normal JAR

META-INF versions -8 A.class B.class -9 C.class

Content Root A.class B.class C.class D.class

Multi Release JAR

Page 17: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Deprecated/Removed機能

17

•以下の機能はJava 9からは非推奨(Deprecated)または削除(Removed)

–非推奨

• JEP 289: Deprecate the Applet API –アプレットはJava 9からは非推奨扱い

–削除

• JEP 241: Remove the jhat Tool

• JEP 231: Remove Launch-Time JRE Version Selection

• JEP 240: Remove the JVM TI hprof Agent

Page 18: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

JDK9 移行のポイント

18

Page 19: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

•バグ修正

•利用可能なアルゴリズムの変更

• セキュリティ改善

•サポート対象プラットフォームの 変更

• ネイティブコードの使用

• Properties の変更

•非推奨の警告(@depricated)

• デプロイ系の変更(browser)

•内部実装の変更 – GC アルゴリズム – G1GCデフォルト化

–多くの内部API の使用不可

•パッケージ –ファイル名、内部ファイルの形式、

–レジストリのキー(Windows)、インストール先(ディレクトリ)

• ツールやファイルの排除

•非推奨のメソッド、クラス、機能の排除

19

JDK 9で想定される主要な非互換の原因

Page 20: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

JEP 260: Encapsulate most internal APIs

• デフォルトで殆どの内部API をアクセスすることが出来なくなる

•幾つかの利用頻度の高い API は暫定的に利用可能を継続 –代替できる public API がまだないことが前提

20

ほとんどの内部APIが利用不可になる

Page 21: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

殆どの sun.misc.* と sun.reflect.* API の利用不可に

•代替 public API がまだ存在しないものが一時的に残る – sun.misc.Unsafe

– sun.misc.{Signal,SignalHandler}

– sun.misc.Cleaner

– sun.reflect.Reflection::getCallerClass

– sun.reflect.ReflectionFactory

•上記以外の sun.{misc,reflect}の API が利用できなくなる –例:sun.misc.Base64

21

sun.misc.Base64.Encoder sun.misc.Base64.Decoder

java.util.Base64.Encoder java.util.Base64.Decoder

Page 22: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

内部API利用の確認、暫定の内部API利用

• JDK 8 に含まれている jdeps ツールを使って、内部 API の利用を検出 することが出来る – JDK 9 に含まれているバージョンの利用を推奨

• どうしても従来の内部API利用が必要な場合は、コマンドラインのフラグ指定によって従来のライブラリ利用を指定、利用することが可能 –あくまで暫定の処置方法をご理解ください

22

Page 23: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

JEP 223: New Version String Scheme(バージョニング変更)

• JDK 8 以前の version string は独自ルール

•新しい仕組みはセマンティック バージョニングを準拠し、従来の歴史的な部分(1.x や u など)を排除

• JDK のファイル名も変更する

• JDK 9以降の変更 – JDK8まではこれまでバージョニングを維持

23

JDK 1.9.0_25 から JDK 9.1.9 へ

JDK <major version>.<minor version>.<security update>

Page 24: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

JEP 220: Modular Run-Time Images

• 実行環境にモジュール化が導入されるため、JREのディレクトリ構成、ファイル構成が変更される

– ファイル名、ファイルの内部構造、Windowsのレジストリキー、インストール・ホルダ

• JREのフォルダー構成及び上記の変更箇所に依存する実装はお勧めしません

– 独自のライブラリ等は、別のホルダを作成し、明示的にクラスパスを指定することをお勧めします

• 既存のアプリケーションで上記のようなコードが存在する場合は修正が必要

24

JREディレクトリ構成、ファイル構成の変更、rt.jar の排除

Page 25: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java 9 EA版でのJREディレクトリ構成

25

• JDK 9 Early Access Build 153で確認したJRE/lib以下のディレクトリ構成

– JRE 8のディレクトリ構成とは異なる • lib/applet, lib/ext

• rt.jarがなくなる

Page 26: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

コンパイル可能なバージョンの制限 JEP 182: Policy for Retiring “javac –source and –target options”

• {-source,-target} 1.5 は JDK 8 で非推奨化

• JDK 9 では 1.6 以上をサポート、1.5より以前は非対応

•新しいポリシーは”one plus three back”

–例: JDK 9 は 6, 7, 8, 9

JDK 10 は 7, 8, 9, 10

26

Page 27: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

JavaDB の非搭載

• JavaDB は単純に Apache Derby のコピー

• JDK 7 と JDK 8 で付属されていた

• Apache プロジェクトからの直接入手に変更

27

Page 28: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Javaプラグイン実行時のメッセージ表示

28

Page 29: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

JDK9/JRE9でアプレットを起動した際に表示される メッセージ画面(日本語)

• JRE9からはアプレットを起動すると以下のような警告メッセージが表示されます

デスクトップ

Javaコンソール

* メッセージ全文(ポップアップと同じ文面) 警告: Java Plug-inが非推奨であり、今後のJavaリリースでの削除が考えられます。このコンテンツの開発者に連絡してこのプログラムの更新を依頼してください。

29

Page 30: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

メッセージ画面(「発行者」が設定されている場合)

「発行者」が設定されている場合、 その値が警告メッセージのここに入る。

30

Page 31: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java EE 8 修整提案

Page 32: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java EE – What’s Next?

32

クラウドとマイクロサービスのための 新しいアプリケーション開発のスタイル

Page 33: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Java Platform, Enterprise Edition への提案仕様

• クラウド、マイクロサービス向けの新しいアプリケーション開発を想定

• 実績あるテクノロジーで構成

• 包括的な構成

–プログラミング・モデル、パッケージング、ポータビリティ

• 標準ベース

–本内容は提案仕様

– JCPプロセスに沿ってコミュニティとともに検討を進める

33

Page 34: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

クラウド・アプリケーション開発で想定する各要素

異種クライアントとの連携を実現する

• 多言語化

• Mobile, REST, HTML5

ステートレス・サービスの主流化

• マイクロサービスへの対応

• サービス個別の管理運用とスケーラビリティ

多彩なデータソースに 対応

• リレーショナルと ノン・リレーショナル

User profile service

Order service

Partner service

Catalog service

Notification service

Import service

HTTP/2 REST JSON XHR

Event JAX-RS/JSON Notifications JAX-WS

RDBMS NoSQL DB TSDB Data Streams

Time Series Events Key Value JDBC

34

Page 35: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 35

Make Your Middle Tier Stateless Push all state and configuration down to highly available cloud services

Application Server

File System

Application Server

File System

Application Server

File System

Application Server

File System

Application Instance

File System

Load Balancer Sticky to an Individual Instance

Application Instance Application

Instance Application Instance Application

Instance

Load Balancer NOT Sticky to an Individual Instance

State Service

Configuration Service

Application Instance

Key to Cloud Native

Session State Shopping cart contents, page view data, personalization, etc

Application Configuration Port numbers, file system paths, host names, etc

Legacy Cloud Native

Page 36: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 36

Platform Architecture Orchestration – Deployment, Scheduling, and Standup

BareMetal

Orchestration

Deployment Manager

Local Service Impls

Additional Local Classfiles

Java EE Cloud Native App

Container Container

Container

Java EE Cloud Native App

JLink

Local Service Impls Additional Local Classfiles

Java EE Cloud Native App With Just Enough

Container

Container Container

Java EE Cloud Native App

Page 37: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 37

Platform Architecture Orchestration – Inspection, Injection, and Wiring

BareMetal

Orchestration

Container

Config

Cache

Logging

Platform Services

Service Registry

Java EE Cloud Native App

Java EE Cloud Native App

@Config @Cache @Logging @Service Name

Impl

Impl

Impl

Impl

Page 38: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

Recent Java EE 7 compatibility updates: Congratulations! テクノロジーのフォーカスエリア:サマリー

リアクティブ・プログラミングの導入

Unified event model

Event messaging API

JAX-RS, HTTP/2, Lambda, JSON-B, ...

Programming Model

外部化されたState管理へストアするAPI

State

データストラクチャの変更時に自動的にイベントを発生させる

Eventual Consistency

クライアント側のサーキットブレーカのサポート

回復用コマンド

クライアント側のヘルス・レポートのフォーマットを標準化

Resiliency

新仕様 – インタフェース、パッケージングフォーマット、マニフェスト

ごく短命なインスタンス

Serverless

Secret management

OAuth

OpenID

Security アプリケーションとランタイムをサービスとしてパッケージ

スタンドアロン型のイミュータブル実行バイナリ

多様な形態のアーカイブ

Packaging 集約性の向上

テナントベースのルーティングとデプロイ

Multitenancy

コンフィグレーションを外だしにする

コンフィグレーションへアクセスする統一化API

Configuration

key valueとDocument DBのための永続性とクエリ・インタフェース

Key Value/Doc Store

38

Page 39: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

提案プラットフォームアーキテクチャ

Java EE Packaging, Serverless, Multitenancy

OS / Hypervisor

Container Runtime

Java SE Runtime

Java EE Runtime

Programming Model

API Gateway

Load Balancer

HTTP/2

JSON-B

Event API

REST API

Security API State API Config API

Eventual Consistency

Resiliency Key Value Store API

39

Key Value

Database

Logging

Config

State

Security

Notification

Rel

iab

ility

, Mo

nit

ori

ng

Man

agem

ent

and

Orc

hes

trat

ion

Sch

edu

ling

and

Ela

stic

Sca

ling

Page 40: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 40

Java EE 7

Connector JAXB JSP Debugging

Managed Beans JSP Concurrency EE Interceptors JAX-WS WebSocket

Bean Validation JASPIC Servlet JMS JTA Deployment

Batch JACC Dependency Injection JAXR JSTL Management

CDI EJB JAX-RPC Web Services JSF JPA

JSON-P Common Annotations EL JAX-RS Web Services

Metadata JavaMail

Page 41: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |

修整版 Java EE 8 プロポーザル

41

No Change to Plan Propose to Drop Propose to Add

JSON <-> object mapping

JSON-B 1.0 (JSR 367) Flexible JMS MDBs

Improved XA support

JMS 2.1 (JSR 368)

HTTP/2 support

Servlet 4.0 (JSR 369) Reactive enhancements Server-sent events Non-blocking I/O Client-side circuit breakers

JAX-RS 2.1 (JSR 370) Action-based MVC framework

MVC 1.0 (JSR 371)

Small-scale new features

Community-driven improvements

JSF 2.3 (JSR 372) REST-based APIs

Management 2.0 (JSR 373) JSON Pointer and Patch

Java Lambda support

JSON-P 1.1 (JSR 374)

Authentication/authorization APIs OAuth, OpenID support Secret management

Security 1.0 (JSR 375) Standard for externalizing application

configuration

Configuration

Standard for client-side health reporting

Health Checking

Bootstrap API for Java SE Async events Observer ordering

CDI 2.0 (JSR 365)

Collection constraints Date/Time support Community-requested features

Bean Validation 2.0 (JSR 380)

Page 42: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 42

Java EE 8 (Revised Proposal, 2016)

Connector JAXB JSP Debugging

Managed Beans JSP Concurrency EE Interceptors JAX-WS WebSocket

Bean Validation JASPIC Servlet JMS JTA Deployment

Batch JACC Dependency Injection JAXR JSTL Management

CDI EJB JAX-RPC Web Services JSF JPA

Common Annotations EL JAX-RS Web Services

Metadata JavaMail

CDI

JSON-B Security

Bean Validation

JSF

JAX-RS JSON-P

Servlet

Health Check Configuration

JSP

Page 43: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 43

Java EE Roadmap

Java EE Communityとの協力 • サーベイからフィードバック • Java EE Next JSRsの策定

2016 Java EE 8 • Specs, RI, TCK の提供 • マイクロサービス・サポート (イニシャル)

• Java EE 9 策定 • Java EE 9インプリメンテーションの Early Access版提供

Java EE 9 • Specs, RI, TCK の提供 • モジュラー Java EEランタイム

• マイクロサービス・サポート(エンハンスド)

2017

2018

Page 44: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 44

最新Java情報はこちらから!:Oracle Java & Developers https://builder.japan.zdnet.com/sp_oracle/

Page 45: 今年はJava進化の年!今知っておくべき新しいJava

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted 45

今すぐTRY! Oracle Cloud無料トライアルのご案内

https://cloud.oracle.com/ja_JP/tryit

Page 46: 今年はJava進化の年!今知っておくべき新しいJava

Confidential – Oracle Internal/Restricted/Highly Restricted 46

Page 47: 今年はJava進化の年!今知っておくべき新しいJava