Александр Ильин, Oracle
Upcoming SlideShare
Loading in...5
×
 

Александр Ильин, Oracle

on

  • 1,756 views

«Новое в JDK 8»

«Новое в JDK 8»

BitByte: 20 апреля 2013, Санкт-Петербург
http://bitbyte.itmozg.ru/

Statistics

Views

Total Views
1,756
Views on SlideShare
465
Embed Views
1,291

Actions

Likes
0
Downloads
0
Comments
0

40 Embeds 1,291

http://spb.itmozg.ru 492
http://itmozg.ru 347
http://ua.itmozg.ru 210
http://by.itmozg.ru 73
http://kz.itmozg.ru 24
http://tatarstan.itmozg.ru 15
http://perm.itmozg.ru 15
http://rnd.itmozg.ru 12
http://oryol.itmozg.ru 9
http://vrn.itmozg.ru 9
http://nsk.itmozg.ru 8
http://khv.itmozg.ru 6
http://kaluga.itmozg.ru 6
http://krasnoyarsk.itmozg.ru 5
http://chel.itmozg.ru 5
http://saratov.itmozg.ru 4
http://ekburg.itmozg.ru 4
http://smolensk.itmozg.ru 4
http://surgut.itmozg.ru 4
http://kirov.itmozg.ru 4
http://penza.itmozg.ru 3
http://kuban.itmozg.ru 3
http://ryazan.itmozg.ru 3
http://nnov.itmozg.ru 2
http://komi.itmozg.ru 2
http://max-itmozg.ru 2
http://samara.itmozg.ru 2
http://tula.itmozg.ru 2
http://volgograd.itmozg.ru 2
http://vologda.itmozg.ru 2
http://irk.itmozg.ru 2
http://belgorod.itmozg.ru 2
http://dagestan.itmozg.ru 1
http://vladimir.itmozg.ru 1
http://chita.itmozg.ru 1
http://mari-el.itmozg.ru 1
http://yaroslavl.itmozg.ru 1
http://tambov.itmozg.ru 1
http://orenburg.itmozg.ru 1
http://kursk.itmozg.ru 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Александр Ильин, Oracle Александр Ильин, Oracle Presentation Transcript

  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 131
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132Что нового в JDK 8Александр ИльинАрхитектор тестирования JDK
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133The following is intended to outline our general productdirection. It is intendedfor information purposes only, and may not be incorporatedinto any contract.It is not a commitment to deliver any material, code, orfunctionality, and should not be relied upon in makingpurchasing decisions. The development, release, and timingof any features or functionality described for Oracle’s productsremains at the sole discretion of Oracle.
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 134Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16ProgramAgenda 50+ изменений DateTime API Type annotations Profiles Lambdahttp://openjdk.java.net/projects/jdk8/features
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135JDK 8Java for Everyone• Профайлы• JSR 310 - Date & Time APIs• Non-Gregorian calendars• Unicode 6.1• ResourceBundle• BCP47 locale matching●Globalization & AccessibilityInnovation• Lambda (замыкания)• Language Interop• NashornCore Libraries• “Параллельные” коллекцииImprovements in functionality• Improved type inferenceSecurity• Ограничение doPrivilege• NSA Suite B algorithm support• Поддержка SNI Server Side• DSA обновление FIPS186-3• AEAD JSSE CipherSuitesTools• Управление компилятором• JSR 308 – аннотации Java-типов• Нативные пакеты• Инструменты для App StoreClient●Новые методыразвертывания●JavaFX 8●Public UI Control API●ПоддержкаEmbedded●Поддержка HTML5●3D формы и атрибуты●Система печатиGeneral Goodness• Улучшения в JVM• No PermGen• Производительность
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136Date & Time API: JSR 310
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137Instant start = Instant.ofEpochMilli(123450L);Instant end = Instant.now();Duration duration = Duration.ofSeconds(12);Duration bigger = duration.multipliedBy(4);Duration biggest = bigger.plus(duration);Instant later = start.plus(duration);Instant earlier = start.minus(duration);Date & Time
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138LocalDate ld = LocalDate.of(2010, Month.DECEMBER, 3);LocalDateTime ldt =LocalDateTime.of(date, LocalTime.of(12, 33));ZonedDateTime zdt = ZonedDateTime.of(dateTime, zoneId);zdt = zdt.minus(12, HOURS);long days = DAYS.between(date1, date2);Period period = Period.between(date1, date2);Date & Time
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139Type annotations: JSR 308
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310Аннотации в Java до Java 8 @Target– ANNOTATION_TYPE, CONSTRUCTOR, FIELD,LOCAL_VARIABLE, METHOD, PACKAGE, PARAMETER, TYPE @Retention– SOURCE, CLASS, RUNTIME Поля, значения по умолчанию– @Test(timeout=100)– Primitive, String, Class, enum, array of the above Нет наследования
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311Аннотации в Java 8 Могут быть использованы на любом использовании типа– Информация на следующих слайдах ... @Target– TYPE_PARAMETER, TYPE_USE Повторяющиеся аннотации@
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312JSR 308: Annotations on Java Types (1) method receiverspublic int size() @Readonly { ... } generic type argumentsMap<@NonNull String, @NonEmpty List<@Readonly Document>>files; arraysDocument[][@Readonly] docs2 =new Document[2] [@Readonly 12];
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313JSR 308: Annotations on Java Types (2) typecastsmyString = (@NonNull String)myObject; type testsboolean isNonNull = myString instanceof @NonNull String; object creationnew @NonEmpty @Readonly List(myNonEmptyStringSet)
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314JSR 308: Annotations on Java Types (3) type parameter bounds<T extends @A Object, U extends @C Cloneable> class inheritanceclass UnmodifiableList implements @Readonly List<@Readonly T> { ... } throws clausesvoid monitorTemperature() throws @Critical TemperatureException { ... }
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315Nullness checkerЕсли Nullness checker не рапортует ошибок для какой-либопрограммы, тогда во время выполнения этой программыникогда не будет брошено null pointer exception.@Nullable Object obj; @NonNull Object nnobj;...nnobj.toString(); obj.toString();nnobj = obj; obj = nnobj;if (nnobj == null) ...if (obj != null) {nnobj = obj; //type refinement}
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316Lock checkerЕсли Lock checker не рапортует ошибок для какой-либопрограммы, тогда программа держит определенный мониторкаждый раз когда доступается до переменной. @GuardedBy – доступ разрешен только если держитсяопределенный монитор @Holding – вызов разрешен только если держится определенныймонитор
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317Lock checker@GuardedBy("MyClass.myLock") Object myMethod() { ... }@GuardedBy("MyClass.myLock") Object x = myMethod();@GuardedBy("MyClass.myLock") Object y = x;Object z = x;x.toString();synchronized(MyClass.myLock) {y.toString();}
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318Lock checkervoid helper1(@GuardedBy("MyClass.myLock") Object a) {a.toString();synchronized(MyClass.myLock) {a.toString();}}@Holding("MyClass.myLock")void helper2(@GuardedBy("MyClass.myLock") Object b) {b.toString();}
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319JDK profiles
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320basetls loggingauthjdbcjtarmijaxpnamingrowsetkerberos managementcompilerxmldsigprefssctpinstrumentscriptingcryptocompatmanagement.iiop cosnamingcorbadesktoptools.jrejaxwsjx.annotationshttpservertoolstools.jaxws tools.basedevtools
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321basetls loggingauthjdbcjtarmijaxpnamingrowsetkerberos managementcompilerxmldsigprefssctpinstrumentscriptingcryptocompatmanagement.iiop cosnamingcorbadesktoptools.jrejaxwsjx.annotationshttpservertoolstools.jaxws tools.basedevtools52MB
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322basetls loggingauthjdbcjtarmijaxpnamingrowsetkerberos managementcompilerxmldsigprefssctpinstrumentscriptingcryptocompatmanagement.iiop cosnamingcorbadesktoptools.jrejaxwsjx.annotationshttpservertoolstools.jaxws tools.basedevtools52MB 24
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323basetls loggingauthjdbcjtarmijaxpnamingrowsetkerberos managementcompilerxmldsigprefssctpinstrumentscriptingcryptocompatmanagement.iiop cosnamingcorbadesktoptools.jrejaxwsjx.annotationshttpservertoolstools.jaxws tools.basedevtools52MB 1724
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324basetls loggingauthjdbcjtarmijaxpnamingrowsetkerberos managementcompilerxmldsigprefssctpinstrumentscriptingcryptocompatmanagement.iiop cosnamingcorbadesktoptools.jrejaxwsjx.annotationshttpservertoolstools.jaxws tools.basedevtools1052MB 1724
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325Lambda: JSR 335
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326Lambda Лямбда(Object o) -> (o.toString()); Ссылка на методObject::toString() Метод по умолчаниюCollection.forEach(java.util.function.Block) Collectionsshapes.stream().filter(s s.getColor() == BLUE).map(s s.getWeight()).sum();
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27Функциональные интерфейсыИнтерфейс с одним методом●Runnable, Comparator, ActionListener●Predicate<T>, Block<T>Лямбда - экземпляр функционального интерфейсаPredicate<String> isEmpty = s s.isEmpty();Predicate<String> isEmpty = String::isEmpty;Runnable r = () {System.out.println(“Boo!”) };
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28Эволюция интерфейсов Палка о двух концах– Гибкость• Специфицирован только API– Невозможно изменить• Требуется менять все имплементации
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29Методы по умолчаниюinterface Collection<E> {default void forEach(Block<E> action) {for (E e: this) action.apply(e);}default boolean removeIf(Predicate<? super E> filter) {boolean removed = false; Iterator<E> each = iterator();while ( each.hasNext() ) {if ( filter.test( each.next() ) ) {each.remove(); removed = true;}}return removed;}}
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30Методы по умолчаниюМножественное наследование? Интерфейса Поведения Состояния
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31Методы по умолчаниюМножественное наследование? Интерфейса Поведения Состояниябыло всегда
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32Методы по умолчаниюМножественное наследование? Интерфейса Поведения Состояниябыло всегдабыло всегдаметоды по умолчанию
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33Методы по умолчаниюМножественное наследование? Интерфейса Поведения Состоянияметоды по умолчаниюбыло всегда
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34Методы по умолчаниюМножественное наследование?1.Класс побеждает2.Более специфичный интерфейс предпочтительней3.Во всех остальных случаях пользователь должен предоставитьреализацию Интерфейса Поведения Состояниябыло всегдаметоды по умолчанию
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35Diamonds? Нет проблем!interface A {default void m() {…}}interface B extends A {…}interface C extends A {…}class D implements B, C {...}AB CDm
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36Diamonds? Нет проблем!interface A {default void m() {…}}interface B extends A {default void m() {…}}interface C extends A {...}сlass D implements B, C {...}AB CDmm
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37Явное разрешение неоднозначностиinterface A {default void m() {…}}interface B {default void m() {…}}class C implements A, B {//Must implement/reabstract m()void m() { A.super.m(); }}A BDm m
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38CортировкаCollections.sort(people, new Comparator<Person>() {public int compare(Person x, Person y) {return x.getLastName().compareTo(y.getLastName());}});
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39Сортировка с лямбдойComparator<Person> byLastName= comparing(p p.getLastName());Collections.sort(people, byLastName);Collections.sort(people, comparing(pp.getLastName()));people.sort(comparing(p p.getLastName()))
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40Сортировка с лямбдойpeople.sort(comparing(Person::getLastName))people.sort(comparing(Person::getLastName).reverse());people.sort(comparing(Person::getLastName).compose(comparing(Person::getFirstName)));
  • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1341Что нового в JDK 8Александр ИльинАрхитектор тестирования JDK