SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Java SE 9
- SHRINATH JOSHI
Java 9
 Java 9 was released on 21st September 2017
 The main goals for Java 9 are to:
 Make the Java Standard Edition platform, and the JDK, more
navigable to scale down for small computing devices.
 Improve the overall security and maintain not only the JDK but
the Java Implementations in general.
 Allow overall improved application performance.
 Make it easier for Java developers to build and uphold the
code libraries and larger applications, for both the Java SE and
EE Platforms.
Java 9 Features
 Jshell
 JPMS (Java Platform Module System)
 Jlink (Java Linker)
 Http/2 Client API
 Process API Update
 Private method inside interface
Java 9 Features cont..
 Try with resources enhancement
 Factory method to create unmodifiadble collections
 Stream Api enhancements
 < > (Diamond )operator Enhancement
 SafeVargs annotations
 G1GC (Garbage First Garbage collector)
JShell
 Like a playground for Begineers where individual can start
learning without writing the boilerplate code
 The Java Shell tool (JShell) is an interactive tool for learning
the Java programming language and prototyping Java code.
 JShell is a Read-Evaluate-Print Loop (REPL), which evaluates
declarations, statements, and expressions as they are entered
and immediately shows the results.
 The tool is run from the command line.
JPMS
 Until java 8 ,while developing software we first define the
classes, interfaces,enum and put this inside package and then
this packages is kept as Jar file.
 This has few disadvantages eg NoClassDefFoundError,
VersionConflict, Security Problem.
 Untill Java 8, Jdk and Jre had monolithic structure i.e. it cannot
be divided. To execute a simple hello World program of 1 kb
the client had to load 400Mb of JRE on client machine.
 All this problem is also known as Java Hell.
 To overcome this problem JPMS comes into picture
 In modular programming the Jvm checks in the start of
execution where all the required files are present or no
.Therefore there is no Chance of NoclasssDefFoundError.
 Part Of Jigsaw Project
 Project started in 2005
JLink
 To run a simple hello World program we need JRE . JRE
contains rt.jar whose size is 60Mb . This rt.jar contains all the
predefined class i.e it contains 4300+ classes but we required
hardly 5-6 classes . The size of Jre is 400Mb . Therefore to run
1 kb program 400mb is required . Therefore java is heavy
weight.
 To create our own customised jre we use jLink
 We can now use java for Iot deices,micro-services etc.
HTTP/2 Client
 To send an Http request to server from a java program we
need some software and that is http/2 clinet.
 Until java 8 we used httpUrlConnection but this had certain
drawback
 httpUrlconnection was developed in 1997 ,introduced in java
1.0 and was still being used until java 8.
 httpUrlconnection was difficult to use
 Only one request at a time.
 It supported only data in text format and not binary data.
 It works in blocking mode i.e wait for the next request.
 Therefore Java programmer started using Apache Http client
or google Httpclient.
 Now in Java 9 they introduced Http/2 client
 Very easy to use
 Works in both blocking and non blocking mode
 Works with data in both text and binary format
 Can send multiple requests.
Process API Updates
 Java communication with processor is very difficult until java
8, but from java 9 new methods added to Process class i.e Api
got enhanced.
 Most imp feature of java 9
 System.out.println(ProcessHandle.current().pid()); to get the
current running jvm process
Private method inside Interface
 Until 1.7 inside interface wecan take only public and abstract methods and
every variable present inside interface is public static and final
 From 1.8 we can take default methods and static methods
 From 1.9 we can take private methods inside interface
 Without affecting the implementation classes we can extends the
functionality of interface by adding default methods
 Interface inter
 {
 M1();
 M2();
 }
 Class a implements inter
 {
 M1() {}
 M2() {}
 }
 .
 .
 .
 Class class10 implents inter
 {
 M1(){}
 M2(){}
 }
 To add a method in interface we have to make changes in all
