SlideShare a Scribd company logo
Java 10 - Key Note
	
The purpose of this article is not just to discuss key features of java 10 instead we’ll go over the circumstances where it’ll be
useful and quickly try our hands out. Believe me it’s a great time-saver.
As a programmer by interest, I’ve tried hands over different programming languages and noticed that, if java lacks something
then it is a tool or an interface to try out code snippet or keywords quickly (“on-the-go”).
I think many among the readers of this blog have had pain of writing test classes to try out the logic that goes as part of your
source code. There might also be a situation where a developer wants to verify some sort of string, primitive variable
operations, accessing native/OS provisioned metrics, APIs encapsulated in java util package and so on and so forth, whereas
a few other languages like Python, Javascript, Go, C++ etc., have an interface or console to try out such little snippets quickly.
Hence introducing JShell for you.
Please go ahead and install Java 10 JDK so that we can get started while you can quickly run some code on your machine.
(NOTE: Beware that after installation Java10 will be your default java. Make sure to backup existing setup and rollback your
settings after this exercise)
Many good features were introduced in Java 9 but unfortunately it hasn’t seen the light of the day for much long. So, we can
say that it’s declared outdated by the community. As I mentioned before JShell was one of significant features introduced in
Java 9 and also available with Java 10 which is declared LTS version may be until March 2025.
	
JShell	
	
I call it “Java OTG (On-The-Go)” coz it’s like an interface that you’ll use when you really want to quickly try it out.
Assuming Java 9 or 9+ JDK installed on your computer, the easiest way to fire JShell is to just type jshell on command-
prompt/terminal.
For everything that you try on jshell if you want an interactive message feedback or log or an acknowledgement, set verbose
mode for current session.
Variable declaration:
Variable and Data operation:
If the result of an operation is not assigned to a user declared variable then, the value is associated to an internal variable,
Before going further digging into more options I would suggest checkout help command. As a caution, type ‘/’ before help
Typing help without ‘/’ you will end up creating a null reference for variable intro.
As explained in feedback, intro is declared to be of type help. But since there is not type help created the variable intro is
created but cannot be used as it has to type reference.
Now to give a life to the variable “intro”. Let’s create a class help.
But still intro is null. Why? Because we haven’t allocated an object, variable or a memory reference to variable intro.
Moral of the story, jshell commands should be used preceding with a forward slash ‘/’ or else you might end up creating a
variable with null reference which has no significance and obviously IMHO a bad practice.
Local Variable Type Inference
This is curios topic because from now on for all those programmers who have the feeling why java is strict with variable
initialization unlike other functional programming languages like python. After lambda, supplier, consumer and streams now
java has introduced us with var type inference. So, what is it??
In the earlier versions to declare a variable we had to define appropriate type and assign/initialize/access it. With java 10
while declaring local variables all you got to do is just say “var”.
Correct Usage:
Incorrect Usage:
What if I assign a different type value after initial assignment. In this case the assignment will fail to compile.
Other important characteristics here:
1. var is NOT a key word rather it’s a reserved type. Like int, float, etc., this is mainly because to provide backwards
compatibility for code generated before java 10.
2. You cannot leave var uninitialized. Ex. var abc;
3. Cannot assign var to null. Ex. var abc = null
4. Cannot use var to declare class member variable.
5. Cannot be used in method argument definition
One potential area where Local Type Inference has significant role is when we are “programming to interfaces”.
For example, in case of facade design pattern or even factory design patterns, we pretty much know what the return object
is supposed to be. Hence there is no real need to explicitly declare define local variable that will eventually be assigned with
return object.
Another benefit I see here, it encourages developers to follow better and meaningful naming conventions when declaring
methods and method documentation.
Example usage of var -
1. Loop statements - For, while, do-whiles
2. In Branch constructs. Note the declared type of consumer and consumerAccountId
Continued …
Other Features
There are a few other features introduced in Java 10 but we won’t be directly interacting with them on our day-to-day
#programminglife.
Hence, I would prefer to list them all but describe only those which are interesting yet critical in the order I think would be
useful for developers. And then leave it up to you guys to discover more.
Thread-Local Handshakes
I suggest please don’t mistake this with ThreadLocal and InheritedThreadLocal concepts that we extensively use in
multithreading. In fact, this is mostly related VM safe point and handshaking of individual or a bunch of threads
Parallel Full GC for GC1
• GC1 – Garbage Collector First is a redesigned garbage collection mechanism introduced in Java 7
• Since then it has been upgraded and updated to make it more performant in Java 9
• In simple words, instead of performing Mark and Sweep on complete Young Generation and Old Generation heap
individually, GC1 divides heap into small chunks of Old, Eden, Survivor and Unassigned heap spaces.
• Once this virtual division is made, then GC1 will perform “Initial Mark” by pausing application execution when GC is
initialized for creating reference to young objects created in heap,
• Performs “Concurrent Mark” while application is executing to check status and usage of references from Initial Mark.
• Then performs “Final Mark” and “Evacuation” by suspending the application.
• The whole process is known as “Concurrent Mark and Sweep”
• Java 10 has now made it possible to execute the whole process is parallel
• Aggregate most of GC source-code which is scattered across HotSpot VM into a single/common interface that
be easily called from variety of join-points in HotSpot VM
Application Class Data sharing
o Class Data sharing introduced in Java 5 allows to maintain a memory map of executable at runtime.
o CDS helps to bootstrap class loader hence improving performance but for system classes only.
o Application CDS extends CDS
o Application CDS opens door for built-in platform class loader, built-in system class loader and customer class loader to
load archived class ex., my-usefull-microservice-app.jar.
o To quickly try out Application CDS feature follow the steps below
§ Let’s quickly create a simple spring boot app using Spring Initializer à https://start.spring.io/
§ Give it a name à my-microservice
§ “cd” into the application root directory
§ Create a list of class that to be archived
java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=my-microservice.lst -cp my-microservice.jar
my-microservice
input is “.jar”
output is “.lst”
§ Create a shared/sharable archive from the list of classes dump in “.lst” file
java -Xshare:dump -XX:+UseAppCDS -XX:SharedClassListFile=my-microservice.lst -
XX:SharedArchiveFile=my-microservice.jsa -cp my-microservice.jar
input is “.lst”
output is “.jsa”
§ Now we’ll start the executable spring-boot application from the archive that we have just now created
java -Xshare:on -XX:+UseAppCDS -XX:SharedArchiveFile=my-microservice.jsa -cp my-microservice.jar
my-microservice
• Experimental Java based JIT compiler
• BCP47 Unicode support
• Heap allocation for external memory location
• Default Root certificates now comes with Java 10
• Time-Based version. For ex. java 10.0.2 2018-07-17 or java version "10.0.2" 2018-07-17
• Convergence of JDK forest repositories into single repository interface.
With this I’m leaving it over to you to read more, explore and share if this triggers the curious techie inside you!
Thank you so much for reading! We’ll meet again… Until then keep exploring! Bye.

