SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132
Lambda, Nashorn,
Metaspace: algumas
novidades do Java SE 8
Bruno Borges
Oracle Product Manager
Java Evangelist
@brunoborges
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133
Bruno Borges
Oracle Product Manager / Evangelist
Desenvolvedor, Gamer, Beer Sommelier
Entusiasta em Java Embedded e JavaFX
Twitter: @brunoborges
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 16
Agenda
 História
 Scene Graph
 Java API
 Properties
 Bindings
 Controls
 CSS
 WebView
 JFXPanel
 Charts
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135
SE8
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136
Um pouco da história

Green Team, C++ ++ –, Oak - 1990

Java 1.0 / 1.1 – 1996 / 1997

Java 2 “J2SE” 1.2 – 1998

Java 1.3 ”J2SE 1.3” – 2000

Java 1.4 ”J2SE 1.4” – 2002

Java 1.5 “Java SE 5” - 2004

Java 1.6 “Java SE 6” - 2006

Java 1.7 “Java SE 7” - 2011
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137
E o futuro...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138
E o JavaFX?
É o sucessor do
Java Swing
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139
Disponível para...

Windows, Linux, Mac OS X

E em Preview...

ARM*

Apple iOS*

Android*

JavaFX 2.2 vem junto com JDK 7u6+

Standalone para Java 6
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310
OpenJFX
JavaFX open sourced!
http://openjdk.java.net/projects/openjfx/
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
Java
SE 8
 Melhorias em interfaces
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312
Java SE 8 – Melhorias em Interfaces

Static methods

Métodos com implementação default

Functional Interfaces

toda interface que define apenas 1 método abstrato (sem corpo)

