java8-features

1,008 views

Published on

Java SE 8 Präsentation im Rahmen der JUG Bielefeld am 12.03.2014.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,008
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
18
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

java8-features

  1. 1. Java SE 8 Features Neuerungen in Java SE 8 pr sentiert von Sascha Kochä 12. M rz 2014ä JUG Bielefeld
  2. 2. 12.03.2014 Java SE 8 Alle freuen sich auf Java 8 Quelle www.heise.de
  3. 3. 12.03.2014 Java SE 8 Programm f r heute abendü ● > 50 Neuerungen in Java SE 8 ● Hands-on Session mit λ-Expressions, der Stream API, den default methods und mehr
  4. 4. 12.03.2014 Java SE 8 Java 8 JEPs General ● 126 Lambda Expressions & Virtual Extension Methods (aka defender or default methods) ● 138 Autoconf-Based Build System (for the jdk itself) ● 160 Lambda-Form Representation for Method Handles (reduce assembly code and native calls, performance optimization, reference implementation of invokedynamic / JSR-292) ● 161 Compact Profiles (instead of jigsaw 140/24/17/10 MB)→ ● 162 Prepare for Modularization (getting ready for jigsaw, java.util.logging and swing)
  5. 5. 12.03.2014 Java SE 8 Java 8 JEPs General ● 164 Leverage CPU Instructions for AES Cryptography (Intel M rz 2008)ä ● 174 Nashorn JavaScript Engine (lightweight, high-performance, ECMAScript-262 5.1) ● 176 Mechanical Checking of Caller-Sensitive Methods (improve security of method-handle implementation, behaviour changed based on the caller) ● 179 Document JDK API Support and Stability (mark core and non-core APIs, what is maintained?)
  6. 6. 12.03.2014 Java SE 8 Java 8 JEPs Core ● 153 Launch JavaFX Applications (launch() from java cmd line) ● 101 Generalized Target-Type Inference Code (only partly realized) ● 104 Annotations on Java Types Code (applied to any use of a type, not at runtime :( ) ● 105 DocTree API (provide structured access to javadoc content) ● 106 Add Javadoc to javax.tools (call javadoc from within vm)
  7. 7. 12.03.2014 Java SE 8 Java 8 JEPs Core ● 117 Remove the Annotation-Processing Tool (in javac) ● 118 Access to Parameter Names at Runtime Code (partly realized) ● 120 Repeating Annotations Code (avoid container annotations, somehow) ● 139 Enhance javac to Improve Build Speed (use of all available cores) ● 172 DocLint Code (static doc analysis, Fusselig, W3C HTML 4.01 HTML conform)
  8. 8. 12.03.2014 Java SE 8 Java 8 JEPs Garbage Collection ● 142 Reduce Cache Contention on Specified Fields (pad variables to avoid sharing cache lines) ● 122 Remove the Permanent Generation (Permanently, PermGen moves to native memory) ● 173 Retire Some Rarely-Used GC Combination (e.g. ParNew + SerialOld, reduce testing effort)
  9. 9. 12.03.2014 Java SE 8 Java 8 JEPs Garbage Collection ● 142 Reduce Cache Contention on Specified Fields (pad variables to avoid sharing cache lines) ● 122 Remove the Permanent Generation (Permanently, PermGen moves to native memory) ● 173 Retire Some Rarely-Used GC Combination (e.g. ParNew + SerialOld, reduce testing effort)
  10. 10. 12.03.2014 Java SE 8 Java 8 JEPs Runtime ● 136 Enhanced Verification Errors (additional information bytecode verification errors) ● 147 Reduce Class Metadata Footprint (taken from ME) ● 148 Small VM (libjvm.so < 3MB, compiling size over speed) ● 171 Fence Intrinsics (sun.misc.Unsafe, memory access)
  11. 11. 12.03.2014 Java SE 8 Java 8 JEPs Core Libraries ● 103 Parallel Array Sorting (new methods in java.util.Arrays) ● 107 Bulk Data Operations for Collections (java.util.function, java.util.stream) ● 109 Enhance Core Libraries with Lambda (Java SE 7 has 4024 standard classes) ● 112 Charset Implementation Improvements (fewer, quicker, better) ● 119 javax.lang.model Implementation Backed by Core Reflection
  12. 12. 12.03.2014 Java SE 8 Java 8 JEPs Core Libraries ● 135 Base64 Encoding & Decoding (previously in sun.misc.*, now java.util.*) ● 149 Reduce Core-Library Memory Usage (reduce dynamic memory) ● 150 Date & Time API (Wurde auch Zeit!) ● 155 Concurrency Updates (Doug Lea Stuff) ● 170 JDBC 4.2 (new Date API support)
  13. 13. 12.03.2014 Java SE 8 How many Bugs? Date date = new Date(2014, 12, 24, 16, 40); TimeZone zone =    TimeZone.getTimeZone(“Asia/HongKong”); Calendar cal =     new GregorianCalendar(date, zone); DateFormat fm =     new SimpleDateFormat(“HH:mm Z”); String str = fm.format(cal);
  14. 14. 12.03.2014 Java SE 8 How many Bugs? 6! Date date = new Date(114, 11, 24, 16, 40); TimeZone zone =    TimeZone.getTimeZone(“Asia/Hong_Kong”); Calendar cal = new GregorianCalendar(zone); cal.setTime(date); DateFormat fm =     new SimpleDateFormat(“HH:mm Z”); fm.setTimeZone(zone); Date calDate = cal.getTime(); String str = fm.format(calDate);
  15. 15. 12.03.2014 Java SE 8 Java 8 JEPs Diverses ● 177 Optimize java.text.DecimalFormat.format (2 x faster for 2 or 3 digits after decimal point) ● 178 Statically-Linked JNI Libraries (previously only dynamically linked) ● 180 Handle Frequent HashMap Collisions with Balanced Trees (performance improvement, previously with linked lists) ●
  16. 16. 12.03.2014 Java SE 8 Java 8 JEPs Diverses ● 127 Improve Locale Data Packaging and Adopt Unicode CLDR Data (standardized locale support) ● 128 BCP 47 Locale Matching (as defined in rfc-4647) ● 133 Unicode 6.2 ● 184 HTTP URL Permissions (previously based on IP addresses)
  17. 17. 12.03.2014 Java SE 8 Java 8 Security ● 113 MS-SFU Kerberos 5 Extensions (Microsoft interoperability) ● 114 TLS Server Name Indication (SNI) Extension (new feature) ● 115 AEAD CipherSuites (meet US government and banking requirements) ● 121 Stronger Algorithms for Password-Based Encryption (evolution of cryptography, PBEwith*, previously DESede and RC2 with SHA1) ● 123 Configurable Secure Random-Number Generation (/dev/random Entropie unter Linux ist alle)→ ● 124 Enhance the Certificate Revocation-Checking API (more complete,flexible)
  18. 18. 12.03.2014 Java SE 8 Java 8 Security ● 129 NSA Suite B Cryptographic Algorithms (meet US government and banking requirements) ● 130 SHA-224 Message Digests (known flaw in SHA-1) ● 131 PKCS#11 Crypto Provider for 64-bit Windows (use of native Win64 libraries) ● 140 Limited doPrivileged (Lambda expressions) ● 166 Overhaul JKS-JCEKS-PKCS12 Keystores (simplification of keystore handling)
  19. 19. 12.03.2014 Java SE 8 Java 8 JEPs / Web JAXP ● 185 JAXP 1.5: Restrict Fetching of External Resources (restrict the set of network protocols used to fetch external resources)
  20. 20. 12.03.2014 Java SE 8 Lambda Expressions ● Aka closures, function literals or Lambdas ● From anonymous inner classes to FunctionalInterfaces; previously known as SAM (single abstract method) ● Syntax: 1. argument list enclosed in parentheses 2. an arrow token ( )→ 3. a function body
  21. 21. 12.03.2014 Java SE 8 Default methods ● Interfaces can have default implementations ● Method starts with default
  22. 22. 12.03.2014 Java SE 8 Lambda form representation method handles ● object::instanceMethod Arrays.asList(0, -2, 2).forEach(System.out::println); Arrays.asList(0, -2, 2).forEach((x) System.out.println(x));→ → ● Class::staticMethod Arrays.asList(0, -2, 2).sort(Integer::compare); Arrays.asList(0, -2, 2).sort((x, y) Integer.compare(x, y));→ → ● Class::instanceMethod Arrays.asList(0, -2, 2).sort(Integer::compareTo); Arrays.asList(0, -2, 2).sort((x, y) x.compareTo(y));→ →
  23. 23. 12.03.2014 Java SE 8 Collection vs Stream Quelle: wikimedia.org
  24. 24. 12.03.2014 Java SE 8 Stream-API ● Get a stream from a collection collection<E>.stream(); ● Generate, limit and skip a stream Stream.generate(Supplier<T> s) // static stream<T>.limit(long) stream<T>.skip(long) ● Manipulate a stream stream<T>.map(Function<T, R>) Stream<R>→ stream<T>.filter(Predicate<T>) Stream<T>→ stream<T>.sorted() Stream<T>→ stream<T>.distinct() Stream<T>→
  25. 25. 12.03.2014 Java SE 8 Stream-API ● “Collection a result” of a stream stream<T>.allMatch(Predicate<T>) boolean→ stream<T>.anyMatch(Predicate<T>) boolean→ stream<T>.findAny() Optional<T>→ stream<T>.findFirst() Optional<T>→ stream<T>.max(Comparator<T>) Optional<T>→ stream<T>.min(Comparator<T>) Optional<T>→ stream<T>.reduce(T, BinaryOperator<T>) T→ stream<T>.collect(T, A, R) R→
  26. 26. 12.03.2014 Java SE 8 Stream-API ● Default Collectors Collectors.toList() Collector<T, ?, List<T>>→ Collectors.reducing(T, BinaryOperator<T>) T→ Collectors.joining() Collector<CharSeq, ?, String>→ Collectors.counting() Collector<T, ?, Long>→
  27. 27. 12.03.2014 Java SE 8 Danke!
  28. 28. 12.03.2014 Java SE 8 Referenzen ● http://www.youtube.com/watch?v=rtAredKhyac, Simon Ritter ● Java SE 8 for the Really Impatient, Cay S. Horstmann ● Java 8 in Action, Raoul-Gabiel Urma et.al ● http://openjdk.java.net/projects/jdk8/features

×