More Related Content

What's hot

Apache Cordova In Action
Apache Cordova In ActionApache Cordova In Action
Apache Cordova In Action
Hazem Saleh
 
Lecture java basics
Lecture   java basicsLecture   java basics
Lecture java basics
eleksdev
 
Java basics
Java basicsJava basics
Java basics
suraj pandey
 
Java Presentation
Java PresentationJava Presentation
Java Presentationpm2214
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
Hazem Saleh
 
Learn java in one day and learn it well 2016 jamie chan
Learn java in one day and learn it well 2016   jamie chanLearn java in one day and learn it well 2016   jamie chan
Learn java in one day and learn it well 2016 jamie chan
anand_study
 
Step by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For BeginnersStep by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For Beginners
calltutors
 
JPQL/ JPA Activity 1
JPQL/ JPA Activity 1JPQL/ JPA Activity 1
JPQL/ JPA Activity 1
SFI
 
Core java course syllabus
Core java course syllabusCore java course syllabus
Core java course syllabus
Papitha Velumani
 
130700548484460000
130700548484460000130700548484460000
130700548484460000
Tanzeel Ahmad
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Edureka!
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operationbobwolff68
 
Gwt and JSR 269's Pluggable Annotation Processing API
Gwt and JSR 269's Pluggable Annotation Processing APIGwt and JSR 269's Pluggable Annotation Processing API
Gwt and JSR 269's Pluggable Annotation Processing API
Arnaud Tournier
 
Selenium training12 1
Selenium training12 1Selenium training12 1
Selenium training12 1
AmanCSE1
 
Java2 platform
Java2 platformJava2 platform
Java2 platform
Sajan Sahu
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013
Hazem Saleh
 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action
Hazem Saleh
 

What's hot (19)

Apache Cordova In Action
Apache Cordova In ActionApache Cordova In Action
Apache Cordova In Action
 
Lecture java basics
Lecture   java basicsLecture   java basics
Lecture java basics
 
Java basics
Java basicsJava basics
Java basics
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
 
perl-java
perl-javaperl-java
perl-java
 
Learn java in one day and learn it well 2016 jamie chan
Learn java in one day and learn it well 2016   jamie chanLearn java in one day and learn it well 2016   jamie chan
Learn java in one day and learn it well 2016 jamie chan
 
Step by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For BeginnersStep by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For Beginners
 
JPQL/ JPA Activity 1
JPQL/ JPA Activity 1JPQL/ JPA Activity 1
JPQL/ JPA Activity 1
 
