Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK...

40

Transcript of Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK...

Page 1: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using
Page 2: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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 September 30th, 2016 – JUG Saxony Day, Dresden

Page 3: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Page 4: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Page 5: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Quality Outreach

– Background/History

• JDK 7 GA - 28 July 2011

• Java 7 paralyses Lucene and Solr (29 July)

• JDK 8

– October 2013 started Quality Outreach

– zero to ~20 FOSS Projects testing EA build prior to GA

– High priority issues were detected and addressed in the run up to JDK 8 GA

• Apache Lucene (5 bugs)

• Apache Maven (4 bugs)

• Groovy (3 bugs)

• Scala (2 bugs)

– Java 8 adoption rate higher than expected

Page 6: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Quality Outreach Program • Promotes testing of Free Open Source Software (FOSS) projects with OpenJDK builds

• Great initiative to improve the release quality of Java and compatibility with libraries

• Participating projects test their software with early access builds of various OpenJDK projects

• Identified issues are reported back in JDK Bug System

• ~80 FOSS projects registered (as of Sept, 2016)

– From Apache, Eclipse, Java EE, Spring and other open source communities

• Build tools such as Apache Ant, Apache Maven, Gradle

• JVM languages such as Clojure, Golo, Apache Groovy, Jython, Scala

• Development tools such as Arquillian, Byteman, Checkstyle, EasyMock, Findbugs, JaCoCo, JUnit 5 ...

• And many more such as Apache Lucene, Apache POI, Apache Tomcat, Hibernate, Jetty, JOSM, Spring Framework, WildFly

Send an e-mail to [email protected] to join us!

Page 7: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

JDK 9 Early Access builds jdk9.java.net

7

Page 8: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Size L

8

Page 9: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Internal API Related Changes: FAQ

Page 10: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Internal API Related Changes: javac

Page 11: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

– Accessibility check performed both • By the javac compiler at compile time and

• By the JVM at runtime

• A handful of critical, widely used internal APIs remain accessible by default

– Without good alternatives in JDK 8, like sun.misc.Unsafe

– Remain accessible by default in JDK 9

– Remain that way until supported replacements exist for all or most of their functionality

11

Page 12: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

JEP 260: Encapsulate most internal APIs

• Preparation:

– The jdeps tool can help identify programs that might be impacted • Use jdeps –jdkinternals my.jar to identify areas of interest

• Caveat Emptor: jdeps performs static analysis only

– Explore Multi-Release JAR files (JEP 238) • Allow Java-release-specific versions of a class to coexist in a single JAR file

• JDK 8 variant of a class alongside a JDK 9 variant of same class

• Could use different APIs in each variant

– As a last resort: • Use a command line flag to provide access to encapsulated APIs

• See JEP 260 for flag details

12

Page 13: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

JEP 260: Encapsulate most internal APIs

13

An example using jdeps

Page 14: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Learn More @ 10:05, Raum 01

14

Page 15: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Learn Even More @ 11:30, Raum 01

15

Page 16: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

JEP 223: New Version String Scheme

• New version string is closer to Semantic-Versioning

• It drops some long kept baggage

– the “1.” in front

– the use of “u” for updates

• Contents of Java version related system properties change as well

16

$MAJOR.$MINOR.$SECURITY

Page 17: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

JEP 223: New Version String Scheme

• Preparation:

– Test version string checking code with a JDK 9 Early Access build • Common sources of surprise:

– GA version string is „9“ instead of „9.0.0“

– Expecting „1.x.0“ and skipping the first component

– Version string checking code targeting both JDK 9 and earlier versions • Has to deal with both “old” and “new” version string formats

17

$MAJOR.$MINOR.$SECURITY

Page 18: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

18

Page 19: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Page 20: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Page 21: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

21

Removed: rt.jar and tools.jar

Page 22: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

JEP 220: Modular Run-Time Images

• 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

22

Removed: rt.jar and tools.jar

Page 23: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Size M

23

Page 24: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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>

24

Re-implemented GC logging with the new JVM logging framework from JEP 158

Page 25: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

JEP 214: Remove GC Combinations Deprecated in JDK 8

• 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

25

Page 26: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

– Have been removed in JDK 9

– Are not recognized any more

– Lead to JVM exiting at startup

26

Page 27: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Endorsed Std Override and Extension mechanism Deprecated in 8u40, dropped in JDK 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

27

JDK-8060206

Page 28: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Endorsed Std Override and Extension mechanism Deprecated in 8u40, dropped in JDK 9

• Preparation:

– JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs • Prints a message if you are using the extension or standard mechanisms

– Use upgradable modules or put jars on the classpath instead

28

JDK-8060206

Page 29: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

29

Except for a few called out in JEP 260

Page 30: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

30

Page 31: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

31

JDK-8038838

Page 32: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Size S

32

Page 33: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

33

JEP 248: Make G1 the Default Garbage Collector

Page 34: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Page 35: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Page 36: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

Page 37: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

One more thing ...

37

https://www.java.com/en/jre-jdk-cryptoroadmap.html

Page 38: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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

• Check code for a dependency on rt.jar, 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

38

Page 39: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using

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 39

Page 40: Prepare for JDK 9! - JUG Saxony Day · Deprecated in 8u40, dropped in JDK 9 •Preparation: –JDK 8u40 introduced -XX:+CheckEndorsedAndExtDirs •Prints a message if you are using