SlideShare a Scribd company logo
1 of 32
Download to read offline
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Preparing your code for Java 9
Eclipse Summit, India
Deepu Xavier
Product Manager
Java Platform Group
26 August 2016
Copyright © 2016, 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.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Agenda
• Java 9 Schedule
• How a developer can leverage and adjust to Java 9 features
– Jshell
– Javadoc Search
– Internal API encapsulation
– Process API
– Convenience Factory Methods for Collections
– Version String – V for Verona
– Multi Release Jar Files
– Gone, gone, gone…
• The Jigsaw way
– How to make your own modular image
• What Next
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Java 9 Timeline
Schedule Milestone Target Date
Feature Complete 26 May 2016
All Tests Run 11 August 2016
Rampdown Start 01 September 2016
Zero bug Bounce 20 October 2016
Rampdown Phase 2 01 December 2016
Final Release Candidate 26 January 2017
General Availability 23 March 2017
https://jdk9.java.net/
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 6
JDK Enhancement Proposals (JEPs) for Java 9
Total
84 JEPs
Jigsaw Client Lib Core Lib Core SVC Hotspot JavaFX Security Lib Tools XML Others
Version String
Linux/AArch64
Port
Infra & Deploy- 3
JEPs
7 JEPs 19 JEPs 2 JEPs 17 JEPs 3 JEPs 9 JEPs 15 JEPs 1 JEPs 5 JEPs
Note: The content of this slide is based on information available as of 26th July 2016
6 JEPs
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 7
Java 9: Jigsaw and Many More…
Process API
Improvements
Multi-Resolution
Images
Interned String in CDS Unicode Compatibility
Default GC
JVM Command
Validation
Compact String
Segmented Code
Cache
Reserved Stack Areas
for Critical Sections
Better Import
Statement Handling
Convenient Collections
Handling
Concurrency Updates
Multi Release JAR
Smart Compilation 2
HiDPI Graphics on
Windows and Linux
Microbenchmark Suite
More JVM Diagnostic
Commands
Compile for Older
Platform Versions
Jigsaw
HTTP2 Compliance
New Version String
http://openjdk.java.net/projects/jdk9/
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 222: JShell
• Lets you try code.
• Supports libraries, tab completion, up/down arrows, etc.
• Not for “create a class or method from this prose.”
8
•Without JShell, I often wrote random unit tests or main
methods to try things.
•With JShell, I can try things and close it when I’m done.
JEP 222
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 225: Javadoc Search
• Add a search box to generated API documentation that can be used to search for program elements and
tagged words and phrases within the documentation.
tools / javadoc(tool)
Java 8 Javadoc:
https://docs.oracle.com/javase/8/docs/api/
Java 9 Javadoc:
http://download.java.net/java/jdk9/docs/api/index.html
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 260: Encapsulate Most Internal APIs
• Make most of the JDK's internal APIs inaccessible by default but leave a few critical, widely-used internal
APIs accessible, until supported replacements exist for all or most of their functionality
– 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
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 11
Categories of APIs in JDK
• Supported, intended for external use
• JCP standard, java.*, javax.*
• JDK-specific API, some com.sun.*, some jdk.*
• Unsupported, JDK-internal, not intended for external use
• sun.* mostly
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 12
Internal API Related Changes
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 13
General compatibility policies
•If an application uses only supported, non-deprecated, APIs and works on release N then it should
work on N+1, even without recompilation
•Supported APIs can be removed but only with advanced notice
How we manage incompatibilities
• Judge risk and impact based on actual data (where possible)
• Communicate early and vigorously through Early Access, OpenJDK Mails etc.
• Make it easy to understand how existing code will be affected
• When removing unsupported APIs, provide replacements where it make sense
• Provide workarounds where possible
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 14
JEP 260 proposal
Encapsulate all non-critical internal APIs by default
Encapsulate all critical internal APIs for which supported replacements exist in JDK 8
Do not encapsulate critical internal APIs
• Deprecate them in JDK 9
• Plan to remove in JDK 10
Provide a workaround via command-line flag
Non-critical
No evidence of use outside of JDK or used only for convenience
Critical
Functionality that would be difficult, if not impossible, to implement outside of the JDK
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 15
Finding uses of JDK-internal APIs
• jdeps tool in JDK 8, improved in JDK 9
• Maven JDeps Plugin
$ jdeps -jdkinternals glassfish/modules/security.jar
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Code shown in the following examples are purely author’s imagination or used in a fictitious manner.
Any resemblance to your application code “could be” purely coincidental.
Internal API !!!
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
jdeps To The Rescue
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
The Right Way
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 102: Process API Updates
19
• There has been a huge limitation in managing and controlling OS processes with Java
• Platform compatibility was always a challenge. At present, developers resort to native code or much
verbose workaround
• With Java 9, processes can be handled using new direct methods like:
• ProcessHandle currProcess = ProcessHandle.current();
• ProcessHandle.allProcesses()
.filter(processHandle -> processHandle.info().command().isPresent())
.limit(3)
.forEach((process) ->{// action here}
//In Windows
Process myProc = Runtime.getRuntime().exec ("tasklist.exe");
InputStream procOutput = myProc.getInputStream ();
if (0 == myProc.waitFor ()) {
// actions here
}
//For Linux
Process myProc = Runtime.getRuntime().exec("ps -e");
InputStream procOutput = myProc.getInputStream ();
if (0 == myProc.waitFor ()) {
// actions here
}
Note: This is just couple of new methods/ classes. Please refer the respective javadoc for full list
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
The Right Way
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 269: Convenience Factory Methods for Collections
• Define library APIs to make it convenient to create instances of collections and maps with small numbers
of elements, so as to ease the pain of not having collection literals in the Java programming language
• Less boilerplate and reduced amount of code needed for creating small collections and maps
• Set<String> set = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("a", "b", "c")));
– populate a collection using a copy constructor from another collection:
• Set<String> set = Collections.unmodifiableSet(new HashSet<String>() {{ add("a"); add("b"); add("c"); }});
– use the so-called "double brace" technique:
• Set<String> set = Collections.unmodifiableSet(Stream.of("a", "b", "c").collect(toSet()));
– by combining stream factory methods and collectors
Set<String> alphabet = Set.of("a", "b", "c");
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Overload Difficulty: List.of(array)
Oracle Confidential – Internal 22
Suppose you have this:
String[] array = { "a", "b", "c" };
List.of(array);
Should this create:
A. List<String> containing three strings?
B. List<String[]> containing a single array?
JEP 269
ANSWER:
A. Compiler chooses varargs, so we get List<String> with three strings
Probably right; list of arrays is rare. Workaround:
List<String[]> listOfArray = List.<String[]>of(array);
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 23
JEP 223: New Version-String Scheme
Revise the JDK's version-string scheme so that it is easier to distinguish major, minor, and security-update releases.
Goal is to device a new version numbering scheme which is
 easily understandable
 aligning with industry best practices (Semantic Versioning)
 is easy to distinguish between major, minor and critical patch update (CPU) releases