Core java course syllabus
Core java course syllabusCore java course syllabus
Core java course syllabus
 
130700548484460000
130700548484460000130700548484460000
130700548484460000
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operation
 
Gwt and JSR 269's Pluggable Annotation Processing API
Gwt and JSR 269's Pluggable Annotation Processing APIGwt and JSR 269's Pluggable Annotation Processing API
Gwt and JSR 269's Pluggable Annotation Processing API
 
Selenium training12 1
Selenium training12 1Selenium training12 1
Selenium training12 1
 
Java2 platform
Java2 platformJava2 platform
Java2 platform
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013
 
[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action[Devoxx Morocco 2015] Apache Cordova In Action
[Devoxx Morocco 2015] Apache Cordova In Action
 

Similar to Java 10 - Key Note

Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Levent YILDIZ
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
Mukesh Tekwani
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importance
nishajj
 
Java Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming Basics
Akshaj Vadakkath Joshy
 
Spring boot
Spring bootSpring boot
10 interesting things about java
10 interesting things about java10 interesting things about java
10 interesting things about java
kanchanmahajan23
 
C# and java comparing programming languages
C# and java  comparing programming languagesC# and java  comparing programming languages
C# and java comparing programming languages
Shishir Roy
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
Techglyphs
 
Java programming language
Java programming languageJava programming language
Java programming language
SubhashKumar329
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Veerabadra Badra
 
Java interview question
Java interview questionJava interview question
Java interview question
simplidigital
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Professional Guru
 
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...
Mr. Akaash
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
Gradeup
 
Java Notes .pdf
Java Notes .pdfJava Notes .pdf
Java Notes .pdf
gokulprasanna4
 
Languages used by web app development services remotestac x
Languages used by web app development services  remotestac xLanguages used by web app development services  remotestac x
Languages used by web app development services remotestac x
Remote Stacx
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
Arto Santala
 

Similar to Java 10 - Key Note (20)

Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
perl-java
perl-javaperl-java
perl-java
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importance
 
Java Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming Basics
 
Spring boot
Spring bootSpring boot
Spring boot
 
10 interesting things about java
10 interesting things about java10 interesting things about java
10 interesting things about java
 
C# and java comparing programming languages
C# and java  comparing programming languagesC# and java  comparing programming languages
C# and java comparing programming languages
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Java programming language
Java programming languageJava programming language
Java programming language
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java interview question
Java interview questionJava interview question
Java interview question
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
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...
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
 
Java Notes .pdf
Java Notes .pdfJava Notes .pdf
Java Notes .pdf
 
Languages used by web app development services remotestac x
Languages used by web app development services  remotestac xLanguages used by web app development services  remotestac x
Languages used by web app development services remotestac x
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 

Java 10 - Key Note

  • 1. Java 10 - Key Note The purpose of this article is not just to discuss key features of java 10 instead we’ll go over the circumstances where it’ll be useful and quickly try our hands out. Believe me it’s a great time-saver. As a programmer by interest, I’ve tried hands over different programming languages and noticed that, if java lacks something then it is a tool or an interface to try out code snippet or keywords quickly (“on-the-go”). I think many among the readers of this blog have had pain of writing test classes to try out the logic that goes as part of your source code. There might also be a situation where a developer wants to verify some sort of string, primitive variable operations, accessing native/OS provisioned metrics, APIs encapsulated in java util package and so on and so forth, whereas a few other languages like Python, Javascript, Go, C++ etc., have an interface or console to try out such little snippets quickly. Hence introducing JShell for you. Please go ahead and install Java 10 JDK so that we can get started while you can quickly run some code on your machine. (NOTE: Beware that after installation Java10 will be your default java. Make sure to backup existing setup and rollback your settings after this exercise) Many good features were introduced in Java 9 but unfortunately it hasn’t seen the light of the day for much long. So, we can say that it’s declared outdated by the community. As I mentioned before JShell was one of significant features introduced in Java 9 and also available with Java 10 which is declared LTS version may be until March 2025. JShell I call it “Java OTG (On-The-Go)” coz it’s like an interface that you’ll use when you really want to quickly try it out. Assuming Java 9 or 9+ JDK installed on your computer, the easiest way to fire JShell is to just type jshell on command- prompt/terminal. For everything that you try on jshell if you want an interactive message feedback or log or an acknowledgement, set verbose mode for current session.
  • 2. Variable declaration: Variable and Data operation: If the result of an operation is not assigned to a user declared variable then, the value is associated to an internal variable, Before going further digging into more options I would suggest checkout help command. As a caution, type ‘/’ before help Typing help without ‘/’ you will end up creating a null reference for variable intro. As explained in feedback, intro is declared to be of type help. But since there is not type help created the variable intro is created but cannot be used as it has to type reference. Now to give a life to the variable “intro”. Let’s create a class help.
  • 3. But still intro is null. Why? Because we haven’t allocated an object, variable or a memory reference to variable intro. Moral of the story, jshell commands should be used preceding with a forward slash ‘/’ or else you might end up creating a variable with null reference which has no significance and obviously IMHO a bad practice. Local Variable Type Inference This is curios topic because from now on for all those programmers who have the feeling why java is strict with variable initialization unlike other functional programming languages like python. After lambda, supplier, consumer and streams now java has introduced us with var type inference. So, what is it?? In the earlier versions to declare a variable we had to define appropriate type and assign/initialize/access it. With java 10 while declaring local variables all you got to do is just say “var”. Correct Usage: Incorrect Usage: What if I assign a different type value after initial assignment. In this case the assignment will fail to compile.
  • 4. Other important characteristics here: 1. var is NOT a key word rather it’s a reserved type. Like int, float, etc., this is mainly because to provide backwards compatibility for code generated before java 10. 2. You cannot leave var uninitialized. Ex. var abc; 3. Cannot assign var to null. Ex. var abc = null 4. Cannot use var to declare class member variable. 5. Cannot be used in method argument definition One potential area where Local Type Inference has significant role is when we are “programming to interfaces”. For example, in case of facade design pattern or even factory design patterns, we pretty much know what the return object is supposed to be. Hence there is no real need to explicitly declare define local variable that will eventually be assigned with return object. Another benefit I see here, it encourages developers to follow better and meaningful naming conventions when declaring methods and method documentation. Example usage of var - 1. Loop statements - For, while, do-whiles
  • 5. 2. In Branch constructs. Note the declared type of consumer and consumerAccountId Continued …
  • 6. Other Features There are a few other features introduced in Java 10 but we won’t be directly interacting with them on our day-to-day #programminglife. Hence, I would prefer to list them all but describe only those which are interesting yet critical in the order I think would be useful for developers. And then leave it up to you guys to discover more. Thread-Local Handshakes I suggest please don’t mistake this with ThreadLocal and InheritedThreadLocal concepts that we extensively use in multithreading. In fact, this is mostly related VM safe point and handshaking of individual or a bunch of threads Parallel Full GC for GC1 • GC1 – Garbage Collector First is a redesigned garbage collection mechanism introduced in Java 7 • Since then it has been upgraded and updated to make it more performant in Java 9 • In simple words, instead of performing Mark and Sweep on complete Young Generation and Old Generation heap individually, GC1 divides heap into small chunks of Old, Eden, Survivor and Unassigned heap spaces. • Once this virtual division is made, then GC1 will perform “Initial Mark” by pausing application execution when GC is initialized for creating reference to young objects created in heap, • Performs “Concurrent Mark” while application is executing to check status and usage of references from Initial Mark. • Then performs “Final Mark” and “Evacuation” by suspending the application. • The whole process is known as “Concurrent Mark and Sweep” • Java 10 has now made it possible to execute the whole process is parallel • Aggregate most of GC source-code which is scattered across HotSpot VM into a single/common interface that be easily called from variety of join-points in HotSpot VM Application Class Data sharing o Class Data sharing introduced in Java 5 allows to maintain a memory map of executable at runtime. o CDS helps to bootstrap class loader hence improving performance but for system classes only. o Application CDS extends CDS o Application CDS opens door for built-in platform class loader, built-in system class loader and customer class loader to load archived class ex., my-usefull-microservice-app.jar. o To quickly try out Application CDS feature follow the steps below § Let’s quickly create a simple spring boot app using Spring Initializer à https://start.spring.io/ § Give it a name à my-microservice § “cd” into the application root directory
  • 7. § Create a list of class that to be archived java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=my-microservice.lst -cp my-microservice.jar my-microservice input is “.jar” output is “.lst” § Create a shared/sharable archive from the list of classes dump in “.lst” file java -Xshare:dump -XX:+UseAppCDS -XX:SharedClassListFile=my-microservice.lst - XX:SharedArchiveFile=my-microservice.jsa -cp my-microservice.jar input is “.lst” output is “.jsa” § Now we’ll start the executable spring-boot application from the archive that we have just now created java -Xshare:on -XX:+UseAppCDS -XX:SharedArchiveFile=my-microservice.jsa -cp my-microservice.jar my-microservice • Experimental Java based JIT compiler • BCP47 Unicode support • Heap allocation for external memory location • Default Root certificates now comes with Java 10 • Time-Based version. For ex. java 10.0.2 2018-07-17 or java version "10.0.2" 2018-07-17 • Convergence of JDK forest repositories into single repository interface. With this I’m leaving it over to you to read more, explore and share if this triggers the curious techie inside you! Thank you so much for reading! We’ll meet again… Until then keep exploring! Bye.