(Microsoft PowerPoint - Innovation als Antriebsfeder f\374r Java

Werbung
Innovation als Antriebsfeder
für Java – Wie sich die Java
Plattform erneuert
Wolfgang Weigend
Sen. Leitender Systemberater
Java Technologie und Architektur
1
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Disclaimer
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.
2
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Java SE 8 – Key Themes and Features
3
Themes
• Revolutionary Java SE 8 release – Most significat upgrade to the Java
programming model ever
• Enhanced developer productivity and significant application performance
increases
Key
Features
• Lambda Expressions – closures and functional programming
• Annotation on Java Types
• Date & Time API‘s
• Nashorn JavaScript engine
• Compact Profiles
Benefits
• Better developer productivity; More reliable code
• Better utilization of multi-core and multi-processor systems
• Code is no longer inherently serial or parallel
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
JDK 8
Innovation
Java for Everyone
Client
• Lambda JSR 335
• Profiles for constrained devices
• Deployment enhancements
• Language Interoperability
• JSR 310 – Date & Time API‘s
• JavaFX 8
• Nashorn
• Non-Gregorian calendars
• Public UI Control API
• Unicode 6.1
• Java SE Embedded support
• ResourceBundle
• Enhanced HTML5 support
• BCP47 locale matching
• 3D shapes and attributes
• Globalization & Accessibility
• Printing
Tools
Security
• Compiler control & logging
• Limited doPriviledge
Core Libraries
• Parallel operations for core collections API‘s
• Improvements in functionality
• Improved type inference
General Goodness
• JVM enhancements
• No PermGen limitations
• Performance Improvements
4
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
• JSR 308 – Annotations on Java Type • NSA Suite B algorithm support
• Native app bundling
• SNI Server Side support
• App Store Bundling tools
• 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
• 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
x -> !x.isEmpty()
5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Extension Methods
Bringt Mehrfachvererbung und Funktionalität für Java
• 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!
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;
}
6
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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
7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Concurrency Updates
• Scalable update variables
– DoubleAccumulator, DoubleAdder, etc
– Multiple variables avoid update contention
– Good for frequent updates, infrequent reads
• ConcurrentHashMap updates
– Improved scanning support, key computation
• ForkJoinPool improvements
– Completion based design for IO bound applications
8
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Bulk Data Operations für Collections
Filter, Map, Reduce for Java
• 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
– Serial and parallel implementations
• Operations upon data are generally expressed as lambda functions
• Parallel implementation builds on Fork-Join framework
9
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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
– Uses Doug Lea’s ParallelArray implementation
– Requires working space the same size as the array being sorted
10
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Lambda Ausdrücke – Parallelisiert
State of the Lambda Libraries Edition
List<Student> students = new ArrayList<>(...);
...
double highestScore =
students.parallelStream()
.filter(s -> s.getGradYear() == 2013)
.map(s -> s.getScore())
.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)
− filter/map/reduce
11
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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
• Provides a limited set of calendar systems and be extensible to others
• Uses relevant standards, including ISO-8601, CLDR, and BCP47
• Based on an explicit time-scale with a connection to UTC
12
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Date and Time API – JSR 310
New Classes
• 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
• 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();
– 2 LocalTime later = now.plus(8, HOURS);
13
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Quelle: https://leanpub.com/whatsnewinjava8/read#leanpub-auto-new-date-and-time-api
Larger Security Policy Areas
SA / CPU RSS Feeds
Security Blog
eBlasts
Java.com Security
Communications
Deployment
Lifecycle
Architecture Review
Peer Review
Security Testing
Post Mortems
Security
Remediation
14
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
CPU
Security Alerts
Java Critical Patch Updates
Rules for Java CPU’s
− 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
15
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
JDK8u5 - Security Baselines
JRE Family Version
JRE Security Baseline
(Full Version String)
8
1.8.0_5
7
1.7.0_55
6
1.6.0_75
5.0
1.5.0_65
Enhanced Certificate Revocation-Checking API
• Current java.security.cert API is all-or-nothing
– Failure to contact server is a fatal error
• New classes
– RevocationChecker
– RevocationParameters
16
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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
RIA Checklist
OpenJDK Security Group Information
Security for Developers
• http://www.oracle.com/technetwork/java/javase/overview/security-2043272.html
17
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Java Mission Control 5.3
18
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Java Flight Recorder – How is it built?
• Information
gathering
− Instrumentation calls all over the JVM
− Application information via Java API
• Collected
in Thread Local buffers
⇢ 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
19
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
JavaFX via Open Source im JDK 8
Open Source
Übergang
Standardisierung
OpenJFX Project under Common license with
Oracle committed to
JavaFX standardization
First phase to focus on JavaFX included in
JSR to be submitted
through JCP
OpenJDK
UI Controls
Java SE
Java SE with JDK 8
JavaFX for Java SE
Embedded (ARM)
20
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
JavaFX goes Open Source
iOS- und Android-Implementierungen
• iOS- und Android-Implementierungen sind Open Source
• Lizensierung mit eigenem Applikations-Co-Bundle
21
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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
http://javafxports.org/page/home
22
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Compact-Profile für festgelegten Speicherbedarf
RI Binaries under the GNU General
Public License version 2 and
under the Oracle Binary Code License
• Compact Profile 1 (13.8 MB)
• Compact Profile 2 (17.5 MB)
• Compact Profile 3 (19.5 MB)
23
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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
‒ 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
• “java -version” will report active profile
24
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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
• Nashorn - Der Weg zur polyglotten VM
25
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
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 is taking advantage of invokedynamic instruction to permit "efficient and flexible execution" in a dynamic
environment such as JavaScript
mytext
26
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Quelle: http://ariya.ofilabs.com/2014/03/nashorn-the-new-rhino-on-the-block.html
Project Nashorn
Invokedynamic Bytecode und „MethodHandle“
27
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Java SE Roadmap
JDK 7u21
JDK 7u40/45/51/55
JDK 8 GA18th of March 2014
JDK 8.1 (Q3 2014)
• Java Client
Security
Enhancements
• Java Flight Recorder
in JDK
• Lambda
• Deterministic G1
• Jigsaw
• Native Memory
Tracking
• Complete JVM Convergence
• JMC 6
• Interoperability
• JavaScript Interoperability
• Improved JRE
installer
• Optimizations
• Japp bundling
enhancements
• Ease of Use
• Java Discovery
Protocol
• JavaFX 8
− Public UI Control API
− Java SE Embedded support
• App Store Packaging
Tools
JDK 9
• Cloud
• JavaFX JSR
− Enhanced HTML5 support
2014
2013
JDK 8.2
2015
2016
NetBeans IDE 7.3
NetBeans IDE 8
NetBeans IDE 9
• New hints and refactoring
• Scene Builder support
• JDK 8 support
• Scene Builder 2.0 support
• JDK 9 support
• Scene Builder 3.0 support
Scene Builder 1.1
• Linux support
28
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Scene Builder 2.0
• JavaFX 8 support
• Enhanced Java IDE support
Scene Builder 3.0
• JavaFX 9 support
Zusammenfassung
• Java SE 8 enthält neue Funktionalität
– Language
– Libraries
– JVM
• Java entwickelt sich kontinuierlich weiter
– jdk8.java.net
– www.jcp.org
– openjdk.java.net/jeps
29
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
Vielen Dank!
[email protected]
Twitter:
30
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.
@wolflook
Herunterladen