advanced modular development -...
TRANSCRIPT
![Page 1: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/1.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Advanced Modular DevelopmentCON6821
Mark Reinhold, Alex Buckley, Alan BatemanJava Platform Group, OracleOctober 2015
![Page 2: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/2.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Sessions
Prepare for JDK 9
Introduction to Modular Development
Advanced Modular Development
Project Jigsaw: Under the Hood
Project Jigsaw Hack Session
3
2
2
1
4
5
![Page 3: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/3.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Application Migration
3
![Page 4: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/4.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Typical application
4
JAR JAR
JAR
JARJAR
JAR JAR
JAR
JARJAR JAR
JAR
JDK
JAR JAR
JAR
JARJAR
JAR
JAR
JARJAR
![Page 5: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/5.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Typical application
5
JAR JAR
JAR
JAR
JAR
JARJAR JAR
JARJAR JAR
JAR
JARJAR
JAR
JARJAR
modulejava.base
modulejava.logging
modulejava.sql
modulejava.xml
JAR
JAR
JAR
JAR
JAR
![Page 6: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/6.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 6
jackson-databind-2.6.3.jar
myapp.jar
modulejava.base
modulejava.logging
mylib.jar
modulejava.xml
modulejava.sql
jackson-annotations-2.6.0.jarjackson-core-2.6.3.jar
SampleScenario
![Page 7: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/7.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 7
$ java -cp \ lib/myapp.jar:\ lib/mylib.jar:\ lib/jackson-core-2.6.3.jar:\ lib/jackson-databind-2.6.3.jar:\ lib/jackson-annotations-2.6.0.jar\ myapp.Main
Running my application
![Page 8: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/8.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 8
jackson-databind-2.6.3.jar
modulemyapp
modulemylib
jackson-annotations-2.6.0.jarjackson-core-2.6.3.jar
Migrating from the top down
modulejava.base
modulejava.logging
modulejava.xml
modulejava.sql
![Page 9: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/9.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Migrating from the top down
• module myapp requires?• module myapp exports?
• module mylib requires?• module mylib exports?
9
![Page 10: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/10.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 10
$ jdeps -s lib/myapp.jar lib/mylib.jar myapp.jar -> lib/jackson-core-2.6.3.jar myapp.jar -> lib/jackson-databind-2.6.3.jar myapp.jar -> mylib.jar myapp.jar -> java.base myapp.jar -> java.sql mylib.jar -> java.base
![Page 11: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/11.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 11
// src/mylib/module-info.java module mylib { requires java.base; exports com.myapp.lib.util to myapp; }
![Page 12: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/12.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 12
// src/myapp/module-info.java module myapp { requires mylib; requires java.base; requires java.sql; ??? requires jackson.core ??? ??? requires jackson.databind ??? }
![Page 13: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/13.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 13
If only …
jackson-databind-2.6.3.jar
jackson-core-2.6.3.jar
jackson-annotations-2.6.0.jar
modulejackson.core
modulejackson.databind
modulejackson.annotations
![Page 14: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/14.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 14
// src/myapp/module-info.java module myapp { requires mylib; requires java.base; requires java.sql; requires jackson.core; requires jackson.databind; }
![Page 15: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/15.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 15
modulejackson.databind
modulemyapp
modulejava.base
modulejava.logging
modulemylib
modulejava.xml
modulejava.sql
modulejackson.annotations
modulejackson.core
![Page 16: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/16.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Automatic modules
• “Real” modules• No changes to someone else’s JAR file :-)• Module name derived from JAR file name• Exports all its packages• Requires all other modules
16
![Page 17: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/17.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 17
modulemyapp
modulemylib
modulejackson.databind
modulejackson.annotations
modulejackson.core
modulejava.xml
modulejava.sql
modulejava.logging
modulejava.base
![Page 18: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/18.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 18
![Page 19: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/19.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 19
lib/jackson-core-2.6.3.jar lib/jackson-databind-2.6.3.jar lib/jackson-annotations-2.6.0.jar
src/myapp/module-info.java src/myapp/...
src/mylib/module-info.java src/mylib/...
$ javac -modulesourcepath src -mp lib -d mods ...
$ jar --create --file mlib/mylib.jar -C mods/mylib .
$ jar --create --file mlib/myapp.jar -C mods/myapp . \ —-main-class myapp.Main
![Page 20: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/20.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 20
$ java -mp mlib:lib —m myapp
$ java -cp \ lib/myapp.jar:\ lib/mylib.jar:\ lib/jackson-core-2.6.3.jar:\ lib/jackson-databind-2.6.3.jar:\ lib/jackson-annotations-2.6.0.jar \ myapp.Main
![Page 21: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/21.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Library Migration
21
![Page 22: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/22.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 22
jackson-databind-2.6.3.jar
myapp.jar
modulejava.base
modulejava.logging
mylib.jar
modulejava.xml
modulejava.sql
jackson-annotations-2.6.0.jarjackson-core-2.6.3.jar
SampleScenario
![Page 23: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/23.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 23
modulejackson.databind
myapp.jar
modulejava.base
modulejava.logging
mylib.jar
modulejava.xml
modulejava.sql
modulejackson.annotations
modulejackson.core
Migrating from the bottom up
![Page 24: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/24.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Migrating from the bottom
• module jackson.core requires?• module jackson.core exports?• module jackson.databind requires?• module jackson.databind exports?• module jackson.annotations requires?• module jackson.annotations exports?
24
![Page 25: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/25.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Requires?
25
$ jdeps -s lib/jackson*.jar jackson-annotations-2.6.0.jar -> java.base jackson-core-2.6.3.jar -> java.base jackson-databind-2.6.3.jar -> lib/jackson-annotations-2.6.0.jar jackson-databind-2.6.3.jar -> lib/jackson-core-2.6.3.jar jackson-databind-2.6.3.jar -> java.base jackson-databind-2.6.3.jar -> java.sql jackson-databind-2.6.3.jar -> java.xml
![Page 26: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/26.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 26
jackson.databind
jackson.core java.sql
jackson.annotations java.xml
java.base
![Page 27: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/27.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Creating the module-info.java for each module
27
$ jdeps -genmoduleinfo src *.jar writing to src/jackson.annotations/module-info.java writing to src/jackson.databind/module-info.java writing to src/jackson.core/module-info.java
![Page 28: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/28.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 28
// src/jackson.databind/module-info.java module jackson.databind { requires public java.sql; requires public java.xml; requires public jackson.annotations; requires public jackson.core; exports com.fasterxml.jackson.databind; exports com.fasterxml.jackson.databind.annotation; exports com.fasterxml.jackson.databind.cfg; exports com.fasterxml.jackson.databind.deser; exports com.fasterxml.jackson.databind.deser.impl; exports com.fasterxml.jackson.databind.jsontype; exports com.fasterxml.jackson.databind.jsontype.impl; exports com.fasterxml.jackson.databind.module; exports com.fasterxml.jackson.databind.node; exports com.fasterxml.jackson.databind.ser; exports com.fasterxml.jackson.databind.ser.impl; exports com.fasterxml.jackson.databind.ser.std; exports com.fasterxml.jackson.databind.type; exports com.fasterxml.jackson.databind.util; }
![Page 29: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/29.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 29
// src/jackson.databind/module-info.java module jackson.databind { requires public java.sql; requires public java.xml; requires public jackson.annotations; requires public jackson.core; exports com.fasterxml.jackson.databind; exports com.fasterxml.jackson.databind.annotation; exports com.fasterxml.jackson.databind.cfg; exports com.fasterxml.jackson.databind.deser; exports com.fasterxml.jackson.databind.deser.impl; exports com.fasterxml.jackson.databind.jsontype; exports com.fasterxml.jackson.databind.jsontype.impl; exports com.fasterxml.jackson.databind.module; exports com.fasterxml.jackson.databind.node; exports com.fasterxml.jackson.databind.ser; exports com.fasterxml.jackson.databind.ser.impl; exports com.fasterxml.jackson.databind.ser.std; exports com.fasterxml.jackson.databind.type; exports com.fasterxml.jackson.databind.util; }
![Page 30: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/30.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 30
src/jackson.core/module-info.java src/jackson.core/...
src/jackson.databind/module-info.java src/jackson.databind/...
src/jackson.annotations/module-info.java src/jackson.annotations/...
$ javac -modulesourcepath src -d mods ...
$ jar --create --file mlib/jackson.core-2.6.3.jar \ —-module-version 2.6.3 -C mods/jackson.core .
$ jar --create --file mlib/jackson.databind-2.6.3.jar \ —-module-version 2.6.3 -C mods/jackson.databind .
$ jar --create --file mlib/jackson.annotations-2.6.0.jar \ —-module-version 2.6.0 -C mods/jackson.annotations .
![Page 31: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/31.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 31
modulejackson.databind
modulejava.logging
modulejava.sql
modulejackson.core
modulejackson.annotations
myapp.jar mylib.jar
modulejava.base
modulejava.xml
![Page 32: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/32.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 32
$ java -mp mlib -cp lib/myapp.jar:lib/mylib.jar -addmods jackson.databind \ myapp.Main
$ java -cp \ lib/myapp.jar:\ lib/mylib.jar:\ lib/jackson-core-2.6.3.jar:\ lib/jackson-databind-2.6.3.jar:\ lib/jackson-annotations-2.6.0.jar \ myapp.Main
![Page 33: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/33.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 33
$ java -mp mlib -cp lib/myapp.jar:lib/mylib.jar \ -addmods jackson.databind myapp.Main
Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make member of class app.MyValue accessible: module jackson.databind does not read <unnamed module @6536e911> at sun.reflect.Reflection.throwInaccessibleObjectException([email protected]/Reflection.java:464) at java.lang.reflect.AccessibleObject.checkCanSetAccessible([email protected]/AccessibleObject.java:175) at java.lang.reflect.Constructor.checkCanSetAccessible([email protected]/Constructor.java:174) at java.lang.reflect.Constructor.setAccessible([email protected]/Constructor.java:167) at com.fasterxml.jackson.databind.util.ClassUtil.checkAndFixAccess(jackson.databind/ClassUtil.java:505) at com.fasterxml.jackson.databind.deser.impl.CreatorCollector._fixAccess(jackson.databind/ CreatorCollector.java:280) at com.fasterxml.jackson.databind.deser.impl.CreatorCollector.setDefaultCreator(jackson.databind/ CreatorCollector.java:155) :
![Page 34: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/34.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 34
jackson.databind
jackson.core
java.sqljackson.annotations
java.xml
<unnamed>
java.base
![Page 35: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/35.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 35
package java.lang.reflect;
public final class Module {
public String getName();
public boolean canRead(Module source); public Module addReads(Module source);
… }
![Page 36: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/36.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 36
Module source = clazz.getModule();this.getClass().getModule().addReads(source);
![Page 37: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/37.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 37
jackson.databind
jackson.core
jackson.annotations
<unnamed>
java.sql java.xmljava.base
![Page 38: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/38.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Putting it all together
38
![Page 39: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/39.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 39
modulejackson.databind
modulejava.logging
modulejava.sql
modulejackson.core
modulejackson.annotations
modulejava.base
modulejava.xml
![Page 40: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/40.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 40
modulejackson.databind
modulejava.logging
modulejava.sql
modulejackson.core
modulejackson.annotations
modulejava.base
modulejava.xml
modulemyapp
modulemylib
![Page 41: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/41.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 41
$ java -mp mlib -m myapp
![Page 42: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/42.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Linking
42
![Page 43: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/43.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 43
$ jlink —mp $JDKMODS:mlib —addmods myapp —output myimage
$ ls myimage bin conf lib release
$ ls myimage/bin myapp java keytool
$ myimage/bin/java -listmods myapp mylib [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
![Page 44: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/44.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 44
$ myimage/bin/java -m myapp Greetings from myapp, here’s some json!
![Page 45: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/45.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 45
$ myimage/bin/myapp Greetings from myapp, here’s some json!
![Page 46: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/46.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Summary
• Freedom to adopt modules at your own pace• Modularize your application before its libraries• Modularize libraries independently
• Different kinds of modules• Explicit vs. automatic
• Some libraries will need changes to work as modules
46
![Page 47: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/47.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 47
Go forth and modularize!
![Page 48: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/48.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Other sessions, this room
• Project Jigsaw: Under the Hood @ 5.30pm• Project Jigsaw Hack Session @ Tuesday 8.30am
48
![Page 49: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/49.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 49
More Information
OpenJDK Project Jigsaw
http://openjdk.java.net/projects/jigsaw/
mailto:[email protected]
Early Access Builds
https://jdk9.java.net/jigsaw/
![Page 50: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/50.jpg)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor StatementThe preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
50
![Page 51: Advanced Modular Development - OpenJDKopenjdk.java.net/projects/jigsaw/talks/adv-modular-dev-j1-2015.pdf · Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |](https://reader034.vdocuments.net/reader034/viewer/2022051813/6031584b40b6eb3e7c7d13b6/html5/thumbnails/51.jpg)