@FunctionalInterface: similar a @Override, para garantia
public default void forEach(Consumer<? super T> action) {
Objects.requireNonNull(action);
for (T t : this) {
action.accept(t);
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
Java
SE 8
 Melhorias em interfaces
 Lambdas
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314
Java SE 8 – Lambdas

Lista de inputs tipados à esquerda, bloco com retorno à direita

Input à esquerda, void à direita

Métodos estáticos e de objetos como funções lambda
(int x, int y) -> { return x + y; }
(x, y) -> x + y
x -> x * x
() -> x
x -> { System.out.println(x); }
String::valueOf x -> String.valueOf(x)
Object::toString x -> x.toString()
x::toString () -> x.toString()
ArrayList::new () -> new ArrayList<>()
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315
Java SE 8 – Lambdas (cont.)

Em busca de um match para saber qual construtor/método chamar

O método compare precisa de dois parâmetros, e deve retornar
int. A expressão lambda condiz com esta assinatura, logo a
expressão é válida

Expressões não devem modificar variáveis definidas fora do corpo
lambda
Comparator<String> c = (a, b) -> Integer.compare(a.length(),
b.length());
int count = 0;
List<String> strings = Arrays.asList("a", "b", "c");
strings.forEach(s -> {
count++; // error: can't modify the value of count
});
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316
Java SE 8 – Lambdas (cont.)

Classes abstratas não podem ser instanciadas com lambda

poderia esconder código (construtor por exemplo)

elimina possibilidade de otimizações futuras

Solução: factory methods
Ordering<String> order = (a, b) -> ...;
CacheLoader<String, String> loader = (key) -> ...;
Ordering<String> order = Ordering.from((a, b) -> ...);
CacheLoader<String, String> loader =
CacheLoader.from((key) -> ...);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317
Java SE 8 – Lambdas (cont.)

Novos pacotes:

java.util.stream: suporta operações em valores de stream, com
expressões lambda

java.util.function: interfaces funcionais utilitárias do JDK
int sumOfWeights = blocks.stream().filter(b -> b.getColor() == RED)
.mapToInt(b -> b.getWeight())
.sum();
// In Java 7:
foo(Utility.<Type>bar());
Utility.<Type>foo().bar();
// In Java 8:
foo(Utility.bar());
Utility.foo().bar();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318
Java SE 8 – Lambdas: Antes e Depois
public void emailDraftees(List<Person> pl) {
for(Person p : pl){
if (p.getAge() >= 18 &&
p.getAge() <= 25 &&
p.getGender() == Gender.MALE) {
roboEmail(p);
}
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319
Java SE 8 – Lambdas: Antes e Depois
public void emailDraftees(List<Person> pl) {
for(Person p : pl) {
if (isDraftee(p)) {
roboEmail(p);
}
}
}
public boolean isDraftee(Person p){
return p.getAge() >= 18
&& p.getAge() <= 25
&& p.getGender() == Gender.MALE;
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320
Java SE 8 – Lambdas: Antes e Depois
Predicate<Person> draftees;
draftees = p -> p.getAge() >= 18 &&
p.getAge() <= 25 &&
p.getGender() == Gender.MALE;
robo.emailContacts(pl, allDraftees);
public void emailContacts(List<Person> pl, Predicate<Person> pred) {
for(Person p : pl)
if (pred.test(p))
roboEmail(p);
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
Java
SE 8
 Melhorias em interfaces
 Lambdas
 Generics
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322
Java SE 8 – Generics

Inferência de tipos genéricos
// In Java 7:
foo(Utility.<Type>bar());
Utility.<Type>foo().bar();
// In Java 8:
foo(Utility.bar());
Utility.foo().bar();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
Java
SE 8
 Melhorias em interfaces
 Lambdas
 Generics
 Date and Time API
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324
Java SE 8 – Date and Time

Mudança total da API para lidar com data, hora, calendário

Baseado no JodaTime – JSR 310

Novas classes:

LocalDateTime, LocalDate, LocalTime

Year, YearMonth, Month, MonthDay, DayOfWeek

Instant, ZonedDateTime, OffsetTime, Duration, Period
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16
Java
SE 8
 Melhorias em interfaces
 Lambdas
 Generics
 Date and Time API
 Outras APIs
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326
Java SE 8 – Outras mudanças de API

Reflection API

Manipular lambdas, anotações, etc

Annotations

Permite definir anotação no tipo genérico

Novos métodos em IO/NIO (busca recursiva de arquivo/diretorio)

Concurrency API

Collections API
List<@Nullable String>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327
DEMO
Antes e depois do Java SE 8
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328
Nashorn
Javascript
the right way
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329
Oracle Nashorn?
É o sucessor do
Mozilla Rhino
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1330
Nashorn

Engine de processamento da linguagem Javascript

Escrito do zero

Seguindo boas práticas

Novas técnicas e algoritmos

Atento às otimizações da JVM (ex: invokedynamic)

Projeto mantido pela Oracle, e Open Source

Incluído no OpenJDK em 21/12/12
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1331
Nashorn – Diferenciais?

Maior integração com a camada Java

Integração com aplicações JavaFX

Utilizado nos componentes WebView e HTML5

Maior performance

Menor footprint de memória
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1332
DEMO
JavaFX usando Nashorn
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1333
Metaspace
Say goodbye to
OutOfMemoryError
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1334
Metaspace

Substitui a PermGen

Modelo já utilizado pela JVM Oracle JRockit

Por padrão, o tamanho é variável – ótimo para desenvolvimento

Em produção, deve ser limitado
– novo parâmetro: -XX:MaxMetaspaceSize
– parâmetros *PermGen ignorados pela VM

Dados armazenados “off-heap”

Limitado ao tamanho de memória disponível na máquina
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1335
Perguntas?
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1336
OBRIGADO!
@brunoborges
blogs.oracle.com/brunoborges
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1337
The preceding 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.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1338

Contenu connexe

Tendances

JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...
JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...
JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...
InSync2011
 
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEd presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Edward Burns
 

Tendances (14)

Java EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the CloudJava EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the Cloud
 
plsql les10
 plsql les10 plsql les10
plsql les10
 
Java 101
Java 101Java 101
Java 101
 
plsql Les05
plsql Les05 plsql Les05
plsql Les05
 
plsql les06
 plsql les06 plsql les06
plsql les06
 
plsql les01
 plsql les01 plsql les01
plsql les01
 
JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...
JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...
JD Edwards & Peoplesoft 1 _ Peter Bruce _ Include Work Centre error messages ...
 
Plsql les04
Plsql les04Plsql les04
Plsql les04
 
Lesson04 学会使用分组函数
Lesson04 学会使用分组函数Lesson04 学会使用分组函数
Lesson04 学会使用分组函数
 
JavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской JavaJavaFX 2.1 - следующее поколение клиентской Java
JavaFX 2.1 - следующее поколение клиентской Java
 
plsql Lec11
plsql Lec11 plsql Lec11
plsql Lec11
 
plsql Les08
plsql Les08 plsql Les08
plsql Les08
 
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun GuptaJAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
 
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEd presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
 

Similaire à Novidades do Java SE 8

A Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedA Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado Embedded
Bruno Borges
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry Pi
Bruno Borges
 
JavaFX and JEE 7
JavaFX and JEE 7JavaFX and JEE 7
JavaFX and JEE 7
Vijay Nair
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
Martin Fousek
 

Similaire à Novidades do Java SE 8 (20)

Aplicações HTML5 com Java EE 7 e NetBeans
Aplicações HTML5 com Java EE 7 e NetBeansAplicações HTML5 com Java EE 7 e NetBeans
Aplicações HTML5 com Java EE 7 e NetBeans
 
A Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado EmbeddedA Importância do JavaFX no Mercado Embedded
A Importância do JavaFX no Mercado Embedded
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry Pi
 
JavaFX and JEE 7
JavaFX and JEE 7JavaFX and JEE 7
JavaFX and JEE 7
 
whats-new-netbeans-ide-80.pptx
whats-new-netbeans-ide-80.pptxwhats-new-netbeans-ide-80.pptx
whats-new-netbeans-ide-80.pptx
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3
 
Java SE 8
Java SE 8Java SE 8
Java SE 8
 
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Ora...
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
 
Java ee7 1hour
Java ee7 1hourJava ee7 1hour
Java ee7 1hour
 
GlassFish BOF
GlassFish BOFGlassFish BOF
GlassFish BOF
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
Java EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e MudançasJava EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e Mudanças
 
Functional Programming With Lambdas and Streams in JDK8
 Functional Programming With Lambdas and Streams in JDK8 Functional Programming With Lambdas and Streams in JDK8
Functional Programming With Lambdas and Streams in JDK8
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
 
Functional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterFunctional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritter
 
WebSockets: um upgrade de comunicação no HTML5
WebSockets: um upgrade de comunicação no HTML5WebSockets: um upgrade de comunicação no HTML5
WebSockets: um upgrade de comunicação no HTML5
 
What's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverWhat's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - Weaver
 
Apouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-futureApouc 2014-java-8-create-the-future
Apouc 2014-java-8-create-the-future
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
 

Plus de Bruno Borges

Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Bruno Borges
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Bruno Borges
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Bruno Borges
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Bruno Borges
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Bruno Borges
 

Plus de Bruno Borges (20)

Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes[Outdated] Secrets of Performance Tuning Java on Kubernetes
[Outdated] Secrets of Performance Tuning Java on Kubernetes
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
 
Making Sense of Serverless Computing
Making Sense of Serverless ComputingMaking Sense of Serverless Computing
Making Sense of Serverless Computing
 
Visual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring DevelopersVisual Studio Code for Java and Spring Developers
Visual Studio Code for Java and Spring Developers
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure Cloud
 
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
A Look Back at Enterprise Integration Patterns and Their Use into Today's Ser...
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na Nuvem
 
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na NuvemTecnologias Oracle em Docker Containers On-premise e na Nuvem
Tecnologias Oracle em Docker Containers On-premise e na Nuvem
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
Migrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFXMigrating From Applets to Java Desktop Apps in JavaFX
Migrating From Applets to Java Desktop Apps in JavaFX
 
Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?Servidores de Aplicação: Por quê ainda precisamos deles?
Servidores de Aplicação: Por quê ainda precisamos deles?
 
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
Build and Monitor Cloud PaaS with JVM’s Nashorn JavaScripts [CON1859]
 
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
Cloud Services for Developers: What’s Inside Oracle Cloud for You? [CON1861]
 
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
Booting Up Spring Apps on Lightweight Cloud Services [CON10258]
 
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
Java EE Application Servers: Containerized or Multitenant? Both! [CON7506]
 
Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]Running Oracle WebLogic on Docker Containers [BOF7537]
Running Oracle WebLogic on Docker Containers [BOF7537]
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the Cloud
 
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFXTweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
Tweet for Beer - Beertap Powered by Java Goes IoT, Cloud, and JavaFX
 
Integrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSocketsIntegrando Oracle BPM com Java EE e WebSockets
Integrando Oracle BPM com Java EE e WebSockets
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Novidades do Java SE 8

  • 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132 Lambda, Nashorn, Metaspace: algumas novidades do Java SE 8 Bruno Borges Oracle Product Manager Java Evangelist @brunoborges
  • 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133 Bruno Borges Oracle Product Manager / Evangelist Desenvolvedor, Gamer, Beer Sommelier Entusiasta em Java Embedded e JavaFX Twitter: @brunoborges
  • 3. 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 16 Agenda  História  Scene Graph  Java API  Properties  Bindings  Controls  CSS  WebView  JFXPanel  Charts
  • 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135 SE8
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136 Um pouco da história  Green Team, C++ ++ –, Oak - 1990  Java 1.0 / 1.1 – 1996 / 1997  Java 2 “J2SE” 1.2 – 1998  Java 1.3 ”J2SE 1.3” – 2000  Java 1.4 ”J2SE 1.4” – 2002  Java 1.5 “Java SE 5” - 2004  Java 1.6 “Java SE 6” - 2006  Java 1.7 “Java SE 7” - 2011
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137 E o futuro...
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138 E o JavaFX? É o sucessor do Java Swing
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139 Disponível para...  Windows, Linux, Mac OS X  E em Preview...  ARM*  Apple iOS*  Android*  JavaFX 2.2 vem junto com JDK 7u6+  Standalone para Java 6
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310 OpenJFX JavaFX open sourced! http://openjdk.java.net/projects/openjfx/
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 Java SE 8  Melhorias em interfaces
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312 Java SE 8 – Melhorias em Interfaces  Static methods  Métodos com implementação default  Functional Interfaces  toda interface que define apenas 1 método abstrato (sem corpo)  @FunctionalInterface: similar a @Override, para garantia public default void forEach(Consumer<? super T> action) { Objects.requireNonNull(action); for (T t : this) { action.accept(t); } }
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 Java SE 8  Melhorias em interfaces  Lambdas
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314 Java SE 8 – Lambdas  Lista de inputs tipados à esquerda, bloco com retorno à direita  Input à esquerda, void à direita  Métodos estáticos e de objetos como funções lambda (int x, int y) -> { return x + y; } (x, y) -> x + y x -> x * x () -> x x -> { System.out.println(x); } String::valueOf x -> String.valueOf(x) Object::toString x -> x.toString() x::toString () -> x.toString() ArrayList::new () -> new ArrayList<>()
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315 Java SE 8 – Lambdas (cont.)  Em busca de um match para saber qual construtor/método chamar  O método compare precisa de dois parâmetros, e deve retornar int. A expressão lambda condiz com esta assinatura, logo a expressão é válida  Expressões não devem modificar variáveis definidas fora do corpo lambda Comparator<String> c = (a, b) -> Integer.compare(a.length(), b.length()); int count = 0; List<String> strings = Arrays.asList("a", "b", "c"); strings.forEach(s -> { count++; // error: can't modify the value of count });
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316 Java SE 8 – Lambdas (cont.)  Classes abstratas não podem ser instanciadas com lambda  poderia esconder código (construtor por exemplo)  elimina possibilidade de otimizações futuras  Solução: factory methods Ordering<String> order = (a, b) -> ...; CacheLoader<String, String> loader = (key) -> ...; Ordering<String> order = Ordering.from((a, b) -> ...); CacheLoader<String, String> loader = CacheLoader.from((key) -> ...);
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317 Java SE 8 – Lambdas (cont.)  Novos pacotes:  java.util.stream: suporta operações em valores de stream, com expressões lambda  java.util.function: interfaces funcionais utilitárias do JDK int sumOfWeights = blocks.stream().filter(b -> b.getColor() == RED) .mapToInt(b -> b.getWeight()) .sum(); // In Java 7: foo(Utility.<Type>bar()); Utility.<Type>foo().bar(); // In Java 8: foo(Utility.bar()); Utility.foo().bar();
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318 Java SE 8 – Lambdas: Antes e Depois public void emailDraftees(List<Person> pl) { for(Person p : pl){ if (p.getAge() >= 18 && p.getAge() <= 25 && p.getGender() == Gender.MALE) { roboEmail(p); } } }
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319 Java SE 8 – Lambdas: Antes e Depois public void emailDraftees(List<Person> pl) { for(Person p : pl) { if (isDraftee(p)) { roboEmail(p); } } } public boolean isDraftee(Person p){ return p.getAge() >= 18 && p.getAge() <= 25 && p.getGender() == Gender.MALE; }
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320 Java SE 8 – Lambdas: Antes e Depois Predicate<Person> draftees; draftees = p -> p.getAge() >= 18 && p.getAge() <= 25 && p.getGender() == Gender.MALE; robo.emailContacts(pl, allDraftees); public void emailContacts(List<Person> pl, Predicate<Person> pred) { for(Person p : pl) if (pred.test(p)) roboEmail(p); }
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 Java SE 8  Melhorias em interfaces  Lambdas  Generics
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322 Java SE 8 – Generics  Inferência de tipos genéricos // In Java 7: foo(Utility.<Type>bar()); Utility.<Type>foo().bar(); // In Java 8: foo(Utility.bar()); Utility.foo().bar();
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 Java SE 8  Melhorias em interfaces  Lambdas  Generics  Date and Time API
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324 Java SE 8 – Date and Time  Mudança total da API para lidar com data, hora, calendário  Baseado no JodaTime – JSR 310  Novas classes:  LocalDateTime, LocalDate, LocalTime  Year, YearMonth, Month, MonthDay, DayOfWeek  Instant, ZonedDateTime, OffsetTime, Duration, Period
  • 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 Java SE 8  Melhorias em interfaces  Lambdas  Generics  Date and Time API  Outras APIs
  • 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326 Java SE 8 – Outras mudanças de API  Reflection API  Manipular lambdas, anotações, etc  Annotations  Permite definir anotação no tipo genérico  Novos métodos em IO/NIO (busca recursiva de arquivo/diretorio)  Concurrency API  Collections API List<@Nullable String>
  • 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327 DEMO Antes e depois do Java SE 8
  • 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328 Nashorn Javascript the right way
  • 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329 Oracle Nashorn? É o sucessor do Mozilla Rhino
  • 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1330 Nashorn  Engine de processamento da linguagem Javascript  Escrito do zero  Seguindo boas práticas  Novas técnicas e algoritmos  Atento às otimizações da JVM (ex: invokedynamic)  Projeto mantido pela Oracle, e Open Source  Incluído no OpenJDK em 21/12/12
  • 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1331 Nashorn – Diferenciais?  Maior integração com a camada Java  Integração com aplicações JavaFX  Utilizado nos componentes WebView e HTML5  Maior performance  Menor footprint de memória
  • 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1332 DEMO JavaFX usando Nashorn
  • 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1333 Metaspace Say goodbye to OutOfMemoryError
  • 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1334 Metaspace  Substitui a PermGen  Modelo já utilizado pela JVM Oracle JRockit  Por padrão, o tamanho é variável – ótimo para desenvolvimento  Em produção, deve ser limitado – novo parâmetro: -XX:MaxMetaspaceSize – parâmetros *PermGen ignorados pela VM  Dados armazenados “off-heap”  Limitado ao tamanho de memória disponível na máquina
  • 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1335 Perguntas?
  • 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1336 OBRIGADO! @brunoborges blogs.oracle.com/brunoborges
  • 36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1337 The preceding 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.
  • 37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1338