Java 9 Project Jigsaw / JSR 376: JavaTM Platform Module System.

Slides:



Advertisements
Similar presentations
Chapter 11 Separate Compilation and Namespaces. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Separate Compilation.
Advertisements

Cognos Web Services Business Intelligence. SOA SOA (Service Oriented Architecture) The SOA approach involves seven key principles: -- Coarse -grained.
Packages Sudhir Talasila Preeti Navale. Introduction Packages are nothing more than the way we organize files into different directories according to.
1 © Wolfgang Pelz UML3 UML 3 Notations describe how to use reusable software. Package Component Deployment Node.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Chapter 3 Programs and Packages. 2 Java Virtual Machine (JVM) Java programs execute on the JVM. The JVM is a virtual rather than a physical machine,
Problem Solving #3: JVM ICS Outline Review of Key Topics Review of Key Topics Problem 1 Problem 1 Problem 2 Problem 2 Problem 3 Problem 3 Problem.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Spring Dynamic Modules. Startlocation: Documentation: /1.2.1/reference/html/
עיצוב תוכנה מונחה עצמים תירגול 1. 1.Packages and Paths 2.Jar Files Outline.
Chapter 25 More Design Patterns.
Proxy Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
PACKAGES Mimi OpkinsCECS277. What We’ll Cover  Packages and Import Statements  The Package java.lang  Package Names and Directories  The Default Package.
Access Control Problem A primary consideration in object- oriented design is to “separate the things that change from the things that stay.
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
OSGi.
© 2005 by IBM; made available under the EPL v1.0 | March 1, 2005 Tim deBoer Gorkem Ercan Extend WTP Server Tools for your.
Chapter 3 Vector Class. Agenda Design and Implementation of Vector class – add, get, set remove, copy, equals, ensureCapacity Hangman using Vector class.
©Fraser Hutchinson & Cliff Green C++ Certificate Program C++ Intermediate Access Control.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Display Text SDD 1.1 Topic. Current Situation COSMOS team is implementing a CLI for user interaction Need the ability to specify strings for display to.
4/1/05F-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Packages and Components in Java and UML.
Setting Up Eclipse. What is Eclipse? Eclipse is a free, downloadable software that allows us to create, compile, and run JAVA programs.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
JDBC - Connection The programming involved to establish a JDBC connection is fairly simple. Here are these simple four steps − Import JDBC Packages: Add.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Slide 1 ApacheCon 2011 > Doreen Seider> Using OSGi to Build Better Software > Using OSGi to Build Better Software Lessons from a Telemedicine.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
introductory lecture on java programming
© 2012 LogiGear Corporation. All Rights Reserved FitNesseFitNesse Authors: Nghia Pham 1.
Package A package is a logical container that contains classes,interfaces sub packages. Package provide a unique name space to its members and provide.
Packages. Access Specifications Public Available anywhere (public keyword) Only one public class per file allowed Protected Available in subclasses, and.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Java 9 support in Eclipse Jay Arthanareeswaran, Manoj Palat IBM.
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
Joy Rathnayake Senior Architect – Virtusa Pvt. Ltd.
Introduction to Object-oriented Programming
Advanced Programing practices
Types for Programs and Proofs
JavaOne BOF: The Legacy Developer’s Guide to Java 9
Project Topic 2: Migration to Java 9
Microsoft .NET 3. Language Innovations Pan Wuming 2017.
Introduction to J2EE Architecture
Java Basics Packages.
Best Angular 2 interview questions and Answer that have been designed for Angular 2 programmers who are preparing online interviews on Angular 2 interviews question. Visit Website:
MonoGame and Windows 8.
Java 9.
.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017.
Embracing Java 9 and beyond with Eclipse JDT
Reusability 11/29/2018© 2006 ITT Educational Services Inc.
JavaTeaching and Importing a github repository
CISC124 Assignment 4 on Inheritance due next Friday.
CISC124 Assignment 4 on Inheritance due next Friday.
Applying OO Concepts Using Java
Agile testing for web API with Postman
CMPE212 – Reminders Assignment 2 sample solution is posted.
F II 1. Background Objectives
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Introducing Java.
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
Working with Libraries
CMPE212 – Reminders Assignment 2 due today, 7pm.
David Cleverly – Development Lead
Plug-In Architecture Pattern
Presentation transcript:

Java 9 Project Jigsaw / JSR 376: JavaTM Platform Module System

Who is speaking Java developer in SEAVUS Oracle Certified Professional, Java SE 8 Programmer Over 8 years in this ever advancing industry Mother of two boys / beasts

Content of this presentation Why modularity ? Jigsaw In a nutshell Modularity basic concepts Example Migration of existing code to Java 9

Why Modularity ?

Jigsaw in a nutshell Create Modular System Key values of the project: strong encapsulation reliable configuration

Jigsaw in a nutshell module graph of the platform 80 platform modules java -listmods module graph of the platform

What it means for the platform ? - Security

What module means for the platform ? - Security --add-exports java.base/sun.security.provider=ALL-UNNAMED Add-Exports: java.base/sun.security.provider

What module means for the platform ? - Scalability jlink custom modular run-time image your app modules + only the required subset of JRE modules = modular run-time image

