tweak your modules java platform module system
play

Tweak Your Modules! Java Platform Module System Stephan Herrmann - PowerPoint PPT Presentation

J D T Tweak Your Modules! Java Platform Module System Stephan Herrmann Simply Retail. J JDT embraces Java 9 / Part II D T We've all migrated to Java 11 From here adopting new Java versions is a breeze Compatibility for all!


  1. J D T Tweak Your Modules! Java Platform Module System Stephan Herrmann Simply Retail.

  2. J JDT embraces Java™ 9 / Part II D T We've all migrated to Java 11 From here adopting new Java versions is a breeze Compatibility for all! … and live happily ever after ... Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 2

  3. J JDT embraces Java™ 9 / Part II D T We've all migrated to Java 11 From here adopting new Java versions is a breeze Compatibility for all! … and live happily ever after ... Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 3

  4. J Some Modules are More Equal than Others D T Named modules System modules Wiring à la JPMS: part of JRE, implicitly available (not all!) ● Regular modules Module 1 Module 2 user defjned requires ● have module-info ● package a package a.c Automatic modules user defjned ● C0 C1 C2 C1 C2 no module-info ● Unnamed module package a.b package a.b All the rest – “legacy” C1 C3 C1 C4 Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 6

  5. J Some Modules are More Equal than Others D T Named modules System modules part of JRE, implicitly available (not all!) ● Regular modules user defjned ● have module-info ● All Java9+ programs use modules, Automatic modules perhaps unknowingly. user defjned ● no module-info ● Unnamed module All the rest – “legacy” Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 7

  6. J D T Demo java.xml: Confmicting Modules Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 8

  7. J Targets are Moving D T JEP 320 JEP 320 Remove the Java EE and CORBA Modules Remove the Java EE and CORBA Modules What if your CORBA application should run on Java 9 and Java 11? Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 9

  8. J JEP 320 D T “In Java SE 9, the Java SE modules that contain Java EE and CORBA technologies are annotated as deprecated for removal , indicating the intent to remove them in a future release: java.xml.ws (JAX-WS, [...] SAAJ and Web Services Metadata) java.xml.bind (JAXB) java.activation (JAF) java.xml.ws.annotation (Common Annotations) java.corba (CORBA) java.transaction (JTA)” “Related modules in Java SE 9 are also deprecated for removal: java.se.ee (Aggregator module for the six modules above) jdk.xml.ws (Tools for JAX-WS) jdk.xml.bind (Tools for JAXB)” “This JEP will remove the nine modules listed above” – Fix Version/s: 11 Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 10

  9. J Options for using JAXB D T Java 9, named module Just require java.xml.bind => deprecation warning java.xml.bind Put jaxb-api.jar on the modulepath ● exists as a system module 1) remove system module ● deprecated for removal 2) add jaxb-api.jar to modulepath ● not visible by default Java 9, unnamed module to unnamed module Put jaxb-api.jar on the classpath Add system module java.xml.bind Java 11+ java.xml.bind Put jaxb-api.jar on the classpath / modulepath ● no longer a system module There is no option 2 Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 11

  10. J Options for using JAXB D T JEP 320: JEP 320: Java 9, named module “Since deprecating modules for removal merely “Since deprecating modules for removal merely causes compile-time warnings, causes compile-time warnings, Just require java.xml.bind => deprecation warning JDK 9 took a more robust step to prepare JDK 9 took a more robust step to prepare java.xml.bind Put jaxb-api.jar on the modulepath developers for the actual removal of these developers for the actual removal of these ● exists as a system module modules in a future release: 1) remove system module modules in a future release: ● deprecated for removal The modules are not resolved in JDK 9 when The modules are not resolved in JDK 9 when 2) add jaxb-api.jar to modulepath code on the class path is compiled or run . code on the class path is compiled or run . ● not visible by default Java 9, unnamed module This allows developers on JDK 9 to deploy This allows developers on JDK 9 to deploy to unnamed module standalone versions of the Java EE and CORBA standalone versions of the Java EE and CORBA Put jaxb-api.jar on the classpath technologies on the class path , technologies on the class path , Add system module java.xml.bind just like on JDK 8. ” just like on JDK 8. ” Java 11+ java.xml.bind Put jaxb-api.jar on the classpath / modulepath ● no longer a system module “Alternatively, developers on JDK 9 can use the “Alternatively, developers on JDK 9 can use the There is no option 2 --add-modules fmag on the command line --add-modules fmag on the command line to resolve the modules in the JDK runtime image.” to resolve the modules in the JDK runtime image.” Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 12

  11. J Defjning a Modular Application D T Language: module-info.java module Directives: requires, exports, opens, provides, uses ● to, with Modifjers: open, transitive Command line options --add-modules … Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 13

  12. J D T Demo java.xml.bind: Module Goes Missing Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 14

  13. J Eclipse UI � Command Line D T Eclipse: Java Build Path > Module Dependencies > All Modules Add System Module � additionally adds required modules Remove � additionally removes requiring modules Command Line --add-modules � need to completely enumerate all additional modules --limit-modules � supports minimal form – will keep the transitive closure of listed modules To observe the correspondence: Show JPMS Options ... Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 15

  14. J The Case of Tests D T Modular project Main & test sources separated test sources marked (Thanks to Till Brychcy) JUnit on the classpath Eclipse implicitly adds these tweaks for running tests: --add-opens my.mod/test.pack=ALL-UNNAMED --add-reads my.mod=ALL-UNNAMED --add-modules=ALL-MODULE-PATH --patch-module my.mod=/path/to/MyProject/bin-test Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 16

  15. J Undeclared Dependencies D T can share packages & access internals of SUT patch-module SUT SUT Test refmective access add-opens sut add-reads add-reads to package of Test add-modules combined module SUT ensure SUT is in the can access JUnit module graph when JUnit launching JUnit JUnit framework can access SUT / Test Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 17

  16. J D T Demo: Modular Tests Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 18

  17. J Knobs & Dials D T module-info.java intrinsic properties Java Build Path determine set of observable modules superimpose more edges onto the module graph just during building of this project Launch Confjguration initialized from Java Build Path superimpose more edges onto the module graph determine the set of root modules Special modules names add-modules: ALL-SYSTEM, ALL-DEFAULT, ALL-MODULE-PATH add-reads, add-exports, add-opens: ALL-UNNAMED Stephan Herrmann @EclipseCon Europe 2019 – published under the EPL 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend