Java in Motion

95
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1

description

Java in Motion: Java Platform Updates and Tradeoffs

Transcript of Java in Motion

Page 1: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.1

Page 2: Java in Motion

Java в движении

Алексей Фёдоров

Software Engineer, Oracle,

JCK, Java Platform Group

jug.msk, Москва

02.12.2013

Page 3: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.3

«А ты кто такой?»

Software Engineer

–Cначала были военные,

–потом legacy systems на Java EE

–С 2011 года в Oracle: JCK Team

Community driver: JUG.ru, CodeFreeze

Conferences: Jpoint, Joker

Peopleware advocate

ФМЛ 239, СПбГУ, к.ф.-м.н.

@23derevo, http://about.me/alexey.fyodorov

Page 4: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.4

Agenda

Java Platform Updates

Java Platform Tradeoffs

Page 5: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.5

Часть 1.Java Platform Updates

Page 6: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.6

The following is intended to outline our

general product direction. It is intended for

information purposes only, and may not be

incorporated into any contract.

It is not a commitment to deliver any material,

code, or functionality, and should not be

relied upon in making purchasing decisions.

The development, release, and timing of any

features or functionality described for

Oracle’s products remains at the sole

discretion of Oracle.

Page 7: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.7

С чем работает Java-приложение?

My Java-

application

Page 8: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.8

С чем работает Java-приложение?

JDK

My Java-

application

Page 9: Java in Motion

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

С чем работает Java-приложение?

JDKFrame-works

My Java-

application

Page 10: Java in Motion

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

С чем работает Java-приложение?

JDKFrame-works

OS

My Java-

application

Page 11: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.11

С чем работает Java-приложение?

JDK

Hardware

Frame-works

OS

My Java-

application

Page 12: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.12

С чем работает Java-приложение?

JDK

Hardware

Frame-works

OS

My Java-

application

Page 13: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.13

Как исправлять баги

OS

JDK

Frameworks

App

Hardware

Page 14: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.14

Обновления

Минимизируйте время на обновление

Вашего приложения

Библиотеки

ОС

Железо

Page 15: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.15

Обновления

Минимизируйте время на обновление

Вашего приложения

Библиотеки

ОС

Железо

Page 16: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.16

Обновления Java

Типы обновлений:

–Release update :7u17 → 7u21

–Major update: Java 7 → Java 8

Page 17: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.17

Обновления Java

Типы обновлений:

–Release update :7u17 → 7u21

–Major update: Java 7 → Java 8

Page 18: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.18

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

Page 19: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.19

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

–7u8 ?

–7u9, 7u10, 7u11…

Page 20: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.20

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

–7u8 ?

–7u9, 7u10, 7u11…

–7u12?

Page 21: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.21

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

–7u8 ?

–7u9, 7u10, 7u11…

–7u12?

7u13, 7u15, 7u17 …

Page 22: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.22

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

–7u8 ?

–7u9, 7u10, 7u11…

–7u12?

7u13, 7u15, 7u17 …

–7u19 ?

Page 23: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.23

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

–7u8 ?

–7u9, 7u10, 7u11…

–7u12?

7u13, 7u15, 7u17 …

–7u19 ?

7u21, 7u25

Page 24: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.24

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

–7u8 ?

–7u9, 7u10, 7u11…

–7u12?

7u13, 7u15, 7u17 …

–7u19 ?

7u21, 7u25

–7u29?

Page 25: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.25

Java 7 Updates versioning

7, 7u1, 7u2, 7u3, 7u4, 7u5, 7u6, 7u7 …

–7u8 ?

–7u9, 7u10, 7u11…

–7u12?

7u13, 7u15, 7u17 …

–7u19 ?

7u21, 7u25

–7u29?

Page 26: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.26

Page 27: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.27

Номера обновлений в JDK 7

Раз в два месяца

Чётные

–Исправление ошибок

–Новая функциональность

Нечётные

–Исправление ошибок

–Обновления системы безопасности

CPU = ?

Page 28: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.28

Номера обновлений в JDK 7

Раз в два месяца

Чётные

–Исправление ошибок

–Новая функциональность

Нечётные

–Исправление ошибок

–Обновления системы безопасности

CPU = Critical Patch Update

Page 29: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.29

Номера обновлений в JDK 7

Функциональность

–7u40, 7u60, 7u80

–8, 8u20, 8u40

Page 30: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.30

Номера обновлений в JDK 7

Функциональность

–7u40, 7u60, 7u80

–8, 8u20, 8u40

Безопасность

–7u45, 7u51, 7u55, 7u61

Page 31: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.31

Номера обновлений в JDK 7