New scheme will follow MAJOR.MINOR.SECURITY (-PRE)?(+BUILD)?(-OPT)? convention
MAJOR : The major version number will be incremented for every major release
MINOR : The minor version number will be incremented for every minor update release
MINOR is reset to zero when MAJOR is incremented
SECURITY: The security version number will be incremented for every security update release
SECURITY is reset to zero only when MAJOR is incremented
A higher value of SECURITY for a given MAJOR value, therefore, always indicates a more secure release, regardless of the value of MINOR
PRE: This represents a pre-release identifier. E.g. ea, for an early-access release
BUILD: Build number may be promoted by 1 for every promoted build. BUILD is reset to one when any portion of MAJOR.MINOR.SECURITY is incremented
OPT: Additional build information
Note: Existing code that assumes the initial element to have the value 1, however, and therefore always skips to the second element when comparing version numbers, will not work correctly
e.g., such code will consider 9.0.1 to precede 1.8.0.
Version # Detail
9 Java 9 GA
9.0.1 CPU: 9 + critical changes
9.1.1 Minor release: 9.0.1 + other changes
9.1.2 CPU: 9.1.1 + critical changes
9.2.2 Minor release: 9.1.2 + other changes
Hypothetical Release Sequence (for illustration only)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 282: jlink: The Java Linker
• Create a tool that can assemble and optimize a set of modules and their dependencies into a custom run-
time image as defined in JEP 220. Define a plugin mechanism for transformation and optimization during
the assembly process, and for the generation of alternative image formats
• Create a custom runtime optimized for a single program
• JEP 261 defines link time as an optional phase between the phases of compile time and run time. Link
time requires a linking tool that will assemble and optimize a set of modules and their transitive
dependencies to create a run-time image or executable.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 25
JEP 238: Multi-Release JAR Files
Extend the JAR file format to allow multiple, Java-release-specific versions of class files to coexist in a single archive.
• It is practically difficult to express conditional platform dependencies or to distribute separate
library artifacts for each new java version
• A multi-release JAR ("MRJAR") will contain additional directories for classes and resources
specific to particular Java platform releases.
With this, it is possible for versions of a class designed for a later Java platform version to
override the version of that same class designed for an earlier Java platform release.
META-INF
Content Root
A.class
B.class
C.class
D.class
Normal JAR
META-INF
versions
-8
A.class
B.class
-9
A.class
Content Root
A.class
B.class
C.class
D.class
MR JAR
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 289: Deprecate the Applet API
• Deprecate the Applet API, which is rapidly becoming irrelevant as web-browser vendors remove support for Java
browser plug-ins
JEP 241: Remove the jhat Tool
• Remove the antiquated jhat tool
• jhat is an experimental, unsupported, and out-of-date tool added in JDK 6
• Superior heap visualizers and analyzers have now been available for many years
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
JEP 231: Remove Launch-Time JRE Version Selection
• Remove the ability to request, at JRE launch time, a version of the JRE that is not the JRE being launched.
• Modern applications are typically deployed via Java Web Start (JNLP), native OS packaging systems, or
active installers, and all of these technologies have their own ways of finding, and even sometimes
installing and later updating, an appropriate JRE for the application.
JEP 240: Remove the JVM TI hprof Agent
• Remove the hprof agent from the JDK
• The hprof agent was written as demonstration code for the JVM Tool Interface and not intended to be a
production tool.
• The useful features of the hprof agent have been superseded by better alternatives.
Alternatives
Heap dumps: GC.heap_dump (jcmd <pid> GC.heap_dump)/ jmap –dump
Allocation profiler : Java VisualVm & other 3rd party tools
CPU profiler: Java VisualVm and Java Flight Recorder
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
What Next ?
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Download Early Access and Try Java 9
https://jdk9.java.net/
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
How can Open Source projects get involved to test JDK 9?
• Helps open source projects understand changes and know how to test.
• Check your code for internal APIs using Jdeps.
• Run your tests on JDK 9.
https://wiki.openjdk.java.net/display/quality/Quality+Outreach
30
Join the OpenJDK Quality Outreach Campaign
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Preparing your code for Java 9

