SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Downloaden Sie, um offline zu lesen
Moving to Module
Issues & Solutions
Project Jigsaw
Java in the Box
Yuichi Sakuraba
Module
Issues of Non-Modular Software
Issues of Modular Software
Motivation
-classpath
rt.jar
-classpath Issues
public is TOO Public
TOO Many Libraries
Which Libs Use which Libs?
Want to Hide “public” Class
rt.jar Issue
rt.jar
(Java SE 8)
Standard Library is TOO Huge
-classpath Issues
rt.jar Issue
Introduce Module
{ }Dependency
Disclosure Scope
Divide into Modules
According to Features
Module
JAR
module-info.java
Dependency
Disclosure Scope
Build
javac --module-path [directory] [source file]
-p
or
jar --create --file [JAR filename] 
-C [class file directory] .
Build
javac --module-path [directory] [source file]
-p
or
jar --create --file [JAR filename] 
-C [class file directory] .
Execution
java -p [directory] 
--module [module]/[main class]
-m
or
java -p mods 
-m net.javainthebox.jigsawsample/net.javainthebox.sample.Main
jigsawsample
java -p mods 
-m net.javainthebox.jigsawsample/net.javainthebox.sample.Main
jigsawsample
javafx.media
javafx.controls
java -p mods 
-m net.javainthebox.jigsawsample/net.javainthebox.sample.Main
jigsawsample
javafx.media
javafx.controls
javafx.graphics
javafx.base
java -p mods 
-m net.javainthebox.jigsawsample/net.javainthebox.sample.Main
jigsawsample
javafx.media
javafx.controls
javafx.graphics
javafx.base
java.desktop
java.xml
jdk.jsobject
......
......
......
Tool Support
IDE IntelliJ IDEA
Eclipse
NetBeans
Only Nightly Build
Tool Support
IDE IntelliJ IDEA
Eclipse
NetBeans
Only Nightly Build
Build Tool Maven
Gradle
Need to Write Options
in Build File
jdeps Tool to Check Dependency
jdeps Tool to Check Dependency
C:samplemods>jdeps -s jigsawsample.jar
jigsawsample.jar -> java.base
jigsawsample.jar -> java.logging
jigsawsample.jar -> java.xml
jigsawsample.jar -> javafx.base
jigsawsample.jar -> javafx.controls
jigsawsample.jar -> javafx.graphics
jigsawsample.jar -> javafx.media
jdeps Tool to Check Dependency
C:samplemods>jdeps --generate-module-info . 
jigsawsample.jar
writing to .jigsawsamplemodule-info.java
module jigsawsample {
requires java.logging;
requires javafx.base;
requires javafx.controls;
requires javafx.media;
requires transitive java.xml;
requires transitive javafx.graphics;
exports net.javainthebox.sample;
exports net.javainthebox.sample.internal;
}
jdeps Tool to Check Dependency
C:samplemods>jdeps --generate-module-info . 
jigsawsample.jar
writing to .jigsawsamplemodule-info.java
module jigsawsample {
requires java.logging;
requires javafx.base;
requires javafx.controls;
requires javafx.media;
requires transitive java.xml;
requires transitive javafx.graphics;
exports net.javainthebox.sample;
exports net.javainthebox.sample.internal;
}
Edit as Necessary
Issues of
Non-Modular Software
Non-Disclosure API
Non-Standard Module
import com.sun.javafx.tk.FontMetrics;
import com.sun.javafx.tk.Toolkit;
import javafx.scene.text.Font;
public class FontSample {
public static void main(String... args) {
Font font = Font.font(24);
Toolkit toolkit = Toolkit.getToolkit();
FontMetrics metrics
= toolkit.getFontLoader().getFontMetrics(font);
System.out.println(metrics.getLineHeight());
}
}
C:fxsample>javac FontSample.java
FontSample.java:1: error: package com.sun.javafx.tk is not
visible
import com.sun.javafx.tk.FontMetrics;
^
(package com.sun.javafx.tk is declared in module javafx.
graphics, which does not export it to the unnamed module)
FontSample.java:2: error: package com.sun.javafx.tk is not
visible
import com.sun.javafx.tk.Toolkit;
^
(package com.sun.javafx.tk is declared in module javafx.
graphics, which does not export it to the unnamed module)
2 errors
import com.sun.javafx.tk.FontMetrics;
import com.sun.javafx.tk.Toolkit;
import javafx.scene.text.Font;
public class FontSample {
public static void main(String... args) {
Font font = Font.font(24);
Toolkit toolkit = Toolkit.getToolkit();
FontMetrics metrics
= toolkit.getFontLoader().getFontMetrics(font);
System.out.println(metrics.getLineHeight());
}
}
Non-Disclosure API
Non Exported Packages
com.sun...
sun...
java.awt.peer
Non-Disclosure API
Non Exported Packages
com.sun...
sun...
java.awt.peer
Exceptional API
sun.misc.Unsafe
sun.reflect.Reflection
(Remove in Future)
Solution
add export by
--add-exports option
--add-exports module/package=target
javac
java
Solution
add export by
--add-exports option
--add-exports module/package=target
javac
java
when non-modular system
target is ALL-UNNAMED
ex.
javac --add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED 
FontSample.java
public class FontSample {
public static void main(String... args) throws Exception {
Font font = Font.font(24);
FontMetrics metrics
= Toolkit.getToolkit().getFontLoader().getFontMetrics(font);
Class<FontMetrics> metricsClass = FontMetrics.class;
Field lineHeight
= metricsClass.getDeclaredField("lineHeight");
lineHeight.setAccessible(true);
System.out.println(lineHeight.getFloat(metrics));
}
}
C:fxsample>javac --add-exports 
javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED 
FontSample.java
C:fxsample>java --add-exports 
javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED FontSample
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by FontSample (file:/C:/fxsa
mple/) to field com.sun.javafx.tk.FontMetrics.lineHeight
WARNING: Please consider reporting this to the maintainers of
FontSample
WARNING: Use --illegal-access=warn to enable warnings of
further illegal reflective access operations
WARNING: All illegal access operations will be denied in a futu
re release
31.921875
public class FontSample {
public static void main(String... args) throws Exception {
Font font = Font.font(24);
FontMetrics metrics
= Toolkit.getToolkit().getFontLoader().getFontMetrics(font);
Class<FontMetrics> metricsClass = FontMetrics.class;
Field lineHeight
= metricsClass.getDeclaredField("lineHeight");
lineHeight.setAccessible(true);
System.out.println(lineHeight.getFloat(metrics));
}
}
Non-Disclosure API
Reflection
Reflective access to public
--add-exports
Non-Disclosure API
Reflection
Reflective access to public
--add-exports
Reflective access to non-public
--add-opens in execution
using setAccessible(true)
ex.
java --add-opens javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED 
FontSample.java
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import net.javainthebox.xml.Name;
public class JAXBSample {
public static void main(String... args) throws JAXBException {
JAXBContext context
= JAXBContext.newInstance("net.javainthebox.xml");
Unmarshaller unmarshaller = context.createUnmarshaller();
File file = new File("sakuraba.xml");
Name sakuraba = (Name)unmarshaller.unmarshal(file);
System.out.println(sakuraba.getFirst()
+ " " + sakuraba.getLast());
}
}
C:jaxbsample>javac JAXBSample.java
netjavaintheboxxmlName.java:11: error: package javax.xml.
bind.annotation is not visible
import javax.xml.bind.annotation.XmlAccessType;
^
(package javax.xml.bind.annotation is declared in module
java.xml.bind, which is not in the module graph)
<<skip the rest>>
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import net.javainthebox.xml.Name;
public class JAXBSample {
public static void main(String... args) throws JAXBException {
JAXBContext context
= JAXBContext.newInstance("net.javainthebox.xml");
Unmarshaller unmarshaller = context.createUnmarshaller();
File file = new File("sakuraba.xml");
Name sakuraba = (Name)unmarshaller.unmarshal(file);
System.out.println(sakuraba.getFirst()
+ " " + sakuraba.getLast());
}
}
Non-Standard Module
Modules not included
in standard modulepath
Non-Standard Module
Modules not included
in standard modulepath
JAXB
JAX-WS
CORBA
java.xml.bind
java.xml.ws
java.corba
These modules will be removed in future
You should use the modules supplied by Java EE
Non-Standard Module
Modules not included
in standard modulepath
JAXB
JAX-WS
CORBA
java.xml.bind
java.xml.ws
java.corba
These modules will be removed in future
You should use the modules supplied by Java EE
Incubator jdk.incubator.httpclient
Solution
Add Modules by
--add-modules option
--add-modules module
javac
java
ex)
java --add-modules java.xml.bind JAXBSample
Issues of
Modular Software
modulepath
classpath
In Java SE 8, Only classpath is Used
In Java SE 8, Only classpath is Used
Module and Non-Module are Used
In Java SE 9,
modulepath classpath
In Java SE 8, Only classpath is Used
Module and Non-Module are Used
In Java SE 9,
modulepath classpath
specified in module-info.java
Module CAN Access Only Modules
foo.jar bar.jarmyapp.jar
Module Non-Module
foo.jar bar.jarmyapp.jar
Module Non-Module
Access Directly: Automatic Module
Access Indirectly: Unnamed Module
foo.jar bar.jarmyapp.jar
Module Non-Module
Access Directly: Automatic Module
Access Indirectly: Unnamed Module
Automatic Unnamed
foo.jar bar.jarmyapp.jar
Module Non-Module
Automatic Unnamed
modulepath classpath
foo.jar bar.jarmyapp.jar
Module Non-Module
Automatic Unnamed
modulepath classpath
Automatic Module: Named Module
Unnamed Module: No Name Modu
MANIFEST.MF Automatic-Module-Name
or JAR filename
Automatic Module Name is Defined by
foo.jar bar.jarmyapp.jar
Module Non-Module
Automatic Unnamed
modulepath classpath
module myapp {
requires foo;
}
> java -cp bar.jar -p mod 
-m myapp/myapp.Main
foo.jar bar.jarmyapp.jar
java.xml.bind
Module Non-Module
Automatic Module Can’
Describe Dependency
t
foo.jar bar.jarmyapp.jar
java.xml.bind
Module Non-Module
Automatic Module Can’
Describe Dependency
t
> java -cp bar.jar -p mods 
--add-modules java.xml.bind 
-m myapp/myapp.Main
foo.jar bar.jarmyapp.jar
java.xml.bind
Module Non-Module
Automatic Module Can’
Describe Dependency
t
> java -cp bar.jar -p mods 
--add-modules java.xml.bind 
-m myapp/myapp.Main
> java -cp bar.jar -p mods 
--add-modules ALL-MODULE-PATH 
-m myapp/myapp.Main
If You Don’ t Know Dependencies
Conclusion
Non-Disclosure API
Issues of Non-Modular Software
Non-Standard Module
May Remove These APIs/Modules in Future
modulepath & classpath
Issues of Modular Software
May Use Only modulepath in Future??
Moving to Module
Issues & Solutions
Project Jigsaw
Java in the Box
Yuichi Sakuraba

