PROJECT JIGSAW – INTEGRATION WITH TOOLS

Slides:



Advertisements
Similar presentations
Introduction to Maven 2.0 An open source build tool for Enterprise Java projects Mahen Goonewardene.
Advertisements

Developing in CAS. Why? As distributed you edit CAS 3 with Eclipse and build with Maven 2 – Best Practice for Release Engineering – Difficult edit-debug.
® IBM Software Group © 2010 IBM Corporation What’s New in Profiling & Code Coverage RAD V8 April 21, 2011 Kathy Chan
ANT: Another Nice Tool Ali Beyad October 1, 2003.
ANT: Another Nice Tool Ali Beyad October 1, 2003.
Java Build Tool Comparison HJUG - April 29th, 2009 John Tyler.
Java development infrastructure at FMI Pekka Rantala FMI.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of Creating Eclipse plug-ins.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
2007 Adobe Systems Incorporated. All Rights Reserved. 1 Joe Berkovitz VP Engineering Allurent, Inc. Continuous Integration with Flex, FlexUnit, and Ant.
Using Ant to build J2EE Applications Kumar
Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
Maven & Bamboo CONTINUOUS INTEGRATION. QA in a large organization In a large organization that manages over 100 applications and over 20 developers, implementing.
MAVEN-BLUEMARTINI Yannick Robin. What is maven-bluemartini?  maven-bluemartini is Maven archetypes for Blue Martini projects  Open source project on.
© 2005 by IBM; made available under the EPL v1.0 | March 1, 2005 Tim deBoer Gorkem Ercan Extend WTP Server Tools for your.
Introduction to Android. Android as a system, is a java based operating system that runs on the Linux kernel. The system is very lightweight and full.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
INFSOM-RI Juelich, 10 June 2008 ETICS - Maven From competition, to collaboration.
The Basics of Javadoc Presented By: Wes Toland. Outline  Overview  Background  Environment  Features Javadoc Comment Format Javadoc Program HTML API.
MAE Continuous Integration Administration guide July 8th, 2013.
Java, Web Applications, and OSS Experience Prakash Malani Copyright © 2003.
July 2011CMSC 341 CVS/Ant 1 CMSC 341 Java Packages Ant CVS Project Submission.
Running Kuali: A Technical Perspective Ailish Byrne (Indiana University) Jonathan Keller (University of California, Davis)
GLite build and integration system Building and Packaging Robert HARAKALY
Chapter 1 Introducing Ant. What is ant? Ant is a build tool  Automate the tasks of compiling code, running test, and packaging the results for redistribution.
introductory lecture on java programming
Build Systems Presentation December 14, 2015 Noon-1pm Kathy Lee Simunich Bldg. 203/ D120 Brought to you by: Argonne Java.
Software Deployment & Release 26/03/2015 1EN-ICE.
UpgradinguPortal to What’s new that matters Better use of third party frameworks Faster! Improved caching Drag and Drop New Skin & Theme Accessibility.
GLite build and integration system Building and Packaging Robert HARAKALY
Maven. Introduction Using Maven (I) – Installing the Maven plugin for Eclipse – Creating a Maven Project – Building the Project Understanding the POM.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Visual Programming Borland Delphi. Developing Applications Borland Delphi is an object-oriented, visual programming environment to develop 32-bit applications.
Copyright © 2010 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are trademarks of Accenture. ODS Tools – Fannie Mae.
Java 9 support in Eclipse Jay Arthanareeswaran, Manoj Palat IBM.
UAB Requirements for 2016 Ivan Prieto Barreiro 18/04/2016 UAB Requirements for
Anjana & Shankar September,2010 Introduction to Programming Tools.
Slide 1. What's New in NetBeans IDE 7.1 Name Title.
Platform & Maven2 David Šimonek. Certified Engineer Course Agenda What is Maven? Why Maven? NB IDE & Maven NB Platform & Maven.
Introduction to Android Programming
Open-O Integration Project Introduction
Maven 04 March
CS520 Web Programming Introduction to Maven
Build Automation with Gradle
Plan What is Maven ? Links : mvn command line tool
Obtaining the Required Tools
JavaOne BOF: The Legacy Developer’s Guide to Java 9
Test Driven Development
Eclipse Navigation & Usage.
UAB Development Status
Project Topic 2: Migration to Java 9
CMPE 152: Compiler Design ANTLR 4 and C++
Java 9.
Java 9 Project Jigsaw / JSR 376: JavaTM Platform Module System.
Maven IIB9 Plug-in Version 9.0
With Some Eclipse Tricks included.
Embracing Java 9 and beyond with Eclipse JDT
JENKINS TIPS Ideas for making your life with Jenkins easier
Cordova & Cordova Plugin Installation and Management
Maven IIB9 Plug-in Version 9.0
Escidoc build and development environment
Getting Started With Solr
Carthage ios 8 onwards Dependency manager that streamlines the process of integrating the libraries into the project.
CMPE212 – Reminders Assignment 2 due today, 7pm.
Review of Previous Lesson
Java Code Review with CheckStyle
Building LabKey with Gradle
Software Engineering and Architecture
Presentation transcript:

PROJECT JIGSAW – INTEGRATION WITH TOOLS JavaOne SAN FRANCISCO 03.10.2017 Alexandru Jecan Software Engineer | Author | Trainer | Speaker | Consultant

SUMMARY 1 2 3 4 5 6 7 Integration with Build Tools Apache Maven Maven Compiler Plugin 4 Maven Exec Plugin 5 Backward Compatibility Using Maven Toolchain Plugin Toolchain Plugin 6 Maven JDeps Plugin 7 Maven Jmod Plugin 02 PROJECT JIGSAW – INTEGRATION WITH TOOLS

SUMMARY 8 9 10 11 12 Maven Jlink Plugin Maven Dependency Plugin Gradle Ant 12 Loom 03 PROJECT JIGSAW – INTEGRATION WITH TOOLS

SUMMARY 13 14 15 Moditect SonarJava Graphviz Gradle Ant Loom 04 PROJECT JIGSAW – INTEGRATION WITH TOOLS

SUMMARY 16 Integration with Integrated Development Environments 17 NetBeans support 18 Eclipse support 19 Intellij IDEA support 20 JDK 9 Ready Status 21 JDK 9 Ready Libraries 22 Status Modularization Third-party Libraries 05 PROJECT JIGSAW – INTEGRATION WITH TOOLS

SUMMARY 23 24 25 26 27 28 29 Modularized Third-party Libraries How to Modularize a Library 25 Encapsulated JDK internal APIs 26 Not resolved platform modules 27 Cyclic dependencies 28 Split packages 29 Java 9 Modularity Revealed book 06 PROJECT JIGSAW – INTEGRATION WITH TOOLS

QUESTION What do you expect from a tool to do in order to make development using Jigsaw easier? 07 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTEGRATION WITH BUILD TOOLS Jigsaw Build Tools Strong encapsulation Build the project Services Central repository Link into run-time images Dependency management Download artifacts Reliable configuration Record dependencies Record artifacts Verify at compile time and run time Verify for compilation Select artifacts for compilation The Java Module System, Nicolai Parlog, Manning 08 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTEGRATION WITH BUILD TOOLS Prior to JDK 9 Build Tools Class path JDK 9+ Class path Build Tools Module path 09 PROJECT JIGSAW – INTEGRATION WITH TOOLS

APACHE MAVEN Only Maven 3+ supports Java 9 No changes were performed in Maven Core in order to make Maven run on Java 9 Maven can also use the module path for compilation (besides the class path) Normal modules as well as automatic modules can be defined as dependencies The presence of module-info.java decides if Maven uses the module path or not 10 PROJECT JIGSAW – INTEGRATION WITH TOOLS