More Related Content

What's hot

Java 9 and the impact on Maven Projects (Devoxx 2016)
Java 9 and the impact on Maven Projects (Devoxx 2016)Java 9 and the impact on Maven Projects (Devoxx 2016)
Java 9 and the impact on Maven Projects (Devoxx 2016)Robert Scholte
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New FeaturesHaim Michael
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Robert Scholte
 
Workflow automation for Front-end web applications
Workflow automation for Front-end web applicationsWorkflow automation for Front-end web applications
Workflow automation for Front-end web applicationsMayank Patel
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9Pavel Bucek
 
Java 10 New Features
Java 10 New FeaturesJava 10 New Features
Java 10 New FeaturesAli BAKAN
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionStephen Colebourne
 
Flavors of Concurrency in Java
Flavors of Concurrency in JavaFlavors of Concurrency in Java
Flavors of Concurrency in JavaJavaDayUA
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modulesPaul Bakker
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Julian Robichaux
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
An Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkAn Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkPT.JUG
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerSimon Ritter
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 

What's hot (20)

Java 9 and the impact on Maven Projects (Devoxx 2016)
Java 9 and the impact on Maven Projects (Devoxx 2016)Java 9 and the impact on Maven Projects (Devoxx 2016)
Java 9 and the impact on Maven Projects (Devoxx 2016)
 
Java11 New Features
Java11 New FeaturesJava11 New Features
Java11 New Features
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)
 
Workflow automation for Front-end web applications
Workflow automation for Front-end web applicationsWorkflow automation for Front-end web applications
Workflow automation for Front-end web applications
 