Weitere ähnliche Inhalte

Was ist angesagt?

Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)DevelopIntelligence
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code ExamplesNaresh Chintalcheru
 
When and How Using Structural Information to Improve IR-Based Traceability Re...
When and How Using Structural Information to Improve IR-Based Traceability Re...When and How Using Structural Information to Improve IR-Based Traceability Re...
When and How Using Structural Information to Improve IR-Based Traceability Re...Annibale Panichella
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java ProgrammersEnno Runne
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeletonIram Ramrajkar
 
More topics on Java
More topics on JavaMore topics on Java
More topics on JavaAhmed Misbah
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7Deniz Oguz
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.Tarunsingh198
 
Java Interview Questions Answers Guide
Java Interview Questions Answers GuideJava Interview Questions Answers Guide
Java Interview Questions Answers GuideDaisyWatson5
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manualLaura Popovici
 
Core Java- An advanced review of features
Core Java- An advanced review of featuresCore Java- An advanced review of features
Core Java- An advanced review of featuresvidyamittal
 
PROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IIPROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IISivaSankari36
 

Was ist angesagt? (20)

Spock
SpockSpock
Spock
 
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
Whats New in Java 5, 6, & 7 (Webinar Presentation - June 2013)
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
 
When and How Using Structural Information to Improve IR-Based Traceability Re...
When and How Using Structural Information to Improve IR-Based Traceability Re...When and How Using Structural Information to Improve IR-Based Traceability Re...
When and How Using Structural Information to Improve IR-Based Traceability Re...
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java Programmers
 
