Java 9
Java 9
rt.jar contains 5000 plus classes & size is 65MB.
Are we using all these classes? Answer is no
jdk-9 (instead jdk1.9)
jmods folder available in the jdk-9 (98 modules) whichever modules required we can use as per our need.
Currently we bundle the packages which consist of clasess and interface in jar and we use it.
package a.b
Package is belong to module. Jar is a phyiscal holder of the module. Now package can be identified using module.
Dependency:
java -listmods (what are the modules jvm using?)
Customize the module of your project using jlink
REPL - (Read Eval Print Loop) Interactive tool
Enhancement in Stream API
Jigsaw -> Modularity
Are we using all these classes? Answer is no
JDK create approximetely 98 modules. Whichever set required. You can use them. If you want a specific module for use system takes the dependencies automatically.
Module dependency hierachyjdk-9 (instead jdk1.9)
jmods folder available in the jdk-9 (98 modules) whichever modules required we can use as per our need.
- java.base.jmod
- java.desktop.jmod
- java.rmi.jmod
- java.sql.jmod
- java.sql.rowset.jmod
- java.se.jmod
- java se.ee.jmod
- java.logging.jmod
sql
|---> logging
|---> xml |----->base
corba
|---> rmi --> logging -> base
|--->desktop |--> xml---> base
|---> charsets-->base
Currently we bundle the packages which consist of clasess and interface in jar and we use it.
package a.b
package a.b.c
Both packages are have no relationship. but we bundle it in the single jar.Package is belong to module. Jar is a phyiscal holder of the module. Now package can be identified using module.
java.base is the base module. (String, java.lang.classes and interface)
Module
A collection of code (package),has a name,tell what is needs (requires) & tell what is provides (exports)
Creating Modules:
- Let's define a module
- module-info.java in a top level directory
module com.developer.{
exports com.dev.math;
}
com.developer (Module name) com.dev.math (packagename)
- requires
- export
- to create a module
javac -d outputdir path/module-info.java path/package/sourcepath
jar -c -f mlib/filename.jar -C outputdir .
- to use a module
- javac -mp mlib ...
- jar ... --main-class package.classname
- java -mp mlib -m modulename
- or
- java -mp mlib -m module/package.mainclassname
- Readability
- A module "reads" the modules it depends on
- exports (package)
- public is not the same any more (it is not visible outside)
- public + exports becomes visible
- public with no exports is not visible
- that's both at compile time and runtime
Dependency:
- All modules depend on java.base
- use jdeps to examine dependency
- -s option for summary
jdeps -s -mp out/mlib jarName.jar
com.developer -> java.base (com.developer package depends on java.base package)java -listmods (what are the modules jvm using?)
Customize the module of your project using jlink
REPL - (Read Eval Print Loop) Interactive tool
jshell -> print the helloworld
Private method in Interface
public interface Demo{
public void process();
public default start(){ start1();}
private void start1(){ }
}
public interface Demo{
public void process();
public default start(){ start1();}
private void start1(){ }
}
Java JVM - G1 as default GC
Factory Methods for Immutable List, Set, Map and Map.Entry
List<String> name = List.of("Peter", "Sam");
Set<String> nameSet = List.of("Peter", "Sam");
Process API Improvements
Reactive Streams - Publisher,Subscriber,Processcor and Flow
Better @Deprecated Annotations
Http Client
HTML5 Java Doc
Search in Doc
Java 8 / 7 works in Java 9.
Java 9 focus on how we build and package them.
List<String> name = List.of("Peter", "Sam");
Set<String> nameSet = List.of("Peter", "Sam");
Process API Improvements
Reactive Streams - Publisher,Subscriber,Processcor and Flow
Better @Deprecated Annotations
Http Client
HTML5 Java Doc
Search in Doc
Java 8 / 7 works in Java 9.
Java 9 focus on how we build and package them.
Java 8 focus on how to write the code effectively.
Comments
Post a Comment