Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Prepare for JDK 9! by Dalibor Topic

Riga Dev Day
March 13, 2016
110

Prepare for JDK 9! by Dalibor Topic

Riga Dev Day

March 13, 2016
Tweet

Transcript

  1. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Prepare for JDK 9! The JEPs Are Coming Dalibor Topić Principal Product Manager Java Platform Group @ Oracle March 2nd, 2015 – Riga Dev Day
  2. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Safe Harbor Statement 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. 3
  3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | “plus ça change, plus c'est la même chose” – Jean-Baptiste Alphonse Karr (1808-1890) 4 Image Credit: "Alphonse Karr". Licensed under Public Domain via Commons - https://commons.wikimedia.org/wiki/File:Alphonse_Karr.jpg#/media/File:Alphonse_Karr.jpg
  4. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Legend 5 The change is not yet (or is not complete) on the latest JDK 9 EA The change is already in on the latest JDK 9 EA As of early Feb 2016
  5. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | JEP 260: Encapsulate most internal APIs • The vast majority of internal APIs are inaccessible by default in JDK 9 • A handful of critical, widely used internal APIs like sun.misc.Unsafe without good alternatives remain accessible by default in JDK 9 – until supported replacements exist for all or most of their functionality • Preparation: – jdeps tool can help identify programs that might be impacted • jdeps from JDK 9 EA is more up to date – Multi-Release JAR files (JEP 238) allow Java-release-specific versions of a class to coexist in a single JAR file – A command line flag would provide access to encapsulated APIs as a last resort 7
  6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | JEP 223: New Version String Scheme • New version string is closer to Semantic-Versioning and drops some long kept baggage (e.g the “1.” in front, the use of “u” for updates) • Contents of Java version related system properties change as well • Preparation: – Test version string checking code • Common sources of surprise: GA version string is „9“ instead of „9.0.0“, or „1.9.0“ – Version string checking code targeting both JDK 9 and earlier versions will have to deal with both “old” and “new” version string formats 8 $MAJOR.$MINOR.$SECURITY
  7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | New version-string format : Hypothetical Examples Release type Old format Long form Old format Short form New format Long form New format Short form Early Access 1.9.0-ea-b19 9-ea -> 9-ea+19 9-ea Major 1.9.0-b100 9 -> 9+100 9 CPU 1.9.0_5-b20 9u5 -> 9.0.1+20 9.0.1 Minor 1.9.0_20-b62 9u20 -> 9.1.2+62 9.1.2 9
  8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | JEP 220: Modular Run-Time Images • Internal structure of the installed JDK has changed – Due to usage of modules instead of JAR files • Directory structures and filenames inside the JDK installation have changed • Preparation: – Check if your code assumes a specific layout of the JDK installation – Use new jrt URI scheme to access modules, classes, and resources stored in a run- time image • jrt:/java.base/java/lang/Class.class • jrt:/jdk.crypto.ec • Use jrt-fs.jar with JDK 8 10 Removed: rt.jar and tools.jar
  9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Remove most sun.misc.* and sun.reflect.* APIs • In order to keep critical APIs without a replacement accessible by default sun.misc and sun.reflect will not be hidden and a few APIs kept “public” – sun.misc.Unsafe – sun.misc.{Signal,SignalHandler} – sun.reflect.Reflection::getCallerClass – sun.reflect.ReflectionFactory • All other APIs in these packages (e.g. sun.misc.Base64) will be removed 12 Except for a few called out in JEP 260
  10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | • JEP 173 deprecated these GC combinations with JDK 8 • These flag combinations will now error • DefNew + CMS : ParNew + SerialOld : -XX:+UseParNewGC ParNew + iCMS : -Xincgc ParNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC DefNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC -XX:-UseParNewGC CMS foreground : -XX:+UseCMSCompactAtFullCollection CMS foreground : -XX:+CMSFullGCsBeforeCompaction CMS foreground : -XX:+UseCMSCollectionPassing • Incremental CMS (iCMS) is removed 13 JEP 214: Remove GC Combinations Deprecated in JDK 8
  11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | General rule: Look out for unrecognized VM options • Launching JRE with unrecognized VM options fails • Using deprecated options in JDK 8 triggers warning messages $ java -XX:MaxPermSize=1G -version Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize; support was removed in 8.0 • Previously deprecated options, removed in JDK 9, will fail to start – Perm generation was removed in JDK 8 (JEP 122) 14
  12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | JEP 231: Remove Launch-Time JRE Version Selection • Multiple JRE (mJRE), introduced in JDK 5, allowed specifying what JRE version, or range of versions, should be used to launch an application • The version(s) could be specified in a manifest entry in the application jar or through a command line parameter • In JDK 9 version(s) selected through the manifest will be ignored (with a warning), version(s) selected through the command line will err and exit 15
  13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Endorsed Std Override and Extension mechanism, deprecated in 8u40, dropped in 9 • Extension mechanism (also called Optional Packages) made APIs available to any application running on the platform • Endorsed Standards was used for updating certain classes and interfaces of the runtime without updating the whole JRE • JDK 9 fails if anything is placed on ${java.home}/lib/ext and ${java.home}/lib/endorsed or if you use java.ext.dirs system property • Preparation: – JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs to print a message if you are using the extension or standard mechanisms – Use upgradable modules or put jars on the classpath instead 16 JDK-8060206
  14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Remove Unsupported OS X APIs • JEP 272: Platform-Specific Desktop Features replaces – com.apple.eawt – com.apple.eio With platform-independent alternatives in java.awt • Remove com.apple.concurrent JDK-8148187 • Remove AppleScript scripting engine JDK-8143404 17
  15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Remove com.sun.image.codec.jpeg • Replacement API shipped since 2002 (1.4) • Not available in OpenJDK • Deprecated in JDK 7 18 JDK-8038838
  16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | JEP 271: Unified GC Logging • GC logs are in a different format – Parsers might need to be reworked • Most common flags are deprecated and remapped -XX:+PrintGC becomes -Xlog:gc -XX:+PrintGCDetails becomes -Xlog:gc* -Xloggc:<filename> becomes -Xlog:gc:<filename> 19 Re-implemented GC logging with the new JVM logging framework from JEP 158
  17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | G1 is the new default garbage collector • Parallel GC was the default up to JDK 8 on most platforms – Still there but no longer the default – Can select Parallel GC via command flags 21 JEP 248: Make G1 the Default Garbage Collector
  18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | What can you do to prepare? • Check code for usages of JDK-internal APIs with jdeps • If you develop tools then check code for a dependency on rt.jar or tools.jar or the runtime-image layout • Check code that might be sensitive to the version change • Check code for uses of underscore as an identifier • Check code for uses of unrecognized VM options such as -XX:MaxPermSize • Test the JDK 9 EA builds and Project Jigsaw EA builds https://wiki.openjdk.java.net/display/Adoption/JDK+9+Outreach 24
  19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Quality Outreach effort wiki: https://wiki.openjdk.java.net/display/quality /Quality+Outreach The following testers who submitted significant bug reports deserve special mention: Apache Lucene, JaCoCo, Apache Groovy , Hazelcast & Apache Ant. Valuable reports were also received from : Gradle, Jitwatch, AssertJ, Apache JMeter & ElasticSearch. (from Quality Outreach report Sept '2015) 29 Thank you!
  20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

    | Safe Harbor Statement 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. Oracle Confidential – Internal 31