APACHE MAVEN The <groupId>, <artifactId> and <version> from pom.xml are not related to the name of the module from module-info.java To add a dependency in pom.xml, the Maven specific names are used, as before To require a module in module-info.java, the name of the module from the module descriptors is used 11 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN COMPILER PLUGIN Offers support for JPMS starting with version 3.6.0 Latest version = 3.7.0 (as of September 2017) Requires JDK 7+ source and target have to be minimum 6 Module-info is compiled as well During the compile phase, when a module-info.java file is found, it automatically switches to the module path 12 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN COMPILER PLUGIN Flags like --add-modules or --add-exports can be added directly in the pom.xml <compilerArgs> <arg>--add-modules</arg> <arg>java.xml.bind</arg> </compilerArgs> <compilerArgs> <arg>--add-exports</arg> <arg>java.base/sun.net=myModule</arg> </compilerArgs> 13 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN COMPILER PLUGIN PROJECT JIGSAW – INTEGRATION WITH TOOLS <artifactId>maven-compiler-plugin</artifactId> <version>3.6.0</version> <executions> <execution> <id>example</id> <goals> <goal>compile</goal> </goals> <configuration> <compilerArgs> <arg>--add-exports</arg> <arg>java.base/sun.net=myModule</arg> <arg>--add-modules</arg> <arg>java.xml.bind</arg> </compilerArgs> </configuration> </execution> </executions> </plugin> 14 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN COMPILER PLUGIN A new tag called <release>, which has greater precendence over the <source> and <target> tags <release> corresponds to the option “maven.compiler.release” For providing backward compatibility: 1) Module-info should be compiled with --release 9 2) All the other sources compiled with --source < 9 and --target < 9 15 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN EXEC PLUGIN Java 9 Modularity Sander Mak, Paul Bakker, O’Reilly <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.6.0</version> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>${JAVA_HOME}/bin/java</executable> <arguments> <argument>--module-path</argument> <modulepath/> <argument>--module</argument> <argument>{myMainClass}</argument> <argument>${myArgument}</argument> </arguments> </configuration> </plugin> Java 9 Modularity Sander Mak, Paul Bakker, O’Reilly 16 PROJECT JIGSAW – INTEGRATION WITH TOOLS

BACKWARD COMPATIBILITY WITH MAVEN TOOLCHAIN PLUGIN Solves JEP 247: Compile for Older Platform Versions With toolchains, we can specify the JDKs installed on our system A project can be built using a specific version of the JDK that is independent from the one Maven is running with To use Toolchains: 1) The maven-toolchain-plugin should be adjusted 2) The toolchains.xml file should be adjusted 17 PROJECT JIGSAW – INTEGRATION WITH TOOLS

BACKWARD COMPATIBILITY WITH MAVEN TOOLCHAIN PLUGIN Toolchains required when we have the module-info.java file inside the sources and we want to compile it with an older version of Java 18 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN JDEPS PLUGIN discover all static dependencies of a library JDeps can: discover all static dependencies of a library discover the usages of internal JDK APIs automatically generate a module descriptor for a JAR file Maven JDeps Plugin has two goals: jdkinternals => checks if main classes depend on JDK-internal classes test-internals => checks if test classes depend on JDK-internal classes 19 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN JDEPS PLUGIN A compilation is necessary, since JDeps uses classes and not sources Should be used to test if your project is ready for JDK 9 By setting the <failOnWarning> option to true, the build will immediately fail if there are any warnings 20 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN JDEPS plugin PROJECT JIGSAW – INTEGRATION WITH TOOLS <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jdeps-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <id>testOnClasses</id> <goals> <goal>jdkinternals</goal> <goal>test-jdkinternals</goal> </goals> </execution> <id>testOnDependencies</id> <configuration> <failOnWarning>false</failOnWarning> <recursive>true</recursive> </configuration> </executions> </plugin> 21 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN JMOD PLUGIN Pre-release version (as of September 2017) First version = 3.0.0-alpha-1 Works with Maven 3+ and JDK 7+ Can create JMOD files (create goal) Can list the content of a JMOD file (list or describe goal) 22 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN JLINK PLUGIN Pre-release version (as of September 2017) First version = 3.0.0-alpha-1 Works with Maven 3+ and JDK 7+ Can create Modular Run-Time Images via Jlink from jar /JMOD files (jlink goal) Has parameters like: <addModules>, <bindServices>, <compression>, <limitModules>, etc. 23 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MAVEN DEPENDENCY PLUGIN The list option lists the groupId, artifactId together with the name of the module 24 PROJECT JIGSAW – INTEGRATION WITH TOOLS

GRADLE Works since the --illegal-access=permit option was set as default No --add-opens options necessary to build Gradle No first class support for Java 9 modules as of 26.09.2017 Running Java 9 on Gradle 4.1+ is supported Example of producing a multi-release JAR with Gradle => https://github.com/melix/mrjar-gradle Work in progress 25 PROJECT JIGSAW – INTEGRATION WITH TOOLS