What problems is it truing to solve ? Whatever you know for the structure of your system it erases and connects everything to everything else. Problems: duplicate classes, missing classes slow sequential lookup The problem with the classpath

Modularity Basic Concepts What is module ? 01 How does this impact on readability and accessibility? 02 What is Unnamed module ? 03 What is Automatic module ? 04

What is Module

Define Module Module is a named self describing collection of code and data. Unit of software that declares the answers to three questions about itself in a file named module-info.java: What is its name? What does it require? What does it export? module name exports requires

Define Module 1. What is its name? 3. What does it export? module com.foo.bar { } 3. What does it export? module com.foo.bar { requires org.baz.qux; exports com.foo.bar.alpha; exports com.foo.bar.beta; } 2. What does it require? module com.foo.bar { requires org.baz.qux; }

Define Module module-info.java source file content: module com.foo.bar { requires org.baz.qux; exports com.foo.bar.alpha; exports com.foo.bar.beta; }

Define Module Modular jar- regular jar with module-info.class in the top level directory Module path - the folders where modules reside it is different than class path.

Readability And Accessibility

Readability - Direct Readability module com.foo.app { requires com.foo.bar; requires java.sql; } module com.foo.bar { requires org.baz.qux; exports com.foo.bar.alpha; exports com.foo.bar.beta; } module java.sql { requires java.logging; requires java.xml; exports java.sql; exports javax.sql; exports javax.transaction.xa; }

Readability - Implied Readability String url = ...; Properties props = ...; Driver d = DriverManager.getDriver(url); Connection c = d.connect(url, props); d.getParentLogger().info("Connection acquired"); module java.sql { requires transitive java.logging; requires transitive java.xml; exports java.sql; exports javax.sql; exports javax.transaction.xa; } Refactor the module -> without breaking it’s consumers.

Accessibility Accessibility is created of two constrains: The readability relationship The exports declaration. class A.B class Q.D Module X Module Y module X{ requires Y; } module Y{ exports Q; reads accesses exports

Accessibility Accessibility (JDK 9 –) public to everyone public but only to specific modules public only within a module protected <package> private

Unnamed And Automatic Modules

Unnamed Module There are situations in which you will need to load a package that is not put in any module yet and it is still on the classpath. In this scenario if the package is found and loaded it is considered as if it belongs to an “unnamed module”. The unnamed module reads code in any other module The unnamed module exports all of its packages.

Automatic Module An automatic module is created when we take code from the class path and we put it in the module path. If we take jar from the class pat and put it in the module path this implicitly becomes named module. It’s name is derived from the jar name, and it is not real module because it does not have explicit module-info declaration. The automatic module reads every other named module. The automatic module exports all of its packages. It guarantees direct and implied readability to all other modules.

Example

EXAMPLE com.coffeeshop.app com.coffeeshop.cup com.coffeeshop.factories com.coffeeshop.ingredients java.base

Services Loose coupling with services One module requires implementation of interface and other module provides implementation There can be more than one provider implementation, ServiceLoader is used and the preferred type is chosen at runtime. //provider module module java.some.provider{ provides java.provider with java.providerimplementation } //consumer module module java.user{ requires java.xyz; exports java.abc uses java.provider ->> service type }

Open Modules Some kinds of framework, libraries require reflective access to members of the non-exported types of other modules -> solution is open modules. open module foo.bar { exports com.foo.bar; requires hibernate.core; requires hibernate.entitymanager; } module foo.bar { exports com.foo.bar; opens com.foo.bar.model; requires hibernate.core; requires hibernate.entitymanager; } Java EE, Hibernate, Spring All elements of all packages are available for deep reflection at run time, but only the public and protected types of com.foo.bar are accessible at compile time Here only com.foo.bar is accessible at compile time.

Migrating to Java 9

Migrating to Java 9 myapp.jar mylib.jar Top Down App Migration Your app lib1.jar otherapp.jar lib2.jar Libraries and Third party apps JDK gradual migration path to modularization. module java.base java.sql java.logging java.xml Bottom Up Library Migration

Migrating to Java 9 Top down would be migrating your application and using not migrated libraries that are still residing on the classpath. Bottom up would be migrating the libraries first and using migrated modularized libraries while your app is still on the class path.

Migrating to Java 9 Top Down App Migration module myapp module mylib Your app AUTOMATIC MODULE lib1.jar otherapp.jar lib2.jar Libraries and Third party apps JDK module java.base java.sql java.logging java.xml

Migrating to Java 9 UNNAMED MODULE myapp.jar mylib.jar Your app Libraries and Third party apps module lib1 module otherapp module lib2 JDK This is a crucial escape hatch in case some problem prevents a migration module java.base java.sql java.logging java.xml Bottom Up Library Migration

Questions?

Prizes Hard Disc: Martin Spasovski @moondowner Java t-shirts: Thunder God @LordRaydenMK Gjorgji Noveski @kacibe_ti MolYDolY @molYCS Ilievski Martin @martinmaxs

References Project Jigsaw - http://openjdk.java.net/projects/jigsaw/ Project Jigsaw: Talks - http://openjdk.java.net/projects/jigsaw/talk s/#j1-2016 Follow @mreinhold https://twitter.com/mreinhold In Seavus Library you can find: Java 9 Modularity