Функциональность

–7u40, 7u60, 7u80

–8, 8u20, 8u40

Безопасность

–7u45, 7u51, 7u55, 7u61

–Exploit?

Page 32: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.32

Номера обновлений в JDK 7

Функциональность

–7u40, 7u60, 7u80

–8, 8u20, 8u40

Безопасность

–7u45, 7u51, 7u55, 7u61

–Exploit?

Emergency Releases!

(7u47, 7u49, 7u53, 7u57 etc.)

Page 33: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.33

Нечётные обновления –Security Baseline Updates

Любой патч, закрывающий какие-либо

уязвимости в JDK 7 должен быть

портирован в JDK 6 и все остальные

поддерживаемые версии

Page 34: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.34

Нечётные обновления –Security Baseline Updates

Page 35: Java in Motion

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

Чётные обновления: Feature Updates

JDK 7 Update 40 Highlights (пример)

Olson Data 2013d

Java Mission Control (JMC) 5.2

JavaFX 2.2.40

Serviceability Agent support for ARM

Retina Display support on Mac OS X

Deployment Rule Set

Option to disable "JRE out of date" warning

Page 36: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.36

Чётные обновления: Feature Updates

JDK 7 Update 40 Highlights (продолж.)

New Security Warnings for Unsigned and

Self-Signed Applications

JAXP Security Improvements

Security Baselines не изменились!

Page 37: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.37

Другие технологии

Java SE:

Standalone Technologies: JAXP, JAXB,

JNLP, JAX-WS (Везде своя нумерация!)

IANA Time Zone Database (aka Olson Data)

New platforms: Mac OS X, Windows 8.1 etc.

New HotSpot VM: new GC, new –XX options

Not Java SE:

Page 38: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.38

Правило Joe Darcy

Не бывает стопроцентно

совместимых изменений!

Page 39: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.39

Протокол взаимодействия

API spec

(aka Javadoc)

JLS8 JSR 337JVMS

8

Standalone

documents

Page 40: Java in Motion

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

Спецификация платформы

Спецификация платформы Java –

это протокол!

– Версия! (Java SE 6, 7, 8)

Протокол нельзя менять часто!

Page 41: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.41

Протокол SMTP

Тысячи серверов

Тысячи клиентов

тысячи + тысячи = тысячи

Timeline

1982 – RFC 821

2001 – RFC 2821

2008 – RFC 5321

Page 42: Java in Motion

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

Java

Миллионы Java-приложений

Тысячи реализаций Java

миллионы + тысячи = миллионы

Timeline

1996 – JDK 1.0 2002 – J2SE 1.4

1997 – J2SE 1.1 2004 – J2SE 5.0

1998 – J2SE 1.2 2006 – Java SE 6

2000 – J2SE 1.3 2011 – Java SE 7

Page 43: Java in Motion

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

Как управлять изменениями в Java

OpenJDK / Oracle JDK

JDK QA

Community

Java-программисты по всему миру

Page 44: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.44

Java от других вендоров

Процедура сертифицикации

Java Compatibility Kit (JCK)

Сотни тысяч тестов

Feedback от лицензиатов

Page 45: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.45

Как мы управляем изменениями?

Специальные процессы и процедуры

Множественное ревью на предмет

Сompatibility, Security, Performance etc.

–Tracking, Accepting / Rejecting

–Проверяются изменения

В спецификации

В реализации

JCP + OpenJDK

Page 46: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.46

Какие изменения допустимы?

Предлагаемое изменение Update Major

release

Добавить что-нибудь в Public API

(пакет / класс / метод / поле)

- +

Удалить что-нибудь из Public API - -*

Добавить что-нибудь в Private API + +

Удалить что-нибудь из Private API +** +

Изменить спецификацию чего-нибудь - +**

Исправить ошибку (несоответствие

поведения требуемому в спецификации)

+**,*** +

* - @Deprecated, @Override ** - проанализировать риски

*** - см. следующий слайд

Page 47: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.47

Adding null key to empty TreeMap

without Comparator should throw NPE

JDK-5045147 JDK-2188127

Page 48: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.48

«Давайте разрешим менять спецификацию чаще!»

Кто начнёт сходить с ума?

–Пользователи

–Инженеры Java Platform

–Лицензиаты Java

Совместимость может нарушаться!

–см. следующий слайд

Page 49: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.49

Совместимость может нарушаться!

Compatibility:

–binary

–source

–Behavioral

Bug-2-Bug

Incompatibilities

–between Java SE 7 and Java SE 6

–between JDK 7 and JDK 6

–Java SE 7 and JDK 7 Compatibility