ANT Ants java, javac and junit understand the new command-line parameters that are specific to JDK 9 modules Support for module path and upgrade module path added in Ant 1.9.7 Single module and multi module compilation supported Since Ant 1.9.8 and 1.10.0: <java>, <javac> and <junit> support JDK 9 modules Support for javac --release option ant.java.version holds the value “9” 26 PROJECT JIGSAW – INTEGRATION WITH TOOLS

LOOM Modern and lightweight build tool for Java 9+ YAML configuration Convention over configuration Build with Java 9 => first-class JPMS support (Optional) Minimalistic configuration Dependency resolution (powered by the Apache Maven Repository) Support for Junit 5, Checkstyle, SpotBugs, PMD, IntellijIDEA, Eclipse 27 PROJECT JIGSAW – INTEGRATION WITH TOOLS

LOOM https://loom.builders/ Loom source code => https://github.com/loom-build-tool/loom Loom documentation => https://loom-build-tool.readthedocs.io/en/latest/ Examples with Loom => https://github.com/loom-build-tool/loom-examples 28 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MODITECT https://github.com/moditect/moditect Maven plugin Can generate module-info.java descriptors for given artifacts on behalf of the specific information written by developers in pom.xml Can add module descriptors to JAR files Can create modular runtime images 29 PROJECT JIGSAW – INTEGRATION WITH TOOLS

SonarJAVA Support for JPMS starting from version 4.11 Recognizes new keywords related to modules from Java 9 Able to recognize and parse module-info.java Can handle the directives from module-info.java: requires, exports, opens, uses and provides ModuleDeclaration: {Annotation} [open] module Identifier {. Identifier} { {ModuleDirective} } 30 PROJECT JIGSAW – INTEGRATION WITH TOOLS