the implanting classes .therefor we add default method
 Interface infer
 {
 M1(){}
 M2(){}
 Default void m3(){}
 }
 Implementing classes are not required to override default
methods.
 Private methods in interface are introduced to make code
reuseable
 Without affecting implementation class how we can get Code
Reusablilty?.
 Consider the below code
 Since the method is private it is hidden from the implementing
class
 This make code reusable .
 Interface interface
 {
 Defaulf void m1()
 {
 m3();
 }
 Default void m2()
 {
 m3();
 }
 Private void m3()
 {
 Common code;
 }
 }
Try with Resources enhancement
 Try with resources
 Until 1.6 , if we have to close the resources we wrote that code in finally
block
 From 1.7 try with resources came
 try(r1;r2)
 {
 }
 These resources were closed automatically after the try block.
 Fw fw=new Fw(“abc.txt”);
 Fr fr=new Fr(“input.txt”);
 Try(fw;fr)
 {
 }// Not allowed in Java 8
 // We have to declare inside try()
 From Java 9 we can use try with resources where resources are already
being created
Factory Methods to create
Unmodifiable Collections
 List <String> l =new ArrayList<>();
 L.add(“A”);
 L.add(“B”);
 L.add(“C”);
 Now if I have to make list immutable??
 Until Java 8
 List <String > l2=Collections.unmodifiableList(l);
 From Java 9
 List<String> l=List.of(“A”,”B”,”C”);
 Set.of();
Stream API Enhancement
 Collection is a group of objects.
 The main objective of collection is to hold objects as a single entitiy and
Stream is used to process this object from the collections.
 New Methods in Java 9
 takeWhile() //Default Methods in Stream Interface
 dropWhile() -------- -------
 Stream.iterate() with three argument
 Stream.ofNullable() //to check if null reference
<> Operator
 ArrayList <String> l =new ArrayList<String>();
 Generics is used to perform typesafety and perform and resolve type
casting problems
 From Java 7
 ArrayList <String> l =new ArrayList<>(); // No need to specify the type
parameter
 Also know as type inference
 This <>operator is only applicable for normal classes and not applicable
for Anonymous Inner Classes
 From Java 9 we can use <>(diamond) operator in anonymous inner
classes.
safeVarargs Annotation
 In Java 5 m1(int … x)
 M1(List<String>… x)
 Here there may be a chance of heap Pollution.
 // Warning by compiler
 If we want to supress this warning we can go for safevarargs annotations
 This concept came in java 8 wherein safevarargs is used for static ,final
,constructor methods
 From Java 9 ,it is also used for private methods also
G1GC
Garbage First Garbage collection
 Many type of GC
 Serial Gc
 Parallel GC
 Concurrent mark and Sweep gc
 G1gc //from 1.6
 First three will work based on generations
 G1gc divides the heap into parts and uses the part with most garbage i.e
highest number of objects that are eligible for gc and will destroy that area
 Performance wise g1gc is best
 From Java 9 ,g1gc is default garbage collector
 Untill java 8 , parallel gc was default garbage collector
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For SyntaxPravinYalameli
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)Shaharyar khan
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924yohanbeschi
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manualnahalomar
 
Method Handles in Java
Method Handles in JavaMethod Handles in Java
Method Handles in Javahendersk
 
PHP 7X New Features
PHP 7X New FeaturesPHP 7X New Features
PHP 7X New FeaturesThanh Tai
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7Deniz Oguz
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
 
Java Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJava Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJavabynataraJ
 
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...Raffi Khatchadourian
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2Techglyphs
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...Duckademy IT courses
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8Raffi Khatchadourian
 

Was ist angesagt? (20)

Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java Presentation For Syntax
Java Presentation For SyntaxJava Presentation For Syntax
Java Presentation For Syntax
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
The Java memory model made easy
The Java memory model made easyThe Java memory model made easy
The Java memory model made easy
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systemsExploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 
Java lab1 manual
Java lab1 manualJava lab1 manual
Java lab1 manual
 