Page 50: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.50

Наши инструменты (TCK Tools)

Проверяются изменения в сигнатурах

SigTest - http://sigtest.java.net/

–JDK – Public API

Жёсткие правила для Major Releases

Очень жёсткие правила для Updates

–NetBeans – Plugin API: полегчало!

Разметка спецификации и привязка тестов

–SpecTrac / SpecDiff

http://jcp.org/en/resources/tdk

Page 51: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.51

Выход Java 8 передвинут на март

http://mreinhold.org/blog/secure-the-train

–Люди не берутся из ниоткуда

–Добавляя людей в конце проекта, сроки

не уменьшить

–Какие рассматривались варианты?

Выкинуть Lambda

Выпустить в срок с сыроватыми Lambda

Подвинуть на полгода

http://openjdk.java.net/projects/jdk8/

Page 52: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.52

Что в итогеОбновление платформы, используемой

сотнями миллионов людей –

это очень сложный процесс!

Разные политики обновления для

Major Releases (Java 7 → Java 8) и для

Updates (7uXX)

–Отслеживание/Управление изменениями

–Специальные процессы

–Review изменений разными командами

–Инструменты: SpecTrac, SigTest и другие

Page 53: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.53

Компромиссы в обновлении платформы Java

Инженерное искусство – это искусство

компромисса!

A trade-off (or tradeoff) is a situation that

involves losing one quality or aspect of

something in return for gaining another

quality or aspect.

Page 54: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.54

Java Platform Tradeoffs

Cкорость выхода новых версий vs. Качество

Cкорость vs. частота выпуска CPU

Совместимость vs. Развитие

И так далее

– Подробности после перерыва!

Page 55: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.55

Java Platform Updates

Q&A

Page 56: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.56

Часть 2.Java Platform Tradeoffs

Page 57: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.57

Agenda

Частота выхода апдейтов

Фикс багов ломает совместимость

История про Substring

Совместимость как груз тянущий вниз

История о неизвестных отцах

История о четырёх аккумуляторах

GUI: Нативный или универсальный?

История про Beep

Как быть хитрому лицензиату?

Page 58: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.58

Сюжет 1Апдейты: часто или редко?

Page 59: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.59

Обновления Java и политика

Page 60: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.60

Page 61: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.61

Сюжет 2Исправление багов или совместимость?

Page 62: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.62

Adding null key to empty TreeMap

without Comparator should throw NPE

JDK-5045147 JDK-2188127

Page 63: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.63

Adding null key to empty TreeMap

without Comparator should throw NPE

JDK-5045147 JDK-2188127

Page 64: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.64

Сюжет 3String.substring()

Page 65: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.65

Page 66: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.66

Page 67: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.67

Page 68: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.68

Since JDK

7u6

Page 69: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.69

Performance vs. Memory

Page 70: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.70

Сюжет 4Совместимость или новые фичи?

Page 71: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.71

Page 72: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.72

Page 73: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.73

Сюжет 5Неизвестные отцы

Page 74: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.74

Page 75: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.75

Page 76: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.76

Page 77: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.77

Page 78: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.78

Сюжет 6История о четырёх аккумуляторах

Page 79: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.79

Page 80: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.80

Page 81: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.81

Page 82: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.82

Утекающий Striped64

Варианты решения:

Делегирование вместо наследования

Дупликация кода

Кодогенерация в билде JDK

Page 83: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.83

Утекающий Striped64

Варианты решения:

Делегирование вместо наследования

Дупликация кода

Кодогенерация в билде JDK

Serialization Proxy

Page 84: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.84

Сериализация

Implements Serializable

Есть в любой JDK

Гибкая

–writeObject, readObject, readObjectNoData

–writeReplace, readResolve

–Externalizable

Легко использовать

Много лет, мало багов

Page 85: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.85

Сюжет 7GUI: Нативный или универсальный?

Page 86: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.86

Page 87: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.87

Сюжет 7Toolkit.beep()

Page 88: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.88

Page 89: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.89

Java 7

Page 90: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.90

Java 7

Java 8

Page 91: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.91

Сюжет 8История о хитром лицензиате

Page 92: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.92

Page 93: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.93

Выводы

Большинство tradeoff’ов связаны с

совместимостью

–в том или ином её смысле

Имеющиеся риски трудно оценивать

Разные риски в update releases

и в major updates

Java двигается в Embedded

–Больше различий в поведении

Page 94: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.94

Q&A

Page 95: Java in Motion

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.95

Мои контакты

@23derevo

[email protected]

[email protected]

Skype: fyodorov.spbu

http://about.me/alexey.fyodorov