GRAPHVIZ Example for Windows: Open source graph visualization software Creates a graphical representation of Jigsaw modules and their dependencies: Example for Windows: jdeps -dotoutput jdeps-dotoutput modules/*.jar \Tools\Graphviz\release\bin\dot.exe –Tpng jdeps-dotoutput/summary.dot > graphviz-summary.png start graphviz-summary.png http://www.torsten-horn.de/techdocs/Jigsaw.html#Abh%C3%A4ngigkeitsgraph-mit-Graphviz 31 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTEGRATION WITH INTEGRATED DEVELOPMENT ENVIRONMENTS NetBeans Support Eclipse Support Intellij IDEA Support 32 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NETBEANS SUPPORT NetBeans 9 runs on top of JDK 8 as well as JDK 9 Support for JDK 9 starting from NetBeans 9 NetBeans 9 not yet officialy released (as of 26.09.2017) NetBeans 9 runs on top of JDK 8 as well as JDK 9 Two options: 1) Build with Ant from: https://github.com/apache/incubator-netbeans 2) Download the latest Development build from: https://builds.apache.org/job/incubator-netbeans-linux/ JDK 8 is mandatory for building NetBeans 9; cannot use JDK 9 or JDK 7 or older 33 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NETBEANS SUPPORT New Project Type => Java Modular Project One NetBeans project now supports multiple Jigsaw modules Support for Maven projects Set netbeans_jdkhome in netbeans.conf to point to JDK 9 installation https://cwiki.apache.org/confluence/display/NETBEANS/NetBeans+9.0+-+New+and+Noteworthy 34

NETBEANS SUPPORT Support for adding module-info (New =>Other => Java => Java Module Info) => supports code completion https://cwiki.apache.org/confluence/display/NETBEANS/NetBeans+9.0+-+New+and+Noteworthy 35 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NETBEANS SUPPORT Support for module path Edit – Compile – Debug cycle supported https://cwiki.apache.org/confluence/display/NETBEANS/NetBeans+9.0+-+New+and+Noteworthy 36 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NETBEANS SUPPORT Go to Tools => Java Platforms and verify that it is running on JDK 9 Project property can be set to JDK 9 Source/binary format for files can be set to JDK 9 37 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NETBEANS SUPPORT Module Dependency Graph using the Graph View http://wiki.netbeans.org/JDK9Support 38 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NETBEANS SUPPORT Support for packaging project files into a custom run-time using Jlink https://cwiki.apache.org/confluence/display/NETBEANS/NetBeans+9.0+-+New+and+Noteworthy 39 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NETBEANS SUPPORT JShell integration https://cwiki.apache.org/confluence/display/NETBEANS/NetBeans+9.0+-+New+and+Noteworthy 40

ECLIPSE SUPPORT Eclipse Oxygen with Java 9 support For Java 9 support, you can also update other Eclipse IDE to Eclipse 4.7. More info => https://marketplace.eclipse.org/content/java-9-support-beta-oxygen https://wiki.eclipse.org/Photon/Simultaneous_Release_Plan#Schedule 41 PROJECT JIGSAW – INTEGRATION WITH TOOLS

ECLISE SUPPORT Add JRE and JDK 9 as installed JRE Support for JavaSE-9 execution environment Module compilation IDE can be launched with JDK 8 or JDK 9 Support for module path + class path 42 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Support for Jigsaw modules starting from version 2017.1 Enhancements in versions 2017.2 and 2017.3 Code completion in the module-info Each Jigsaw module has to correspond to an Intellij IDEA module For a module, “Mark directory as => Sources root” 43 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Supports module path, class path, module path + class path 44 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT 45 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT 46 PROJECT JIGSAW – INTEGRATION WITH TOOLS

Intellij idea support 47 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Package not exported => “Package not found” No readability defined in module-info 48 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Recognizes when a platform module is not required Can suggest to add missing requires clauses in module-info 49

INTELLIJ IDEA SUPPORT Code completion in module-info Code completion for exporting packages 50

INTELLIJ IDEA SUPPORT Both Intellij IDEA module dependencies as well as Jigsaw module dependencies have to be declared module com.javaone.application { requires com.javaone.service; } 51 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Dependency Diagram for Java 9 52 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Opens clause in open module not allowed Duplicate clauses in module-info detected https://blog.jetbrains.com/idea/2017/07/support-for-java-9-in-intellij-idea-2017-2/ 53 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Find usages https://blog.jetbrains.com/idea/2017/07/support-for-java-9-in-intellij-idea-2017-2/ 54 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Inspection Possibility to highlight the automatic modules, etc. 55 PROJECT JIGSAW – INTEGRATION WITH TOOLS

INTELLIJ IDEA SUPPORT Support for Maven projects Automatically runs with the module path instead of class path Quick fixes for adding items in the module-info.java file 56 PROJECT JIGSAW – INTEGRATION WITH TOOLS

JDK 9 READY STATUS (AS OF 24.09.17) https://wiki.openjdk.java.net/display/quality/Quality+Outreach 57 PROJECT JIGSAW – INTEGRATION WITH TOOLS

JDK 9 READY LIBRARIES (AS OF 24.09.17) Library Name JDK 9 Ready JDK 9 Ready starting from Version Apache Derby Yes 10.13.1.1 Apache Log4j 2.9.0 Apache Lucene / Solr 7.0 (for both Lucene and Solr) Apache Maven 3.0 Apache PDFBox 2.0.8 Apache POI 3.17 bt CruiseControl GraphHopper https://wiki.openjdk.java.net/display/quality/Quality+Outreach 58 PROJECT JIGSAW – INTEGRATION WITH TOOLS

JDK 9 READY LIBRARIES (AS OF 24.09.17) Library Name JDK 9 Ready HeapStats Yes Hibernate Jackson JaCoCo JITWatch JOSM Junit 5 LWJGL Rapidoid https://wiki.openjdk.java.net/display/quality/Quality+Outreach 59 PROJECT JIGSAW – INTEGRATION WITH TOOLS

JDK 9 READY LIBRARIES (AS OF 24.09.17) Library Name JDK 9 Ready RedHat Wildfly Yes RxJava Spotbugs Woodstox https://wiki.openjdk.java.net/display/quality/Quality+Outreach 60 PROJECT JIGSAW – INTEGRATION WITH TOOLS

JDK 9 READY SOON LIBRARIES (AS OF 24.09.17) Library Name Apache JMeter DataCleaner Golo JLine Roaring Apache MetaModel Drools Groovy Jboss-Forge Spring Framework Apache Tomcat EasyMock Hazelcast Kotlin ZXing Apache Tika Eclipse Jetty HSQLDB Objenesis Byteman Ehcache JavaEWAH OptaPlanner Classworlds ElasticSearch JBoss Tools oVirt engine https://wiki.openjdk.java.net/display/quality/Quality+Outreach 61 PROJECT JIGSAW – INTEGRATION WITH TOOLS

STATUS MODULARIZATION THIRD-PARTY LIBRARIES 62 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MODULARIZED THIRD-PARTY LIBRARIES Library Name Modularized (as of 23.09.2017) Accumulo No ActiveMQ Ambari Ant Aurora Avro Axis Cassandra CloudStack Cordova CouchDB 63 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MODULARIZED THIRD-PARTY LIBRARIES Library Name Modularized (as of 23.09.2017) EclipseLink No Falcon Flex Flume Geronimo Grails Groovy Guava Hadoop Hbase Hibernate 64 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MODULARIZED THIRD-PARTY LIBRARIES Library Name Modularized (as of 23.09.2017) Jackrabbit No Jackson JDO Jersey Jetty Joda Jsoup Kafka Knox Log4j Lombok 65 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MODULARIZED THIRD-PARTY LIBRARIES Library Name Modularized (as of 23.09.2017) Lucene No Mahout Maven Mesos Mockito Oozie OpenJPA Perl Pig PowerMock Quarz 66 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MODULARIZED THIRD-PARTY LIBRARIES Library Name Modularized (as of 23.09.2017) SLF4J Yes Spark No Spring Struts Subversion SWT Tapestry TestNG Tiles Tomcat Vaadin 67 PROJECT JIGSAW – INTEGRATION WITH TOOLS

MODULARIZED THIRD-PARTY LIBRARIES Library Name Modularized (as of 23.09.2017) Velocity No Xerces ZooKeeper 68 PROJECT JIGSAW – INTEGRATION WITH TOOLS

HOW TO MODULARIZE A LIBRARY Modularize the codebase by introducing a module-info.java file for each module A module-info.java file can be: 1) Created manually by the developers 2) Automatically generated using the JDeps tool with the option --generate-module-info The most common four issues that can occur during the modularization of a library are: 1) Encapsulated JDK internal APIs 3) Cyclic dependencies 2) Not resolved modules 4) Split packages 69 PROJECT JIGSAW – INTEGRATION WITH TOOLS

ENCAPSULATED JDK INTERNAL APIS Most of the internal JDK APIs are inaccessible in Java 9 Trying to access them causes a compilation error Internal APIs are in the sun.* package, but not only The module jdk.unsupported is still accessible: sun.misc.Unsafe, sun.reflect.Reflection, sun.misc.Signal, sun.reflect.ReflectionFactory, sun.misc.SignalHandler 70 PROJECT JIGSAW – INTEGRATION WITH TOOLS

ENCAPSULATED JDK INTERNAL APIS Breaking encapsulation of the JDK Internal APIs: 71 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NOT RESOLVED PLATFORM MODULES Not all the platform modules from the JDK are available at compile-time All the packages from module java.se.ee are not available at compile-time: java.xml.ws, java.xml.bind, java.corba, java.activation, java.xml.ws.annotations => package not exist error encountered at compile-time 72 PROJECT JIGSAW – INTEGRATION WITH TOOLS

NOT RESOLVED PLATFORM MODULES Solution: add the module that contains the needed packages in the graph of modules using the --add-modules options --add-modules java.xml.bind Use --add-modules both at compile-time and at run-time 73 PROJECT JIGSAW – INTEGRATION WITH TOOLS

CYCLIC DEPENDENCIES Forbidden at compile-time (between modules) JPMS does not allow cycles in the “requires” clauses JPMS allows cycles in the “reads” relation of run-time modules module A { requires B; } module B { requires A; } 74 PROJECT JIGSAW – INTEGRATION WITH TOOLS

CYCLIC DEPENDENCIES One solution is to merge the JARs into a single module Redesign might be necessary to a higher degree Cycles can be broken by using interfaces 75 PROJECT JIGSAW – INTEGRATION WITH TOOLS

SPLIT PACKAGES Modules that contain packages having the same name must not interfere with each other Solutions for JAR files: Create a single JAR file out of the two JAR files Rename one of the package Solutions for modules: Create a single module out of two or more modules Create a third module Remove the package dependencies 76 PROJECT JIGSAW – INTEGRATION WITH TOOLS

Java 9 Modularity Revealed Apress, 2017 221 pages ISBN: 978 - 1484227121

@alexandrujecan alexandrujecan alexandrujecan.com alexandrujecan@gmail.com