Java SE 8 - Java Technologie
Update
Update
Wolfgang Weigend
Sen. Leitender Systemberater
Java Technologie und Architektur
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
Disclaimer
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.
JDK 8
Innovation
•
Lambda JSR 335
•
Language Interoperability
•
Nashorn
Core Libraries
•
Parallel operations for core collections API‘s
Java for Everyone
•
Profiles for constrained devices
•
JSR 310 – Date & Time API‘s
•
Non-Gregorian calendars
•
Unicode 6.1
•
ResourceBundle
•
BCP47 locale matching
Client
•
Deployment enhancements
•
JavaFX 8
•
Public UI Control API
•
Java SE Embedded support
•
Enhanced HTML5 support
•
3D shapes and attributes
•
Parallel operations for core collections API‘s
•
Improvements in functionality
•
Improved type inference
General Goodness
•
JVM enhancements
•
No PermGen limitations
•
Performance Improvements
•
BCP47 locale matching
•
Globalization & Accessibility
Tools
•
Compiler control & logging
•
JSR 308 – Annotations on Java Type
•
Native app bundling
•
App Store Bundling tools
•
3D shapes and attributes
•
Printing
Security
•
Limited doPriviledge
•
NSA Suite B algorithm support
•
SNI Server Side support
•
DSA update to FIPS186-3
•
AEAD JSSE CipherSuites
Lambda Ausdrücke JSR-335
•
Functional Interfaces: “An interface with one method”
•
Gehört zum Sprachumfang von Java SE 8
−
Final Release Specification
file:///C:/Java/jsr335-final/index.html
−
http://www.oracle.com/technetwork/java/javase/downloads/index.html
−
http://www.oracle.com/technetwork/java/javase/downloads/index.html
•
Lambda Expressions (closures)
/*
(int x, int y) {return x+y; }
*/
•
Parameter Liste
→
->
Operator
→
Expression od. Statements
(String x) -> {return !x.isEmpty();}
•
Was hergeleitet werden kann, kann auch weggelassen werden
Extension Methods
•
Provide a mechanism to add new methods to existing interfaces
–
Without breaking backwards compatibility
–
Gives Java multiple inheritance of behaviour, as well as types
•
but not state!
Bringt Mehrfachvererbung und Funktionalität für Java
public interface Set<T> extends Collection<T> {
public int size();
... // The rest of the existing Set methods
public T reduce(Reducer<T> r)
default
Collections.<T>setReducer;
}
Erweiterung der Core Libraries mit Lambdas
•
Modernize general library API’s
•
Improve performance
–
Gains from use of invokedynamic to implement Lambdas
•
Demonstrate best practices for extension methods
Concurrency Updates
•
Scalable update variables
–
DoubleAccumulator
,
DoubleAdder
, etc
–
Multiple variables avoid update contention
–
Good for frequent updates, infrequent reads
•
ConcurrentHashMap
updates
•
ConcurrentHashMap
updates
–
Improved scanning support, key computation
•
ForkJoinPool
improvements
Bulk Data Operations für Collections
•
Add functionality to the Java Collections Framework for bulk
operations upon data
•
This is commonly referenced as “filter/map/reduce for Java”
•
The bulk data operations include both serial (on the calling thread)
and parallel (using many threads) versions of the operations
Filter, Map, Reduce for Java
and parallel (using many threads) versions of the operations
–
Serial and parallel implementations
•
Operations upon data are generally expressed as lambda functions
Parallel Array Sorting
•
Additional utility methods in
java.util.Arrays
–
parallelSort
(multiple signatures for different primitives)
•
Anticipated minimum improvement of 30% over sequential sort
–
For dual core system with appropriate sized data set
•
Built on top of the fork-join framework
•
Built on top of the fork-join framework
–
Uses Doug Lea’s
ParallelArray
implementation
List<Student> students = new
ArrayList
<>(...);
...
double highestScore =
students.
parallelStream
()
.
filter
(s -> s.getGradYear() == 2013)
.
map
(s -> s.getScore())
.
reduce
(0.0, Integer::max);
Lambda Ausdrücke – Parallelisiert
State of the Lambda Libraries Edition
.
reduce
(0.0, Integer::max);
−
More readable
−
Better abstraction
−
No reliance on mutable state
−
Runs in parallel
−
Works on any data structure that knows how to subdivide itself
Concurrent Bulk Data Operations in Java collections API’s (JEP 107)
Date and Time API – JSR 310
•
JEP 150 by Stephen Colebourne
•
A new date, time, and calendar API for the Java SE platform
•
Supports standard time concepts
–
Partial, duration, period, intervals
–
date, time, instant, and time-zone
–
date, time, instant, and time-zone
•
Provides a limited set of calendar systems and be extensible to others
•
Uses relevant standards, including ISO-8601, CLDR, and BCP47
Date and Time API – JSR 310
•
The main difference you will notice is that there are several different classes to represent time,
date, time period, and timezone specific data. Also there are transformers for dates and times
•
For dates and times
without a timezone
, use the following:
–
LocalDate
– Day, month, year
–
LocalTime
– Time of day only
–
LocalDateTime
– Both date and time
•
For timezone specific times you use
ZonedDateTime
New Classes
•
For timezone specific times you use
ZonedDateTime
•
Previous to Java 8
, to calculate the time eight hours in the future you would need to write
something like the following:
–
1 Calendar cal = Calendar.getInstance();
–
2 cal.add(Calendar.HOUR, 8);
–
3 cal.getTime();
// actually returns a Date
•
With Java 8
, you can more simply write the following:
–
1 LocalTime now = LocalTime.now();
Date and Time API – JSR 310
Creation
•
Creating new date and time objects is much easier and less error-prone in Java 8. Every class
has static factory methods that are easy to understand
•
For example, creating a new
LocalDate
for 17
th
of July 2014 is as simple as:
–
1 date = LocalDate.of(2014, 7, 17);
•
For
more type-safety
, you can use the new Month enum:
–
1 date = LocalDate.of(2014, Month.JULY, 17);
•
You can also easily
create a LocalDateTime
from an instance of LocalDate:
–
1 LocalTime time = LocalTime.of(23, 59, 0);
–
2 LocalDateTime datetime = date.atTime(time);
•
You could
also use any of the following methods
(on LocalDate):
–
atTime(int hour, int minute)
–
atTime(int hour, int minute, int second)
–
atTime(int hour, int minute, int second, int nanoOfSecond)
Date and Time API – JSR 310
java.time API Packages
Package
Description
java.time
The main API for dates, times, instants, and durations
java.time.chrono
Generic API for calendar systems other than the default ISO
java.time.chrono
Generic API for calendar systems other than the default ISO
java.time.format
Provides classes to print and parse dates and times
java.time.temporal
Access to date and time using fields and units, and date
time adjusters
Date and Time API – JSR 310
Basisklassen im Package java.time
Klasse
Beschreibung
Clock
A clock providing access to the current instant, date and time using a time-zone.
Duration
A time-based amount of time, such as '34.5 seconds'.
Instant
An instantaneous point on the time-line.
LocalDate
A date without a time-zone in the ISO-8601 calendar system, such as 2007-12-03.
LocalDateTime
A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.
LocalTime
A time without time-zone in the ISO-8601 calendar system, such as 10:15:30.
LocalTime
A time without time-zone in the ISO-8601 calendar system, such as 10:15:30.
MonthDay
A month-day in the ISO-8601 calendar system, such as --12-03.
OffsetDateTime
A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00.
OffsetTime
A time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as 10:15:30+01:00.
Period
A date-based amount of time in the ISO-8601 calendar system, such as '2 years, 3 months and 4 days'.
Year
A year in the ISO-8601 calendar system, such as 2007.
YearMonth
A year-month in the ISO-8601 calendar system, such as 2007-12.
ZonedDateTime
A date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.
ZoneId
A time-zone ID, such as Europe/Paris.
Larger Security Policy Areas
Communications
Deployment
Lifecycle
Architecture Review
Peer Review
Security Testing
Post Mortems
SA / CPU RSS Feeds
Security Blog
eBlasts
Java.com Security
Remediation
Security
Post Mortems
Java.com Security
CPU
Security Alerts
Java Critical Patch Updates
Rules for Java CPU’s
−
Main release for security vulnerabilities
JDK 8u20 - Security Baselines
−
Main release for security vulnerabilities
−
Covers all JDK families (8, 7, 6, 5.0)
−
CPU release triggers Auto-update
−
Dates published 12 months in advance
−
Security Alerts are released as necessary
−
Based off the previous (non-CPU) release
−
Released simultaneously on java.com and OTN
JRE Family Version
JRE Security Baseline
(Full Version String)
8
1.8.0_11
7
1.7.0_65
6
1.6.0_81
5.0
1.5.0_71
Java Security Resource Center
What’s new
•
New Secure Coding Guidelines
•
Java 8 Security Enhancements
•
JavaOne 2014 Java Security Track
•
Manage multiple versions on client systems
•
Exception Site List and Deployment Rule Set
•
Exception Site List and Deployment Rule Set
•
RIA Checklist
•
OpenJDK Security Group Information
•
Security for Developers
•
Information gathering
−
Instrumentation calls all over the JVM
−
Application information via Java API
•
Collected in Thread Local buffers
⇢
Global Buffers
⇢
Disk
Java Flight Recorder – How is it built?
⇢
Global Buffers
⇢
Disk
•
Binary, proprietary file format
•
Managed via JMX
•
Java Flight Recorder
−
Start from JMC 5.3 or CLI
•
Activate Flight Recorder
−
-XX: +UnlockCommercialFeatures
−
-XX: +FlightRecorder
Java Advanced Management Console
Build for managing the Java clients in enterprises
Automatically tracks Java applet and Java web Start application usage
Enables management of deployment rules
Deployment Rule Sets - Desktop Administrators can control multiple Java versions
•
Lots of managed clients
•
Different applications need different Java versions
•
Different applications need different Java versions
•
and different users need several at once
•
Mitigate risk of security by limiting the exposure of old versions
Controlling Compatibility with Deployment Rule Sets
•
This application needs JDK 8u20, that needs JDK 6u38, those need JDK 7u40
Blocking Applications with Deployment Rules
JavaFX via Open Source im JDK 8
Open Source
OpenJFX Project under
OpenJDK
Übergang
Common license with
Java SE
Standardisierung
Oracle committed to
JavaFX standardization
OpenJDK
First phase to focus on
UI Controls
Java SE
JavaFX included in
Java SE with JDK 8
JavaFX for Java SE
Embedded (ARM)
JavaFX standardization
JSR to be submitted
through JCP and JSR
expected for JDK 9
JavaFX ist die strategische Java-UI-Technologie
für Rich-Client-Anwendungen
Einheitliche Applikationsentwicklung für Java- und Web-Anwendungen
•
Browser Plug-in, Web Start, Native Executables
•
Hardware Accelerated Graphics (DirectX, OpenGL)
•
JavaFX wird mit HTML-DOM ausgestattet
−
JavaFX mit WebView für HTML5 Features (Web Sockets, offline Browsing, lokale Datenbank)
−
Leistungsfähige JavaScript Engine
−
JavaFX als Applet eingebettet in einer Web-Seite lauffähig
JavaFX 2.0 Plattform Sprachwechsel vollzogen
•
Java als native Sprache - anstatt JavaFX Script
•
JavaFX APIs in Java implementiert
•
Vorteile bei Verwendung von Generics, Annotations und Multithreading für JavaFX
JavaFX 8 im JDK 8 enthalten und mit NetBeans 8 unterstützt
•
Migrationspfad für Swing- und SWT-basierte Anwendungen
•
JFXPanel Komponente ermöglicht das Einbinden von JavaFX Anwendungen in Swing
•
Open Source mit OpenJFX und im JCP standardisiert
JavaFXPorts: JavaFX on Mobile and Tablets
Package your JavaFX Application for deployment on iOS and Android
•
JavaFX on client, desktop, laptop and embedded systems
•
JavaFX on mobile and tablets
•
Why is a port needed? - Isn't Java Write Once Run Anywhere?
OpenJDK
Compact-Profile für festgelegten Speicherbedarf
RI Binaries under the GNU General
Public License version 2 and
under the Oracle Binary Code License
under the Oracle Binary Code License
•
Compact Profile 1
(13.8 MB)
•
Compact Profile 2
(17.5 MB)
Compact1 Profil
Compact2 Profil
Compact3 Profil
Vollständige JRE
java.lang
java.sql
java.lang.management
java.applet
java.io
jvax.sql
javax.management
java.awt
java.nio
javax.xml
javax.naming
java.beans
java.text
org.w3c.dom
java.sql.rowset
javax.activity
java.math
org.xml.sax
javax.security.auth.kerberos
javax.rmi
java.net
java.rmi
org.ietf.jgss
javax.rmi.CORBA
javax.net
javax.rmi
javax.script
org.omg
java.util
javax.transaction
javax.xml.crypto
javax.accessibility
Compact-Profile mit Packages
java.util
javax.transaction
javax.xml.crypto
javax.accessibility
java.util.logging
java.util.prefs
javax.imagio
java.security
javax.security.sasl
javax.print
javax.crypto
javax.security.acl
javax.sound
javax.security
javax.lang.instrument
javax.swing
javax.annotation.processing
javax.activation
javax.lang.model
javax.jws
javax.lang.model.element
javax.lang.model.type
javax.lang.model.util
javax.tools
javax.xml.bind
javax.xml.soap
javax.xml.ws
javax.annotation
Compact-Profile – Neue Option für „javac“
•
New “javac” option
‒
javac -target 8 -profile
Profile
‒
The javac compiler will verify java code against APIs available in profile
‒
$ javac -profile compact1 Hello.java
•
New “jar” option
•
New “jar” option
‒
jar -profile
Profile
‒
Marks jar file with minimum required profile
‒
Main application jar file defines default minimum profile
•
Runtime verification of profile
‒
jar files will be validated at startup to ensure minimum profile is running
Der Weg zur polyglotten VM:
Sprachen die auf der JVM laufen
Groovy
JRuby
…
…
…
Scala
Clojure
JavaScript
Project Nashorn
•
Lightweight, high-performance JavaScript engine
−
Integrated into JRE
•
ECMAScript 5.1 compliant JavaScript that runs on the JVM
−
Accessible via
javax.script
API or
jjs
command line
•
Replacement for Rhino
•
Exploits JSR-292 via Dynalink
•
Fully part of the OpenJDK
•
Available on Java SE and Java ME
Project Nashorn Leistungsfähigkeit
‒
Test app executes Esprima parser and tokenizer
bitbucket.org/ariya/nashorn-speedtest
‒
Rhino gets the first chance, Nashorn follows right after, each engine gets 30 runs
In the beginning, Rhino’s first run is 2607 ms and slowly it speeds up and finally this parsing is completed in just 824 ms
‒
Nashorn timings have a different characteristic
When it is cold, Nashorn initially takes 5328 ms to carry out the operation but it quickly picks up the pace and imediate,
it starts moving full steam ahead, reaching 208 ms per run
‒
Nashorn compiles JavaScript code into Java bytecodes and run them on the JVM itself
‒
Nashorn compiles JavaScript code into Java bytecodes and run them on the JVM itself
Nashorn is taking advantage of invokedynamic instruction to permit "efficient and flexible execution" in a dynamic
environment such as JavaScript
Project Nashorn
Java SE Roadmap
JDK 9
•
Jigsaw
•
Interoperability
•
Optimizations
•
Cloud
•
Ease of Use
•
JavaFX JSR
JDK 7u40/45/51/55
•
Java Flight Recorder
in JDK
•
Native Memory
Tracking
•
Java Discovery
Protocol
•
App Store Packaging
Tools
JDK 8 GA18
th
of March 2014
•
Lambda
•
Complete JVM Convergence
•
JavaScript Interoperability
•
JavaFX 8
−
Public UI Control API
−
Java SE Embedded support
−
Enhanced HTML5 support
JDK 8.1 (Q3 2014)
•
Deterministic G1
•
JMC 6
•
Improved JRE
installer
•
Japp bundling
enhancements
JDK 7u21
•
Java Client
Security
Enhancements
JDK 8.2
2013
2014
NetBeans IDE 9
•
JDK 9 support
•
Scene Builder 3.0 support
Scene Builder 3.0
2016
•
Scene Builder support
NetBeans IDE 7.3
•
New hints and refactoring
•
Scene Builder support
Tools
NetBeans IDE 8
•
JDK 8 support
•
Scene Builder 2.0 support
Scene Builder 2.0
•
JavaFX 8 support
Scene Builder 1.1
JDK 8 Update 40 Early Access Release
•
8u40 Build b02
https://jdk8.java.net/download.html
Feedback forum
Report Bugs
•
Changes in JDK 8u40 Build b02
•
Changes in JDK 8u40 Build b02
http://hg.openjdk.java.net/jdk8u/jdk8u40/hotspot
•
These early access release downloads of the JRE and JDK are based on code
available on OpenJDK at the time they were built and might not include the latest
security patches
Zusammenfassung
•
Java SE 8 enthält neue Funktionalität
–
Language
–
Libraries
–
JVM
–
JVM
•
Java entwickelt sich kontinuierlich weiter
–
jdk8.java.net
–
www.jcp.org
Danke!