Embracing Java 9 and beyond with Eclipse JDT Sarika Sinha Committer Platform and JDT Eclipse Projects, Co-Lead Eclipse JDT Project
Agenda Java and Eclipse release timelines Java 9 features Moving from Java 8 to Java 9 and beyond
Java and Eclipse release timelines Twice yearly releases of Java from 2018 in March and September Quarterly releases of Eclipse in March, June, September and December.
Java 9 features Private interface methods Try-With Resources enhancements @SafeVarargs Annotation for private instance methods Collection Factory Methods Stream improvements Option --release Modules Launching with Java 9 and beyond Overriding dependencies while launching for Java 9 and beyond
Java 9 features - Private interface methods Java 9 allows private methods and private static methods in interfaces.
Java 9 features - Try-With Resources enhancements Final and effectively final variables can be placed in try-with- resource blocks, starting in Java 9.
Java 9 features - @SafeVarargs enhancement Java 9 allows @SafeVarargs annotation for private instance methods also.
Java 9 features – Collection factory methods Java 9 has added simple ways to create immutable Collections without null values.
Java 9 features - Stream improvements Stream takeWhile/dropWhile Stream iterate Stream ofNullable
Java 9 features --release option Now it is possible to compile against older compliance level by specifying --release option. The new --release compiler option now allows the user to configure compilation against a platform API version of user's choice. The --release option is enabled for JRE 9 and above, if the compliance is set to 1.6 or above
Java 9 features - Modules Project Jigsaw introduced the Java 9 Platform Module System. Module—a uniquely named, reusable group of related packages, as well as resources and a module descriptor (module-info.java) All JDK Modules starts with “jdk.*” All Java SE Specifications Modules starts with “java.*” Java 9 Module System has a “java.base” Module which is an independent module.
Java 9 features – Modules (contd..) Named modules have module defined in module-info.java A class which is not a member of a 'named module' is considered to be a member of a special module known as the unnamed module. The unnamed module 'requires' every other named modules and 'exports' all its packages. Automatic Modules are named modules which are automatically created for a non-modular jar.
Java 9 features – Modules (contd..) Java search now includes a new search scope – Module. Java Build Path allows to add Projects and jars to Modulepath or Classpath Encapsulation properties of Modulepath elements can be modified using Is modular node. Is modular node is changed to Is not modular if the the Build Path Project library is moved to Classpath.
Java 9 features – Modules (contd..) Encapsulation properties of Modulepath elements can be modified using Is modular node. Patching the module, modules for read and exports can be added.
Java 9 features – Modules (contd..) Quick Fix in module-info.java to import class and add requires to module-info.java. Quick Fix in module-info.java to move Classpath entry to Modulepath entry.
Java 9 features – Modules (contd..) Quick Fix in a class to add requires to module-info.java. Quick Fix in import to add requires to module-info.java.
Java 9 features – Launch Configuration “Dependencies” tab with Java Runtime 9.
Java 9 features – Launch Configuration Override Dependencies button has been added to the Dependencies tab. Java 9 has provided many command line options to make older projects compatible to the new modules. Based on Java build path, dependencies are derived. These options from build path can be overridden for launching programs in the module.
Java 10 features Local variable type inference support for Java 10. Auto completion support for “var” Hover Support for “var” Type conversion suggestions Suggestion to change project compliance and JRE
Java 10 features Time based release versioning
Java 11 features Local variable syntax for Lambda Parameters Nest-Based Access Control Raw String literals (Not triaged to Java 11) Switch Expressions and Pattern matching (Not triaged to Java 11)
Moving from Java 8 to Java 9 and beyond Create new Java Projects as modular Put Java 8 libraries and Projects in Classpath Put modular libraries and Projects in Modulepath Learn about options ALL-UNNAMED, ALL- DEFAULT, ALL-SYSTEM, ALL-MODULE-PATH Learn about options --add-exports, --add- reads, --add-opens
Quick Links Eclipse Photon JDT New and Noteworthy Java 9 Examples https://www.eclipse.org/eclipse/news/4.8/jdt.html Java 9 Examples https://wiki.eclipse.org/Java9/Examples Java 10 Examples https://wiki.eclipse.org/Java10/Examples Java 11 Examples https://wiki.eclipse.org/Java11/Examples
Thank You