Method Handles in Java
Method Handles in JavaMethod Handles in Java
Method Handles in Java
 
PHP 7X New Features
PHP 7X New FeaturesPHP 7X New Features
PHP 7X New Features
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
 
Java Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRaoJava Interview Questions by NageswaraRao
Java Interview Questions by NageswaraRao
 
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
An Empirical Study of Refactorings and Technical Debt in Machine Learning Sys...
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
 

Ähnlich wie Java 9 features

Ähnlich wie Java 9 features (20)

Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
java basic for begginers
java basic for begginersjava basic for begginers
java basic for begginers
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Introduction
IntroductionIntroduction
Introduction
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
Java7
Java7Java7
Java7
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
 
Unit of competency
Unit of competencyUnit of competency
Unit of competency
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Java programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, MysuruJava programming material for beginners by Nithin, VVCE, Mysuru
Java programming material for beginners by Nithin, VVCE, Mysuru
 
OOP-Chap2.docx
OOP-Chap2.docxOOP-Chap2.docx
OOP-Chap2.docx
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Java
JavaJava
Java
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 

Kürzlich hochgeladen

Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 

Kürzlich hochgeladen (20)

Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 

Java 9 features

  • 1. Java SE 9 - SHRINATH JOSHI
  • 2. Java 9  Java 9 was released on 21st September 2017  The main goals for Java 9 are to:  Make the Java Standard Edition platform, and the JDK, more navigable to scale down for small computing devices.  Improve the overall security and maintain not only the JDK but the Java Implementations in general.  Allow overall improved application performance.  Make it easier for Java developers to build and uphold the code libraries and larger applications, for both the Java SE and EE Platforms.
  • 3. Java 9 Features  Jshell  JPMS (Java Platform Module System)  Jlink (Java Linker)  Http/2 Client API  Process API Update  Private method inside interface
  • 4. Java 9 Features cont..  Try with resources enhancement  Factory method to create unmodifiadble collections  Stream Api enhancements  < > (Diamond )operator Enhancement  SafeVargs annotations  G1GC (Garbage First Garbage collector)
  • 5. JShell  Like a playground for Begineers where individual can start learning without writing the boilerplate code  The Java Shell tool (JShell) is an interactive tool for learning the Java programming language and prototyping Java code.  JShell is a Read-Evaluate-Print Loop (REPL), which evaluates declarations, statements, and expressions as they are entered and immediately shows the results.  The tool is run from the command line.
  • 6. JPMS  Until java 8 ,while developing software we first define the classes, interfaces,enum and put this inside package and then this packages is kept as Jar file.  This has few disadvantages eg NoClassDefFoundError, VersionConflict, Security Problem.  Untill Java 8, Jdk and Jre had monolithic structure i.e. it cannot be divided. To execute a simple hello World program of 1 kb the client had to load 400Mb of JRE on client machine.  All this problem is also known as Java Hell.  To overcome this problem JPMS comes into picture
  • 7.  In modular programming the Jvm checks in the start of execution where all the required files are present or no .Therefore there is no Chance of NoclasssDefFoundError.  Part Of Jigsaw Project  Project started in 2005
  • 8. JLink  To run a simple hello World program we need JRE . JRE contains rt.jar whose size is 60Mb . This rt.jar contains all the predefined class i.e it contains 4300+ classes but we required hardly 5-6 classes . The size of Jre is 400Mb . Therefore to run 1 kb program 400mb is required . Therefore java is heavy weight.  To create our own customised jre we use jLink  We can now use java for Iot deices,micro-services etc.
  • 9. HTTP/2 Client  To send an Http request to server from a java program we need some software and that is http/2 clinet.  Until java 8 we used httpUrlConnection but this had certain drawback  httpUrlconnection was developed in 1997 ,introduced in java 1.0 and was still being used until java 8.  httpUrlconnection was difficult to use  Only one request at a time.  It supported only data in text format and not binary data.  It works in blocking mode i.e wait for the next request.
  • 10.  Therefore Java programmer started using Apache Http client or google Httpclient.  Now in Java 9 they introduced Http/2 client  Very easy to use  Works in both blocking and non blocking mode  Works with data in both text and binary format  Can send multiple requests.
  • 11. Process API Updates  Java communication with processor is very difficult until java 8, but from java 9 new methods added to Process class i.e Api got enhanced.  Most imp feature of java 9  System.out.println(ProcessHandle.current().pid()); to get the current running jvm process
  • 12. Private method inside Interface  Until 1.7 inside interface wecan take only public and abstract methods and every variable present inside interface is public static and final  From 1.8 we can take default methods and static methods  From 1.9 we can take private methods inside interface  Without affecting the implementation classes we can extends the functionality of interface by adding default methods  Interface inter  {  M1();  M2();  }
  • 13.  Class a implements inter  {  M1() {}  M2() {}  }  .  .  .  Class class10 implents inter  {  M1(){}  M2(){}  }
  • 14.  To add a method in interface we have to make changes in all the implanting classes .therefor we add default method  Interface infer  {  M1(){}  M2(){}  Default void m3(){}  }  Implementing classes are not required to override default methods.
  • 15.  Private methods in interface are introduced to make code reuseable  Without affecting implementation class how we can get Code Reusablilty?.  Consider the below code  Since the method is private it is hidden from the implementing class  This make code reusable .
  • 16.  Interface interface  {  Defaulf void m1()  {  m3();  }  Default void m2()  {  m3();  }  Private void m3()  {  Common code;  }  }
  • 17. Try with Resources enhancement  Try with resources  Until 1.6 , if we have to close the resources we wrote that code in finally block  From 1.7 try with resources came  try(r1;r2)  {  }  These resources were closed automatically after the try block.
  • 18.  Fw fw=new Fw(“abc.txt”);  Fr fr=new Fr(“input.txt”);  Try(fw;fr)  {  }// Not allowed in Java 8  // We have to declare inside try()  From Java 9 we can use try with resources where resources are already being created
  • 19. Factory Methods to create Unmodifiable Collections  List <String> l =new ArrayList<>();  L.add(“A”);  L.add(“B”);  L.add(“C”);  Now if I have to make list immutable??  Until Java 8  List <String > l2=Collections.unmodifiableList(l);  From Java 9  List<String> l=List.of(“A”,”B”,”C”);  Set.of();
  • 20. Stream API Enhancement  Collection is a group of objects.  The main objective of collection is to hold objects as a single entitiy and Stream is used to process this object from the collections.  New Methods in Java 9  takeWhile() //Default Methods in Stream Interface  dropWhile() -------- -------  Stream.iterate() with three argument  Stream.ofNullable() //to check if null reference
  • 21. <> Operator  ArrayList <String> l =new ArrayList<String>();  Generics is used to perform typesafety and perform and resolve type casting problems  From Java 7  ArrayList <String> l =new ArrayList<>(); // No need to specify the type parameter  Also know as type inference  This <>operator is only applicable for normal classes and not applicable for Anonymous Inner Classes  From Java 9 we can use <>(diamond) operator in anonymous inner classes.
  • 22. safeVarargs Annotation  In Java 5 m1(int … x)  M1(List<String>… x)  Here there may be a chance of heap Pollution.  // Warning by compiler  If we want to supress this warning we can go for safevarargs annotations  This concept came in java 8 wherein safevarargs is used for static ,final ,constructor methods  From Java 9 ,it is also used for private methods also
  • 23. G1GC Garbage First Garbage collection  Many type of GC  Serial Gc  Parallel GC  Concurrent mark and Sweep gc  G1gc //from 1.6  First three will work based on generations  G1gc divides the heap into parts and uses the part with most garbage i.e highest number of objects that are eligible for gc and will destroy that area  Performance wise g1gc is best  From Java 9 ,g1gc is default garbage collector  Untill java 8 , parallel gc was default garbage collector