What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9
 
Java 10 New Features
Java 10 New FeaturesJava 10 New Features
Java 10 New Features
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introduction
 
Flavors of Concurrency in Java
Flavors of Concurrency in JavaFlavors of Concurrency in Java
Flavors of Concurrency in Java
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modules
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
JDK-9: Modules and Java Linker
JDK-9: Modules and Java LinkerJDK-9: Modules and Java Linker
JDK-9: Modules and Java Linker
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
An Introduction to Play 2 Framework
An Introduction to Play 2 FrameworkAn Introduction to Play 2 Framework
An Introduction to Play 2 Framework
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 

Viewers also liked

Разговор про Java 9. Extended version
Разговор про Java 9. Extended versionРазговор про Java 9. Extended version
Разговор про Java 9. Extended versionIvan Krylov
 
Lean UX and Design winning mobile apps
Lean UX and Design winning mobile appsLean UX and Design winning mobile apps
Lean UX and Design winning mobile appsKosala Nuwan Perera
 
Embracing Reactive Streams with Java 9 and Spring 5
Embracing Reactive Streams with Java 9 and Spring 5Embracing Reactive Streams with Java 9 and Spring 5
Embracing Reactive Streams with Java 9 and Spring 5Wilder Rodrigues
 
자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)Chang-Hwan Han
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and ToolingTrisha Gee
 
Migrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from EclipseMigrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from EclipseTrisha Gee
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Trisha Gee
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
Java9 특징 훑어보기
Java9 특징 훑어보기Java9 특징 훑어보기
Java9 특징 훑어보기duriepark 유현석
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9Simon Ritter
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
 

Viewers also liked (13)

Разговор про Java 9. Extended version
Разговор про Java 9. Extended versionРазговор про Java 9. Extended version
Разговор про Java 9. Extended version
 
Lean UX and Design winning mobile apps
Lean UX and Design winning mobile appsLean UX and Design winning mobile apps
Lean UX and Design winning mobile apps
 
Git
GitGit
Git
 
Embracing Reactive Streams with Java 9 and Spring 5
Embracing Reactive Streams with Java 9 and Spring 5Embracing Reactive Streams with Java 9 and Spring 5
Embracing Reactive Streams with Java 9 and Spring 5
 
What's New in Java SE 9
What's New in Java SE 9What's New in Java SE 9
What's New in Java SE 9
 
자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)자바9 특징 (Java9 Features)
자바9 특징 (Java9 Features)
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and Tooling
 
Migrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from EclipseMigrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from Eclipse
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Java9 특징 훑어보기
Java9 특징 훑어보기Java9 특징 훑어보기
Java9 특징 훑어보기
 
55 New Features in JDK 9
55 New Features in JDK 955 New Features in JDK 9
55 New Features in JDK 9
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 

Similar to Preparing your code for Java 9

Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018CodeOps Technologies LLP
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8jclingan
 
Serverless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsDavid Delabassee
 
JDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDKJDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDKWolfgang Weigend
 
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]David Buck
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureJavaDayUA
 
Building Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integrationBuilding Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integrationFredrik Öhrström
 
Concierge - Bringing OSGi (back) to Embedded Devices
Concierge - Bringing OSGi (back) to Embedded DevicesConcierge - Bringing OSGi (back) to Embedded Devices
Concierge - Bringing OSGi (back) to Embedded DevicesJan S. Rellermeyer
 
Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Shaun Smith
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Alexandre (Shura) Iline
 
Configuration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and TamayaConfiguration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and TamayaDmitry Kornilov
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudBruno Borges
 
Java @ Cloud - Setor Público SP
Java @ Cloud - Setor Público SPJava @ Cloud - Setor Público SP
Java @ Cloud - Setor Público SPIlan Salviano
 
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"GlobalLogic Ukraine
 
Lucene, Solr and java 9 - opportunities and challenges
Lucene, Solr and java 9 - opportunities and challengesLucene, Solr and java 9 - opportunities and challenges
Lucene, Solr and java 9 - opportunities and challengesCharlie Hull
 

Similar to Preparing your code for Java 9 (20)

Java Cloud and Container Ready
Java Cloud and Container ReadyJava Cloud and Container Ready
Java Cloud and Container Ready
 
Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018
 
Hotspot & AOT
Hotspot & AOTHotspot & AOT
Hotspot & AOT
 
Java 8
Java 8Java 8
Java 8
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Serverless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and Triumphs
 
JDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDKJDK 8 and JDK 8 Updates in OpenJDK
JDK 8 and JDK 8 Updates in OpenJDK
 
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
Bytecode Verification, the Hero That Java Needs [JavaOne 2016 CON1500]
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and Architecture
 
Building Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integrationBuilding Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integration
 
Concierge - Bringing OSGi (back) to Embedded Devices
Concierge - Bringing OSGi (back) to Embedded DevicesConcierge - Bringing OSGi (back) to Embedded Devices
Concierge - Bringing OSGi (back) to Embedded Devices
 
Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.
 
Configuration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and TamayaConfiguration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and Tamaya
 
JDK 10 Java Module System
JDK 10 Java Module SystemJDK 10 Java Module System
JDK 10 Java Module System
 
Java EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The CloudJava EE Arquillian Testing with Docker & The Cloud
Java EE Arquillian Testing with Docker & The Cloud
 
Java @ Cloud - Setor Público SP
Java @ Cloud - Setor Público SPJava @ Cloud - Setor Público SP
Java @ Cloud - Setor Público SP
 
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"
Java Webinar #12: "Java Versions and Features: Since JDK 8 to 16"
 
Lucene, Solr and java 9 - opportunities and challenges
Lucene, Solr and java 9 - opportunities and challengesLucene, Solr and java 9 - opportunities and challenges
Lucene, Solr and java 9 - opportunities and challenges
 