Clojure: a LISP for the JVM
Clojure: a LISP for the JVMClojure: a LISP for the JVM
Clojure: a LISP for the JVM
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Java Interview Questions Answers Guide
Java Interview Questions Answers GuideJava Interview Questions Answers Guide
Java Interview Questions Answers Guide
 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manual
 
Core Java- An advanced review of features
Core Java- An advanced review of featuresCore Java- An advanced review of features
Core Java- An advanced review of features
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
PROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part IIPROGRAMMING IN JAVA-unit 3-part II
PROGRAMMING IN JAVA-unit 3-part II
 
Basic java for Android Developer
Basic java for Android DeveloperBasic java for Android Developer
Basic java for Android Developer
 

Ähnlich wie Moving to Module: Issues & Solutions

Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpathAlexis Hassler
 
LausanneJUG 2017 - Jigsaw est prêt à tuer le classpath
LausanneJUG 2017 - Jigsaw est prêt à tuer le classpathLausanneJUG 2017 - Jigsaw est prêt à tuer le classpath
LausanneJUG 2017 - Jigsaw est prêt à tuer le classpathAlexis Hassler
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
NJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docx
NJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docxNJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docx
NJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docxcurwenmichaela
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpathLyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpathAlexis Hassler
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath Alexis Hassler
 
Java 9 Module System
Java 9 Module SystemJava 9 Module System
Java 9 Module SystemHasan Ünal
 
Java Programming and J2ME: The Basics
Java Programming and J2ME: The BasicsJava Programming and J2ME: The Basics
Java Programming and J2ME: The Basicstosine
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modulesPaul Bakker
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesGlobalLogic Ukraine
 
ElsassJUG - Le classpath n'est pas mort...
ElsassJUG - Le classpath n'est pas mort...ElsassJUG - Le classpath n'est pas mort...
ElsassJUG - Le classpath n'est pas mort...Alexis Hassler
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satyaSatya Johnny
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java WorkshopSimon Ritter
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemGuardSquare
 

Ähnlich wie Moving to Module: Issues & Solutions (20)

Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
 
LausanneJUG 2017 - Jigsaw est prêt à tuer le classpath
LausanneJUG 2017 - Jigsaw est prêt à tuer le classpathLausanneJUG 2017 - Jigsaw est prêt à tuer le classpath
LausanneJUG 2017 - Jigsaw est prêt à tuer le classpath
 
Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Java9
Java9Java9
Java9
 
NJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docx
NJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docxNJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docx
NJB_Coll_Lib1javadocallclasses-frame.htmlAll ClassesDynamicArr.docx
 
Java Quiz - Meetup
Java Quiz - MeetupJava Quiz - Meetup
Java Quiz - Meetup
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpathLyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Java 9 Module System
Java 9 Module SystemJava 9 Module System
Java 9 Module System
 
Java Programming - 05 access control in java
Java Programming - 05 access control in javaJava Programming - 05 access control in java
Java Programming - 05 access control in java
 
Java Programming and J2ME: The Basics
Java Programming and J2ME: The BasicsJava Programming and J2ME: The Basics
Java Programming and J2ME: The Basics
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modules
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration IssuesJava 9: Deep Dive into Modularity and Dealing with Migration Issues
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
 
ElsassJUG - Le classpath n'est pas mort...
ElsassJUG - Le classpath n'est pas mort...ElsassJUG - Le classpath n'est pas mort...
ElsassJUG - Le classpath n'est pas mort...
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
 

Mehr von Yuichi Sakuraba

Vector API - Javaによるベクターコンピューティング
Vector API - JavaによるベクターコンピューティングVector API - Javaによるベクターコンピューティング
Vector API - JavaによるベクターコンピューティングYuichi Sakuraba
 
Oracle Code One - Java KeynoteとJava SE
Oracle Code One - Java KeynoteとJava SEOracle Code One - Java KeynoteとJava SE
Oracle Code One - Java KeynoteとJava SEYuichi Sakuraba
 
Project Loom + Project Panama
Project Loom + Project PanamaProject Loom + Project Panama
Project Loom + Project PanamaYuichi Sakuraba
 
Project Loom - 限定継続と軽量スレッド -
Project Loom - 限定継続と軽量スレッド - Project Loom - 限定継続と軽量スレッド -
Project Loom - 限定継続と軽量スレッド - Yuichi Sakuraba
 
Oracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE UpdateOracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE UpdateYuichi Sakuraba
 
今こそStream API入門
今こそStream API入門今こそStream API入門
今こそStream API入門Yuichi Sakuraba
 
Oracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE UpdateOracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE UpdateYuichi Sakuraba
 
Learn Language 2018 Java Language Update
Learn Language 2018 Java Language Update Learn Language 2018 Java Language Update
Learn Language 2018 Java Language Update Yuichi Sakuraba
 
Dockerに向けて、Javaもダイエット
Dockerに向けて、JavaもダイエットDockerに向けて、Javaもダイエット
Dockerに向けて、JavaもダイエットYuichi Sakuraba
 
Migration Guide to Java SE 10, and also Java SE 11
Migration Guide to Java SE 10, and also Java SE 11Migration Guide to Java SE 10, and also Java SE 11
Migration Guide to Java SE 10, and also Java SE 11Yuichi Sakuraba
 
琥珀色のJava - Project Amber -
琥珀色のJava - Project Amber -琥珀色のJava - Project Amber -
琥珀色のJava - Project Amber -Yuichi Sakuraba
 
モジュール移行の課題と対策
モジュール移行の課題と対策モジュール移行の課題と対策
モジュール移行の課題と対策Yuichi Sakuraba
 
Project Jigsawと、ちょっとだけVector API
Project Jigsawと、ちょっとだけVector APIProject Jigsawと、ちょっとだけVector API
Project Jigsawと、ちょっとだけVector APIYuichi Sakuraba
 
Java SEの現在、過去 そして未来
Java SEの現在、過去 そして未来Java SEの現在、過去 そして未来
Java SEの現在、過去 そして未来Yuichi Sakuraba
 
Introduction of Project Jigsaw
Introduction of Project JigsawIntroduction of Project Jigsaw
Introduction of Project JigsawYuichi Sakuraba
 
Encouragement of Java SE 9
Encouragement of Java SE 9Encouragement of Java SE 9
Encouragement of Java SE 9Yuichi Sakuraba
 

Mehr von Yuichi Sakuraba (20)

Vector API - Javaによるベクターコンピューティング
Vector API - JavaによるベクターコンピューティングVector API - Javaによるベクターコンピューティング
Vector API - Javaによるベクターコンピューティング
 
Oracle Code One - Java KeynoteとJava SE
Oracle Code One - Java KeynoteとJava SEOracle Code One - Java KeynoteとJava SE
Oracle Code One - Java KeynoteとJava SE
 
Project Loom + Project Panama
Project Loom + Project PanamaProject Loom + Project Panama
Project Loom + Project Panama
 
Project Loom - 限定継続と軽量スレッド -
Project Loom - 限定継続と軽量スレッド - Project Loom - 限定継続と軽量スレッド -
Project Loom - 限定継続と軽量スレッド -
 
Oracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE UpdateOracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE Update
 
今こそStream API入門
今こそStream API入門今こそStream API入門
今こそStream API入門
 
Oracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE UpdateOracle Code One 報告会 Java SE Update
Oracle Code One 報告会 Java SE Update
 
Learn Language 2018 Java Language Update
Learn Language 2018 Java Language Update Learn Language 2018 Java Language Update
Learn Language 2018 Java Language Update
 
Dockerに向けて、Javaもダイエット
Dockerに向けて、JavaもダイエットDockerに向けて、Javaもダイエット
Dockerに向けて、Javaもダイエット
 
What's New in Java
What's New in JavaWhat's New in Java
What's New in Java
 
Migration Guide to Java SE 10, and also Java SE 11
Migration Guide to Java SE 10, and also Java SE 11Migration Guide to Java SE 10, and also Java SE 11
Migration Guide to Java SE 10, and also Java SE 11
 
琥珀色のJava - Project Amber -
琥珀色のJava - Project Amber -琥珀色のJava - Project Amber -
琥珀色のJava - Project Amber -
 
モジュール移行の課題と対策
モジュール移行の課題と対策モジュール移行の課題と対策
モジュール移行の課題と対策
 
Project Jigsawと、ちょっとだけVector API
Project Jigsawと、ちょっとだけVector APIProject Jigsawと、ちょっとだけVector API
Project Jigsawと、ちょっとだけVector API
 
Java SE 9の全貌
Java SE 9の全貌Java SE 9の全貌
Java SE 9の全貌
 
Java SEの現在、過去 そして未来
Java SEの現在、過去 そして未来Java SEの現在、過去 そして未来
Java SEの現在、過去 そして未来
 
Java SE 9 のススメ
Java SE 9 のススメJava SE 9 のススメ
Java SE 9 のススメ
 
Introduction of Project Jigsaw
Introduction of Project JigsawIntroduction of Project Jigsaw
Introduction of Project Jigsaw
 
Encouragement of Java SE 9
Encouragement of Java SE 9Encouragement of Java SE 9
Encouragement of Java SE 9
 
Javaで和暦と元号
Javaで和暦と元号Javaで和暦と元号
Javaで和暦と元号
 

Kürzlich hochgeladen

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
 
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
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Kürzlich hochgeladen (20)

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
 
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, ...
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Moving to Module: Issues & Solutions

  • 1. Moving to Module Issues & Solutions Project Jigsaw Java in the Box Yuichi Sakuraba
  • 2. Module Issues of Non-Modular Software Issues of Modular Software
  • 5. -classpath Issues public is TOO Public TOO Many Libraries Which Libs Use which Libs? Want to Hide “public” Class
  • 6. rt.jar Issue rt.jar (Java SE 8) Standard Library is TOO Huge
  • 7. -classpath Issues rt.jar Issue Introduce Module { }Dependency Disclosure Scope Divide into Modules According to Features
  • 8.
  • 10. Build javac --module-path [directory] [source file] -p or jar --create --file [JAR filename] -C [class file directory] .
  • 11. Build javac --module-path [directory] [source file] -p or jar --create --file [JAR filename] -C [class file directory] . Execution java -p [directory] --module [module]/[main class] -m or
  • 12. java -p mods -m net.javainthebox.jigsawsample/net.javainthebox.sample.Main jigsawsample
  • 13. java -p mods -m net.javainthebox.jigsawsample/net.javainthebox.sample.Main jigsawsample javafx.media javafx.controls
  • 14. java -p mods -m net.javainthebox.jigsawsample/net.javainthebox.sample.Main jigsawsample javafx.media javafx.controls javafx.graphics javafx.base
  • 15. java -p mods -m net.javainthebox.jigsawsample/net.javainthebox.sample.Main jigsawsample javafx.media javafx.controls javafx.graphics javafx.base java.desktop java.xml jdk.jsobject ...... ...... ......
  • 16. Tool Support IDE IntelliJ IDEA Eclipse NetBeans Only Nightly Build
  • 17. Tool Support IDE IntelliJ IDEA Eclipse NetBeans Only Nightly Build Build Tool Maven Gradle Need to Write Options in Build File
  • 18. jdeps Tool to Check Dependency
  • 19. jdeps Tool to Check Dependency C:samplemods>jdeps -s jigsawsample.jar jigsawsample.jar -> java.base jigsawsample.jar -> java.logging jigsawsample.jar -> java.xml jigsawsample.jar -> javafx.base jigsawsample.jar -> javafx.controls jigsawsample.jar -> javafx.graphics jigsawsample.jar -> javafx.media
  • 20. jdeps Tool to Check Dependency C:samplemods>jdeps --generate-module-info . jigsawsample.jar writing to .jigsawsamplemodule-info.java module jigsawsample { requires java.logging; requires javafx.base; requires javafx.controls; requires javafx.media; requires transitive java.xml; requires transitive javafx.graphics; exports net.javainthebox.sample; exports net.javainthebox.sample.internal; }
  • 21. jdeps Tool to Check Dependency C:samplemods>jdeps --generate-module-info . jigsawsample.jar writing to .jigsawsamplemodule-info.java module jigsawsample { requires java.logging; requires javafx.base; requires javafx.controls; requires javafx.media; requires transitive java.xml; requires transitive javafx.graphics; exports net.javainthebox.sample; exports net.javainthebox.sample.internal; } Edit as Necessary
  • 23. import com.sun.javafx.tk.FontMetrics; import com.sun.javafx.tk.Toolkit; import javafx.scene.text.Font; public class FontSample { public static void main(String... args) { Font font = Font.font(24); Toolkit toolkit = Toolkit.getToolkit(); FontMetrics metrics = toolkit.getFontLoader().getFontMetrics(font); System.out.println(metrics.getLineHeight()); } }
  • 24. C:fxsample>javac FontSample.java FontSample.java:1: error: package com.sun.javafx.tk is not visible import com.sun.javafx.tk.FontMetrics; ^ (package com.sun.javafx.tk is declared in module javafx. graphics, which does not export it to the unnamed module) FontSample.java:2: error: package com.sun.javafx.tk is not visible import com.sun.javafx.tk.Toolkit; ^ (package com.sun.javafx.tk is declared in module javafx. graphics, which does not export it to the unnamed module) 2 errors
  • 25. import com.sun.javafx.tk.FontMetrics; import com.sun.javafx.tk.Toolkit; import javafx.scene.text.Font; public class FontSample { public static void main(String... args) { Font font = Font.font(24); Toolkit toolkit = Toolkit.getToolkit(); FontMetrics metrics = toolkit.getFontLoader().getFontMetrics(font); System.out.println(metrics.getLineHeight()); } }
  • 26. Non-Disclosure API Non Exported Packages com.sun... sun... java.awt.peer
  • 27. Non-Disclosure API Non Exported Packages com.sun... sun... java.awt.peer Exceptional API sun.misc.Unsafe sun.reflect.Reflection (Remove in Future)
  • 28. Solution add export by --add-exports option --add-exports module/package=target javac java
  • 29. Solution add export by --add-exports option --add-exports module/package=target javac java when non-modular system target is ALL-UNNAMED ex. javac --add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED FontSample.java
  • 30. public class FontSample { public static void main(String... args) throws Exception { Font font = Font.font(24); FontMetrics metrics = Toolkit.getToolkit().getFontLoader().getFontMetrics(font); Class<FontMetrics> metricsClass = FontMetrics.class; Field lineHeight = metricsClass.getDeclaredField("lineHeight"); lineHeight.setAccessible(true); System.out.println(lineHeight.getFloat(metrics)); } }
  • 31. C:fxsample>javac --add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED FontSample.java C:fxsample>java --add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED FontSample WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by FontSample (file:/C:/fxsa mple/) to field com.sun.javafx.tk.FontMetrics.lineHeight WARNING: Please consider reporting this to the maintainers of FontSample WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a futu re release 31.921875
  • 32. public class FontSample { public static void main(String... args) throws Exception { Font font = Font.font(24); FontMetrics metrics = Toolkit.getToolkit().getFontLoader().getFontMetrics(font); Class<FontMetrics> metricsClass = FontMetrics.class; Field lineHeight = metricsClass.getDeclaredField("lineHeight"); lineHeight.setAccessible(true); System.out.println(lineHeight.getFloat(metrics)); } }
  • 34. Non-Disclosure API Reflection Reflective access to public --add-exports Reflective access to non-public --add-opens in execution using setAccessible(true) ex. java --add-opens javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED FontSample.java
  • 35. import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import net.javainthebox.xml.Name; public class JAXBSample { public static void main(String... args) throws JAXBException { JAXBContext context = JAXBContext.newInstance("net.javainthebox.xml"); Unmarshaller unmarshaller = context.createUnmarshaller(); File file = new File("sakuraba.xml"); Name sakuraba = (Name)unmarshaller.unmarshal(file); System.out.println(sakuraba.getFirst() + " " + sakuraba.getLast()); } }
  • 36. C:jaxbsample>javac JAXBSample.java netjavaintheboxxmlName.java:11: error: package javax.xml. bind.annotation is not visible import javax.xml.bind.annotation.XmlAccessType; ^ (package javax.xml.bind.annotation is declared in module java.xml.bind, which is not in the module graph) <<skip the rest>>
  • 37. import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import net.javainthebox.xml.Name; public class JAXBSample { public static void main(String... args) throws JAXBException { JAXBContext context = JAXBContext.newInstance("net.javainthebox.xml"); Unmarshaller unmarshaller = context.createUnmarshaller(); File file = new File("sakuraba.xml"); Name sakuraba = (Name)unmarshaller.unmarshal(file); System.out.println(sakuraba.getFirst() + " " + sakuraba.getLast()); } }
  • 38. Non-Standard Module Modules not included in standard modulepath
  • 39.
  • 40. Non-Standard Module Modules not included in standard modulepath JAXB JAX-WS CORBA java.xml.bind java.xml.ws java.corba These modules will be removed in future You should use the modules supplied by Java EE
  • 41. Non-Standard Module Modules not included in standard modulepath JAXB JAX-WS CORBA java.xml.bind java.xml.ws java.corba These modules will be removed in future You should use the modules supplied by Java EE Incubator jdk.incubator.httpclient
  • 42. Solution Add Modules by --add-modules option --add-modules module javac java ex) java --add-modules java.xml.bind JAXBSample
  • 44. In Java SE 8, Only classpath is Used
  • 45. In Java SE 8, Only classpath is Used Module and Non-Module are Used In Java SE 9, modulepath classpath
  • 46. In Java SE 8, Only classpath is Used Module and Non-Module are Used In Java SE 9, modulepath classpath specified in module-info.java Module CAN Access Only Modules
  • 48. foo.jar bar.jarmyapp.jar Module Non-Module Access Directly: Automatic Module Access Indirectly: Unnamed Module
  • 49. foo.jar bar.jarmyapp.jar Module Non-Module Access Directly: Automatic Module Access Indirectly: Unnamed Module Automatic Unnamed
  • 51. foo.jar bar.jarmyapp.jar Module Non-Module Automatic Unnamed modulepath classpath Automatic Module: Named Module Unnamed Module: No Name Modu MANIFEST.MF Automatic-Module-Name or JAR filename Automatic Module Name is Defined by
  • 52. foo.jar bar.jarmyapp.jar Module Non-Module Automatic Unnamed modulepath classpath module myapp { requires foo; } > java -cp bar.jar -p mod -m myapp/myapp.Main
  • 54. foo.jar bar.jarmyapp.jar java.xml.bind Module Non-Module Automatic Module Can’ Describe Dependency t > java -cp bar.jar -p mods --add-modules java.xml.bind -m myapp/myapp.Main
  • 55. foo.jar bar.jarmyapp.jar java.xml.bind Module Non-Module Automatic Module Can’ Describe Dependency t > java -cp bar.jar -p mods --add-modules java.xml.bind -m myapp/myapp.Main > java -cp bar.jar -p mods --add-modules ALL-MODULE-PATH -m myapp/myapp.Main If You Don’ t Know Dependencies
  • 56. Conclusion Non-Disclosure API Issues of Non-Modular Software Non-Standard Module May Remove These APIs/Modules in Future modulepath & classpath Issues of Modular Software May Use Only modulepath in Future??
  • 57. Moving to Module Issues & Solutions Project Jigsaw Java in the Box Yuichi Sakuraba