jabrena / java9-by-example

A presentation about main Java 9 features included.
https://jabrena.github.io/java9-by-example/www/#/
MIT License
2 stars 0 forks source link

JSR 376: Java Platform Module System #2

Closed jabrena closed 7 years ago

jabrena commented 7 years ago

It is necessary to write about:

-Why we need a Module system? -API Reorganization -How to create a Module? -Build systems -Open issues

Points to talk in 15m:

module-info.java
cat src/com.greetings/module-info.java
module com.greetings { }
javac -d mods/com.greetings \
        src/com.greetings/module-info.java \
        src/com.greetings/com/greetings/Main.java
java --module-path mods -m com.greetings/com.greetings.Main
cat src/org.astro/org/astro/World.java
    package org.astro;
    public class World {
        public static String name() {
            return "world";
        }
    }
module com.greetings {
        requires org.astro;
    }
javac -d mods --module-source-path src $(find src -name "*.java")

    $ find mods -type f
    mods/com.greetings/com/greetings/Main.class
    mods/com.greetings/module-info.class
    mods/org.astro/module-info.class
    mods/org.astro/org/astro/World.class
java -p mlib -m com.greetings
jar --print-module-descriptor --file=mlib/org.astro@1.0.jar

    Name:
      org.astro@1.0
    Requires:
      java.base [ MANDATED ]
    Exports:
      org.astro

http://openjdk.java.net/projects/jigsaw/quick-start https://www.infoq.com/articles/Latest-Project-Jigsaw-Usage-Tutorial https://www.infoq.com/articles/Project-Jigsaw-Coming-in-Java-9 http://www.javahispano.org/portada/2012/1/11/el-proyecto-jigsaw-de-java-8.html

jabrena commented 7 years ago

https://www.sitepoint.com/reflection-vs-encapsulation-in-the-java-module-system/ http://www.javaworld.com/article/2878952/java-platform/modularity-in-java-9.html https://thoughtfulsoftware.wordpress.com/2016/08/29/java-9-why-modules/ http://mydailyjava.blogspot.co.uk/2015/12/project-jigsaw-incomplete-puzzle.html https://es.slideshare.net/SimonRitter/jdk-9-big-changes-to-make-java-smaller http://stackoverflow.com/questions/3091040/why-do-we-use-rt-jar-in-a-java-project

jabrena commented 7 years ago

https://blog.jetbrains.com/idea/2017/03/support-for-java-9-modules-in-intellij-idea-2017-1/

jabrena commented 7 years ago

https://es.slideshare.net/pavelbucek/pitfalls-of-migrating-projects-to-jdk-9 http://openjdk.java.net/jeps/238 http://product.hubspot.com/blog/the-fault-in-our-jars-why-we-stopped-building-fat-jars

jabrena commented 7 years ago

https://github.com/HubSpot/slimfast

jabrena commented 7 years ago

https://www.infoq.com/articles/monolith-defense-part-2

jabrena commented 7 years ago

https://arnaudroger.github.io/blog/2016/08/09/jigsaw-maven-integration.html https://www.sitepoint.com/maven-cannot-generate-module-declaration/

jabrena commented 7 years ago

https://developer.jboss.org/blogs/scott.stark/2017/04/14/critical-deficiencies-in-jigsawjsr-376-java-platform-module-system-ec-member-concerns http://blog.osgi.org/2015/01/java-modularity-revisited.html http://blog.codefx.org/java/dev/motivation-goals-project-jigsaw/ http://wildfly.org/news/2016/12/12/Jigsaws-Missing-Pieces/ https://github.com/moditect/moditect

jabrena commented 7 years ago

https://news.ycombinator.com/item?id=10197445

jabrena commented 7 years ago

http://events.linuxfoundation.org/sites/events/files/slides/Java9%20and%20the%20impact%20on%20Maven%20projects.pdf

jabrena commented 7 years ago

https://github.com/gradle/gradle/blob/master/design-docs/jdk9-support.md

jabrena commented 7 years ago

Why we need a Module system?

Software can be seen as a system of interacting parts and in Java it is common to package each of those parts in its own JAR. Conceptually a part consists of three properties: a name, a public API for the rest of the world to use, and dependencies on other parts. This graph-like model helps developers and tools dissect, analyse, and work with software systems.

But none of those properties exist inside the Java runtime, which uses the classpath to access a bunch of JARs and simply rolls them all into one big ball of mud. Any distinction between JARs is entirely lost and only a flat set of packages remains, with no capability of further validation. So important questions like “are these all required JARs?”, “are these even the correct JARs?”, “are there conflicts?”, or “are only public APIs used?” cannot be answered by the running JVM.

Project Jigsaw will enhance the compiler and runtime to come closer to the structured model. Its main goals are reliable configuration (by declaring dependencies) and strong encapsulation (by hiding internals) and its agent for both is the concept of modules.

jabrena commented 7 years ago

JAR hell? (Or is it classpath hell? Or dependency hell?) http://blog.codefx.org/java/jar-hell/

Unexpressed Dependencies NoClassDefFoundError

Transitive Dependencies https://en.wikipedia.org/wiki/Java_Classloader http://javarevisited.blogspot.com.es/2012/12/how-classloader-works-in-java.html

Shadowing Sometimes different JARs on the classpath contain classes with the same fully-qualified name. This can happen for different reasons, e.g. when there are two different versions of the same library, when a fat JAR contains dependencies that are also pulled in as standalone JARs, or when a library is renamed and unknowingly added to the classpath twice.

Version Conflicts Complex Class Loading

Version conflicts are the single most problematic aspect of JAR hell.

jabrena commented 7 years ago

http://blog.codefx.org/java/reflection-vs-encapsulation/

jabrena commented 7 years ago

https://developer.jboss.org/blogs/scott.stark/2017/04/14/critical-deficiencies-in-jigsawjsr-376-java-platform-module-system-ec-member-concerns

jabrena commented 7 years ago

https://youtu.be/q64TThEk_Z4

jabrena commented 7 years ago

https://dzone.com/articles/the-features-project-jigsaw-brings-to-java-9-1

jabrena commented 7 years ago

https://es.slideshare.net/pavelbucek/pitfalls-of-migrating-projects-to-jdk-9

jabrena commented 7 years ago

Classpath vs Modulepath

jabrena commented 7 years ago

https://github.com/gradle/jigsaw-quick-start

jabrena commented 7 years ago

https://dzone.com/articles/java-components-solving-the-puzzle-with-jigsaw-and

jabrena commented 7 years ago

https://docs.gradle.org/current/userguide/java_software.html

jabrena commented 7 years ago

https://es.slideshare.net/pavelbucek/pitfalls-of-migrating-projects-to-jdk-9

jabrena commented 7 years ago

https://melix.github.io/gradlesummit2016-jigsaw-gradle/#/a-simple-project

jabrena commented 7 years ago

http://trask.github.io/pjug-java9/#9

jabrena commented 7 years ago

https://github.com/szczepiq/java9-demo

jabrena commented 7 years ago

Main Class: http://stackoverflow.com/questions/41861613/java-9-can-i-add-the-mainclass-attribute-to-module-info-class-in-the-archive

jabrena commented 7 years ago

https://dzone.com/articles/a-look-at-intellij-ideas-support-for-java-9-modules