Recently uploaded

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Preparing your code for Java 9

  • 1.
  • 2. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Preparing your code for Java 9 Eclipse Summit, India Deepu Xavier Product Manager Java Platform Group 26 August 2016
  • 3. Copyright © 2016, 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.
  • 4. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Agenda • Java 9 Schedule • How a developer can leverage and adjust to Java 9 features – Jshell – Javadoc Search – Internal API encapsulation – Process API – Convenience Factory Methods for Collections – Version String – V for Verona – Multi Release Jar Files – Gone, gone, gone… • The Jigsaw way – How to make your own modular image • What Next
  • 5. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Java 9 Timeline Schedule Milestone Target Date Feature Complete 26 May 2016 All Tests Run 11 August 2016 Rampdown Start 01 September 2016 Zero bug Bounce 20 October 2016 Rampdown Phase 2 01 December 2016 Final Release Candidate 26 January 2017 General Availability 23 March 2017 https://jdk9.java.net/
  • 6. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 6 JDK Enhancement Proposals (JEPs) for Java 9 Total 84 JEPs Jigsaw Client Lib Core Lib Core SVC Hotspot JavaFX Security Lib Tools XML Others Version String Linux/AArch64 Port Infra & Deploy- 3 JEPs 7 JEPs 19 JEPs 2 JEPs 17 JEPs 3 JEPs 9 JEPs 15 JEPs 1 JEPs 5 JEPs Note: The content of this slide is based on information available as of 26th July 2016 6 JEPs
  • 7. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 7 Java 9: Jigsaw and Many More… Process API Improvements Multi-Resolution Images Interned String in CDS Unicode Compatibility Default GC JVM Command Validation Compact String Segmented Code Cache Reserved Stack Areas for Critical Sections Better Import Statement Handling Convenient Collections Handling Concurrency Updates Multi Release JAR Smart Compilation 2 HiDPI Graphics on Windows and Linux Microbenchmark Suite More JVM Diagnostic Commands Compile for Older Platform Versions Jigsaw HTTP2 Compliance New Version String http://openjdk.java.net/projects/jdk9/
  • 8. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 222: JShell • Lets you try code. • Supports libraries, tab completion, up/down arrows, etc. • Not for “create a class or method from this prose.” 8 •Without JShell, I often wrote random unit tests or main methods to try things. •With JShell, I can try things and close it when I’m done. JEP 222
  • 9. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 225: Javadoc Search • Add a search box to generated API documentation that can be used to search for program elements and tagged words and phrases within the documentation. tools / javadoc(tool) Java 8 Javadoc: https://docs.oracle.com/javase/8/docs/api/ Java 9 Javadoc: http://download.java.net/java/jdk9/docs/api/index.html
  • 10. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 260: Encapsulate Most Internal APIs • Make most of the JDK's internal APIs inaccessible by default but leave a few critical, widely-used internal APIs accessible, until supported replacements exist for all or most of their functionality – 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
  • 11. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 11 Categories of APIs in JDK • Supported, intended for external use • JCP standard, java.*, javax.* • JDK-specific API, some com.sun.*, some jdk.* • Unsupported, JDK-internal, not intended for external use • sun.* mostly
  • 12. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 12 Internal API Related Changes
  • 13. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 13 General compatibility policies •If an application uses only supported, non-deprecated, APIs and works on release N then it should work on N+1, even without recompilation •Supported APIs can be removed but only with advanced notice How we manage incompatibilities • Judge risk and impact based on actual data (where possible) • Communicate early and vigorously through Early Access, OpenJDK Mails etc. • Make it easy to understand how existing code will be affected • When removing unsupported APIs, provide replacements where it make sense • Provide workarounds where possible
  • 14. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 14 JEP 260 proposal Encapsulate all non-critical internal APIs by default Encapsulate all critical internal APIs for which supported replacements exist in JDK 8 Do not encapsulate critical internal APIs • Deprecate them in JDK 9 • Plan to remove in JDK 10 Provide a workaround via command-line flag Non-critical No evidence of use outside of JDK or used only for convenience Critical Functionality that would be difficult, if not impossible, to implement outside of the JDK
  • 15. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 15 Finding uses of JDK-internal APIs • jdeps tool in JDK 8, improved in JDK 9 • Maven JDeps Plugin $ jdeps -jdkinternals glassfish/modules/security.jar
  • 16. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Code shown in the following examples are purely author’s imagination or used in a fictitious manner. Any resemblance to your application code “could be” purely coincidental. Internal API !!!
  • 17. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. jdeps To The Rescue
  • 18. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. The Right Way
  • 19. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 102: Process API Updates 19 • There has been a huge limitation in managing and controlling OS processes with Java • Platform compatibility was always a challenge. At present, developers resort to native code or much verbose workaround • With Java 9, processes can be handled using new direct methods like: • ProcessHandle currProcess = ProcessHandle.current(); • ProcessHandle.allProcesses() .filter(processHandle -> processHandle.info().command().isPresent()) .limit(3) .forEach((process) ->{// action here} //In Windows Process myProc = Runtime.getRuntime().exec ("tasklist.exe"); InputStream procOutput = myProc.getInputStream (); if (0 == myProc.waitFor ()) { // actions here } //For Linux Process myProc = Runtime.getRuntime().exec("ps -e"); InputStream procOutput = myProc.getInputStream (); if (0 == myProc.waitFor ()) { // actions here } Note: This is just couple of new methods/ classes. Please refer the respective javadoc for full list
  • 20. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. The Right Way
  • 21. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 269: Convenience Factory Methods for Collections • Define library APIs to make it convenient to create instances of collections and maps with small numbers of elements, so as to ease the pain of not having collection literals in the Java programming language • Less boilerplate and reduced amount of code needed for creating small collections and maps • Set<String> set = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("a", "b", "c"))); – populate a collection using a copy constructor from another collection: • Set<String> set = Collections.unmodifiableSet(new HashSet<String>() {{ add("a"); add("b"); add("c"); }}); – use the so-called "double brace" technique: • Set<String> set = Collections.unmodifiableSet(Stream.of("a", "b", "c").collect(toSet())); – by combining stream factory methods and collectors Set<String> alphabet = Set.of("a", "b", "c");
  • 22. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Overload Difficulty: List.of(array) Oracle Confidential – Internal 22 Suppose you have this: String[] array = { "a", "b", "c" }; List.of(array); Should this create: A. List<String> containing three strings? B. List<String[]> containing a single array? JEP 269 ANSWER: A. Compiler chooses varargs, so we get List<String> with three strings Probably right; list of arrays is rare. Workaround: List<String[]> listOfArray = List.<String[]>of(array);
  • 23. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 23 JEP 223: New Version-String Scheme Revise the JDK's version-string scheme so that it is easier to distinguish major, minor, and security-update releases. Goal is to device a new version numbering scheme which is  easily understandable  aligning with industry best practices (Semantic Versioning)  is easy to distinguish between major, minor and critical patch update (CPU) releases New scheme will follow MAJOR.MINOR.SECURITY (-PRE)?(+BUILD)?(-OPT)? convention MAJOR : The major version number will be incremented for every major release MINOR : The minor version number will be incremented for every minor update release MINOR is reset to zero when MAJOR is incremented SECURITY: The security version number will be incremented for every security update release SECURITY is reset to zero only when MAJOR is incremented A higher value of SECURITY for a given MAJOR value, therefore, always indicates a more secure release, regardless of the value of MINOR PRE: This represents a pre-release identifier. E.g. ea, for an early-access release BUILD: Build number may be promoted by 1 for every promoted build. BUILD is reset to one when any portion of MAJOR.MINOR.SECURITY is incremented OPT: Additional build information Note: Existing code that assumes the initial element to have the value 1, however, and therefore always skips to the second element when comparing version numbers, will not work correctly e.g., such code will consider 9.0.1 to precede 1.8.0. Version # Detail 9 Java 9 GA 9.0.1 CPU: 9 + critical changes 9.1.1 Minor release: 9.0.1 + other changes 9.1.2 CPU: 9.1.1 + critical changes 9.2.2 Minor release: 9.1.2 + other changes Hypothetical Release Sequence (for illustration only)
  • 24. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 282: jlink: The Java Linker • Create a tool that can assemble and optimize a set of modules and their dependencies into a custom run- time image as defined in JEP 220. Define a plugin mechanism for transformation and optimization during the assembly process, and for the generation of alternative image formats • Create a custom runtime optimized for a single program • JEP 261 defines link time as an optional phase between the phases of compile time and run time. Link time requires a linking tool that will assemble and optimize a set of modules and their transitive dependencies to create a run-time image or executable.
  • 25. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 25 JEP 238: Multi-Release JAR Files Extend the JAR file format to allow multiple, Java-release-specific versions of class files to coexist in a single archive. • It is practically difficult to express conditional platform dependencies or to distribute separate library artifacts for each new java version • A multi-release JAR ("MRJAR") will contain additional directories for classes and resources specific to particular Java platform releases. With this, it is possible for versions of a class designed for a later Java platform version to override the version of that same class designed for an earlier Java platform release. META-INF Content Root A.class B.class C.class D.class Normal JAR META-INF versions -8 A.class B.class -9 A.class Content Root A.class B.class C.class D.class MR JAR
  • 26. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 289: Deprecate the Applet API • Deprecate the Applet API, which is rapidly becoming irrelevant as web-browser vendors remove support for Java browser plug-ins JEP 241: Remove the jhat Tool • Remove the antiquated jhat tool • jhat is an experimental, unsupported, and out-of-date tool added in JDK 6 • Superior heap visualizers and analyzers have now been available for many years
  • 27. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. JEP 231: Remove Launch-Time JRE Version Selection • Remove the ability to request, at JRE launch time, a version of the JRE that is not the JRE being launched. • Modern applications are typically deployed via Java Web Start (JNLP), native OS packaging systems, or active installers, and all of these technologies have their own ways of finding, and even sometimes installing and later updating, an appropriate JRE for the application. JEP 240: Remove the JVM TI hprof Agent • Remove the hprof agent from the JDK • The hprof agent was written as demonstration code for the JVM Tool Interface and not intended to be a production tool. • The useful features of the hprof agent have been superseded by better alternatives. Alternatives Heap dumps: GC.heap_dump (jcmd <pid> GC.heap_dump)/ jmap –dump Allocation profiler : Java VisualVm & other 3rd party tools CPU profiler: Java VisualVm and Java Flight Recorder
  • 28. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. What Next ?
  • 29. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Download Early Access and Try Java 9 https://jdk9.java.net/
  • 30. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. How can Open Source projects get involved to test JDK 9? • Helps open source projects understand changes and know how to test. • Check your code for internal APIs using Jdeps. • Run your tests on JDK 9. https://wiki.openjdk.java.net/display/quality/Quality+Outreach 30 Join the OpenJDK Quality Outreach Campaign
  • 31. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.