SlideShare a Scribd company logo
1 of 25
Welcome to Java 9
Spring Days – 6/20/17
Jeanne Boyarsky
https://www.slideshare.net/
boyarsky/2017-java9springdays
Twitter @jeanneboyarsky
Blog: http://www.selikoff.net
Modules (Jigsaw)
Problem
• Jar hell
• Solution – Maven/Gradle?
• No closed/private packages
Java 9
• Modules!
Twitter: @jeanneboyarsky
Jigsaw – flux
• You can use a command line flag.
• The flag might or might not be the default.
Twitter: @jeanneboyarsky
Do you
•use sun.* internal APIs?
•use a jar that does?
• 2011 – Maybe part of Java 7. Nope Plan B
• 2012 - Part of Java 8. No wait
• 2014 - Part of Java 9
• Sept 2016
• May 2017
• July 2017
• Sept 2017?
The Saga of Jigsaw
Twitter: @jeanneboyarsky
Moving on
That was nerve wracking.
We clearly need sugar!
Twitter: @jeanneboyarsky
Creating a non-empty Set
Set<String> set = new HashSet<>(
Arrays.asList("1","2", "3"));
Set<String> set = Stream.of("1", "2”, "3")
.collect(Collectors.toSet());
Set<String> set = Set.of("1", "2", "3");
Twitter: @jeanneboyarsky
For consistency
Map<String, String> map = Map.of("k", "v");
Up to 10 params, then varargs
List<String> list = List.of("1", "2", "3");
Up to 20 params, then varargs
Twitter: @jeanneboyarsky
Better Map
Twitter: @jeanneboyarsky
Map<Integer, Integer> map =
Map.ofEntries(
Map.entry(1, 10),
Map.entry(2, 20)
);
JavaDoc Search Upgrade
Twitter: @jeanneboyarsky
(to 2017)
Try with Resources
Path path = Paths.get("test.txt");
try (BufferedReader reader =
Files.newBufferedReader(path)) {
System.out.println(reader.readLine());
}
Effectively final
resources
Twitter: @jeanneboyarsky
BufferedReader reader =
Files.newBufferedReader(path);
try (reader) {
System.out.println(reader.readLine());
}
What’s wrong here?
Connection con =
DriverManager.getConnection(url);
PreparedStatement ps =
con.prepareStatement(sql);
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
try (con; ps; rs) {
while (rs.next()) {
// process result set
} } Twitter: @jeanneboyarsky
Resource leak!
@Deprecated
“Very few deprecated APIs were actually
removed, leading some people to believe that
nothing would ever be removed.
On the other hand, other people believed that
everything that was deprecated might
eventually be removed, which was never the
intent either.”
From JEP 277
Twitter: @jeanneboyarsky
@Deprecated New Attributes
Attribute Type Description
forRemoval boolean Is the intent to remove API
from Java at some point?
since String Version of Java when API
first became deprecated (not
populated for all pre-Java 9
APIs)
Twitter: @jeanneboyarsky
Only had for new
APIs before
Twitter: @jeanneboyarsky
@Deprecated
Warning types
• Ordinary Deprecation
• Removal
@SuppressWarnings("deprecation”)
@SuppressWarnings("removal”)
@SuppressWarnings({"deprecation", "removal"})
Twitter: @jeanneboyarsky
What is deprecated for removal?
• Unused code in AWT
• Some old security APIs
• Some thread and runtime APIs
• Some Jigsaw transition modules
(but not classes)
• And…
Twitter: @jeanneboyarsky
Applets
Finally deprecated!
But…
forRemoval=false
Applet
Twitter: @jeanneboyarsky
Streams - takeWhile
Stream.iterate(entry(1,1),
e -> entry(e.getValue(),
e.getKey()+e.getValue()))
.map(Entry::getValue)
.takeWhile(n -> n < 30)
.forEach(System.out::println);
How print all Fibonacci #s less than 30?
Assumes ordered stream. Takes all elements until
one doesn’t match.
Twitter: @jeanneboyarsky
Streams - dropWhile
Stream.iterate(entry(1,1),
e -> entry(e.getValue(),
e.getKey()+e.getValue()))
.map(Entry::getValue)
.dropWhile(n -> n < 30)
.forEach(System.out::println);
How print all Fibonacci #s greater than 30?
Note: This doesn’t work. takeWhile and dropWhile
aren’t always opposites. See why?
Twitter: @jeanneboyarsky
Streams - iterate
Stream.iterate(10, i-> i-1)
.limit(10)
.forEach(System.out::println);
Stream.iterate(10, i-> i>0, i-> i-1)
.forEach(System.out::println);
Twitter: @jeanneboyarsky
Streams - ofNullable
stream = dubiousObj == null
? Stream.empty()
: Stream.of(dubiousObj);
stream = Stream.ofNullable(dubiousObj);
Twitter: @jeanneboyarsky
JShell
• REPL for Java
• Now with tab and up arrow
• More packages known than Nashorn
Twitter: @jeanneboyarsky
Random other changes
• Can now have private methods in interfaces
• _ is no longer a legal identifier. Still ok to have
vars like _temp
• sun.misc.Unsafe was replaced by VarHandle. I
can’t imagine needing to do either. Maybe for
low level APIs
• Could use @SafeVarargs on static methods or
final instance methods. Now can do the same
for private instance methods
Twitter: @jeanneboyarsky
More new APIs
APIs for reactive programming:
•Flow.Processor
•Flow.Publisher
•Flow.Subscriber
•Flow.Subscription
(new class Flow)
Process APIs
Process.pid()
supportsNormalTermination()
CompletableFuture<Process> onExit()
info()
descendants()
children()
Twitter: @jeanneboyarsky
Questions
?
Twitter: @jeanneboyarsky

More Related Content

What's hot

Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016Matt Raible
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017Matt Raible
 
Testing Angular Applications - Jfokus 2017
Testing Angular Applications - Jfokus 2017Testing Angular Applications - Jfokus 2017
Testing Angular Applications - Jfokus 2017Matt Raible
 
Herding a Cat with Antlers - Catalyst 5.80
Herding a Cat with Antlers - Catalyst 5.80Herding a Cat with Antlers - Catalyst 5.80
Herding a Cat with Antlers - Catalyst 5.80Tomas Doran
 
Testing Mobile JavaScript
Testing Mobile JavaScriptTesting Mobile JavaScript
Testing Mobile JavaScriptjeresig
 
Get Hip with JHipster - Colorado Springs OSS Meetup April 2016
Get Hip with JHipster - Colorado Springs OSS Meetup April 2016Get Hip with JHipster - Colorado Springs OSS Meetup April 2016
Get Hip with JHipster - Colorado Springs OSS Meetup April 2016Matt Raible
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Matt Raible
 
Web Frameworks of the Future: Flex, GWT, Grails and Rails
Web Frameworks of the Future: Flex, GWT, Grails and RailsWeb Frameworks of the Future: Flex, GWT, Grails and Rails
Web Frameworks of the Future: Flex, GWT, Grails and RailsMatt Raible
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015Matt Raible
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksPhill Sparks
 
Realtime Apps with Django
Realtime Apps with DjangoRealtime Apps with Django
Realtime Apps with DjangoRenyi Khor
 
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017The Ultimate Getting Started with Angular Workshop - Devoxx France 2017
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017Matt Raible
 
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itDrupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itRyan Weaver
 
What's New in JHipsterLand - Devoxx US 2017
What's New in JHipsterLand - Devoxx US 2017What's New in JHipsterLand - Devoxx US 2017
What's New in JHipsterLand - Devoxx US 2017Matt Raible
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$Joe Ferguson
 
On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)Zoe Landon
 
Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016Matt Raible
 

What's hot (18)

Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx UK 2016
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017
 
Testing Angular Applications - Jfokus 2017
Testing Angular Applications - Jfokus 2017Testing Angular Applications - Jfokus 2017
Testing Angular Applications - Jfokus 2017
 
Herding a Cat with Antlers - Catalyst 5.80
Herding a Cat with Antlers - Catalyst 5.80Herding a Cat with Antlers - Catalyst 5.80
Herding a Cat with Antlers - Catalyst 5.80
 
Testing Mobile JavaScript
Testing Mobile JavaScriptTesting Mobile JavaScript
Testing Mobile JavaScript
 
Get Hip with JHipster - Colorado Springs OSS Meetup April 2016
Get Hip with JHipster - Colorado Springs OSS Meetup April 2016Get Hip with JHipster - Colorado Springs OSS Meetup April 2016
Get Hip with JHipster - Colorado Springs OSS Meetup April 2016
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
 
Web Frameworks of the Future: Flex, GWT, Grails and Rails
Web Frameworks of the Future: Flex, GWT, Grails and RailsWeb Frameworks of the Future: Flex, GWT, Grails and Rails
Web Frameworks of the Future: Flex, GWT, Grails and Rails
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - Devoxx 2015
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill Sparks
 
Async await...oh wait!
Async await...oh wait!Async await...oh wait!
Async await...oh wait!
 
Realtime Apps with Django
Realtime Apps with DjangoRealtime Apps with Django
Realtime Apps with Django
 
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017The Ultimate Getting Started with Angular Workshop - Devoxx France 2017
The Ultimate Getting Started with Angular Workshop - Devoxx France 2017
 
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itDrupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
 
What's New in JHipsterLand - Devoxx US 2017
What's New in JHipsterLand - Devoxx US 2017What's New in JHipsterLand - Devoxx US 2017
What's New in JHipsterLand - Devoxx US 2017
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)On Selecting JavaScript Frameworks (Women Who Code 10/15)
On Selecting JavaScript Frameworks (Women Who Code 10/15)
 
Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016
 

Similar to Java 9 Modules and New Features

Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Mihail Stoynov
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & HowGraham Tackley
 
JRuby 6 Years in Production
JRuby 6 Years in ProductionJRuby 6 Years in Production
JRuby 6 Years in ProductionMark Menard
 
Monkeybars in the Manor
Monkeybars in the ManorMonkeybars in the Manor
Monkeybars in the Manormartinbtt
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and ToolingTrisha Gee
 
Hacking Java @JavaLand2016
Hacking Java @JavaLand2016Hacking Java @JavaLand2016
Hacking Java @JavaLand2016Sean P. Floyd
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaHenri Tremblay
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9Trisha Gee
 
Java 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the GalleryJava 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the Gallerynjbartlett
 
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksBuilding Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksAtlassian
 
Real World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains WebinarReal World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains WebinarTrisha Gee
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9Trisha Gee
 
Making The Move To Java 17 (JConf 2022)
Making The Move To Java 17 (JConf 2022)Making The Move To Java 17 (JConf 2022)
Making The Move To Java 17 (JConf 2022)Alex Motley
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.WO Community
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
Java days Lviv 2015
Java days Lviv 2015Java days Lviv 2015
Java days Lviv 2015Alex Theedom
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGuillaume Laforge
 

Similar to Java 9 Modules and New Features (20)

Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
 
JRuby 6 Years in Production
JRuby 6 Years in ProductionJRuby 6 Years in Production
JRuby 6 Years in Production
 
Monkeybars in the Manor
Monkeybars in the ManorMonkeybars in the Manor
Monkeybars in the Manor
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and Tooling
 
Hacking Java @JavaLand2016
Hacking Java @JavaLand2016Hacking Java @JavaLand2016
Hacking Java @JavaLand2016
 
DevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern JavaDevNexus 2020: Discover Modern Java
DevNexus 2020: Discover Modern Java
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Java 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the GalleryJava 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the Gallery
 
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning TalksBuilding Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
 
Real World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains WebinarReal World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains Webinar
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Making The Move To Java 17 (JConf 2022)
Making The Move To Java 17 (JConf 2022)Making The Move To Java 17 (JConf 2022)
Making The Move To Java 17 (JConf 2022)
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Just enough app server
Just enough app serverJust enough app server
Just enough app server
 
Better Career with Java
Better Career with JavaBetter Career with Java
Better Career with Java
 
Java days Lviv 2015
Java days Lviv 2015Java days Lviv 2015
Java days Lviv 2015
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 

More from Jeanne Boyarsky

Pathways intro january 2018
Pathways intro   january 2018Pathways intro   january 2018
Pathways intro january 2018Jeanne Boyarsky
 
Pathways path-comparison
Pathways path-comparisonPathways path-comparison
Pathways path-comparisonJeanne Boyarsky
 
2017 stuysplash-build-tools
2017 stuysplash-build-tools2017 stuysplash-build-tools
2017 stuysplash-build-toolsJeanne Boyarsky
 
2017 JavaOne Mutation Testing Session
2017 JavaOne Mutation Testing Session2017 JavaOne Mutation Testing Session
2017 JavaOne Mutation Testing SessionJeanne Boyarsky
 
java 8 Hands on Workshop
java 8 Hands on Workshopjava 8 Hands on Workshop
java 8 Hands on WorkshopJeanne Boyarsky
 
2016 java-sig-mutation-testing
2016 java-sig-mutation-testing2016 java-sig-mutation-testing
2016 java-sig-mutation-testingJeanne Boyarsky
 
2016 first-champs-java-cert
2016 first-champs-java-cert2016 first-champs-java-cert
2016 first-champs-java-certJeanne Boyarsky
 
2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownership2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownershipJeanne Boyarsky
 
Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?Jeanne Boyarsky
 

More from Jeanne Boyarsky (20)

Pathways intro january 2018
Pathways intro   january 2018Pathways intro   january 2018
Pathways intro january 2018
 
Pathways path-comparison
Pathways path-comparisonPathways path-comparison
Pathways path-comparison
 
2017 stuysplash-build-tools
2017 stuysplash-build-tools2017 stuysplash-build-tools
2017 stuysplash-build-tools
 
Virtual scrum
Virtual scrumVirtual scrum
Virtual scrum
 
Ignite java-robots
Ignite java-robotsIgnite java-robots
Ignite java-robots
 
2017 JavaOne Mutation Testing Session
2017 JavaOne Mutation Testing Session2017 JavaOne Mutation Testing Session
2017 JavaOne Mutation Testing Session
 
java 8 Hands on Workshop
java 8 Hands on Workshopjava 8 Hands on Workshop
java 8 Hands on Workshop
 
Pathways overview
Pathways overviewPathways overview
Pathways overview
 
2016 java-sig-mutation-testing
2016 java-sig-mutation-testing2016 java-sig-mutation-testing
2016 java-sig-mutation-testing
 
Ftc judging
Ftc judgingFtc judging
Ftc judging
 
2016 qcon-virtual-scrum
2016 qcon-virtual-scrum2016 qcon-virtual-scrum
2016 qcon-virtual-scrum
 
2016 java9-how-make-qus
2016 java9-how-make-qus2016 java9-how-make-qus
2016 java9-how-make-qus
 
2016 java9-how-make-qus
2016 java9-how-make-qus2016 java9-how-make-qus
2016 java9-how-make-qus
 
2016 first-champs-java-cert
2016 first-champs-java-cert2016 first-champs-java-cert
2016 first-champs-java-cert
 
2016 java8-cert-intro
2016 java8-cert-intro2016 java8-cert-intro
2016 java8-cert-intro
 
FTC 2015-2016 Judging
FTC 2015-2016 JudgingFTC 2015-2016 Judging
FTC 2015-2016 Judging
 
2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownership2015 nyc-spin-collective-ownership
2015 nyc-spin-collective-ownership
 
FTC Robot C to Java
FTC Robot C to JavaFTC Robot C to Java
FTC Robot C to Java
 
Frc java5-8andeclipse
Frc java5-8andeclipseFrc java5-8andeclipse
Frc java5-8andeclipse
 
Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?Throw Away all the Rules: Now What Process do you Follow?
Throw Away all the Rules: Now What Process do you Follow?
 

Recently uploaded

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Java 9 Modules and New Features

  • 1. Welcome to Java 9 Spring Days – 6/20/17 Jeanne Boyarsky https://www.slideshare.net/ boyarsky/2017-java9springdays Twitter @jeanneboyarsky Blog: http://www.selikoff.net
  • 2. Modules (Jigsaw) Problem • Jar hell • Solution – Maven/Gradle? • No closed/private packages Java 9 • Modules! Twitter: @jeanneboyarsky
  • 3. Jigsaw – flux • You can use a command line flag. • The flag might or might not be the default. Twitter: @jeanneboyarsky Do you •use sun.* internal APIs? •use a jar that does?
  • 4. • 2011 – Maybe part of Java 7. Nope Plan B • 2012 - Part of Java 8. No wait • 2014 - Part of Java 9 • Sept 2016 • May 2017 • July 2017 • Sept 2017? The Saga of Jigsaw Twitter: @jeanneboyarsky
  • 5. Moving on That was nerve wracking. We clearly need sugar! Twitter: @jeanneboyarsky
  • 6. Creating a non-empty Set Set<String> set = new HashSet<>( Arrays.asList("1","2", "3")); Set<String> set = Stream.of("1", "2”, "3") .collect(Collectors.toSet()); Set<String> set = Set.of("1", "2", "3"); Twitter: @jeanneboyarsky
  • 7. For consistency Map<String, String> map = Map.of("k", "v"); Up to 10 params, then varargs List<String> list = List.of("1", "2", "3"); Up to 20 params, then varargs Twitter: @jeanneboyarsky
  • 8. Better Map Twitter: @jeanneboyarsky Map<Integer, Integer> map = Map.ofEntries( Map.entry(1, 10), Map.entry(2, 20) );
  • 9. JavaDoc Search Upgrade Twitter: @jeanneboyarsky (to 2017)
  • 10. Try with Resources Path path = Paths.get("test.txt"); try (BufferedReader reader = Files.newBufferedReader(path)) { System.out.println(reader.readLine()); } Effectively final resources Twitter: @jeanneboyarsky BufferedReader reader = Files.newBufferedReader(path); try (reader) { System.out.println(reader.readLine()); }
  • 11. What’s wrong here? Connection con = DriverManager.getConnection(url); PreparedStatement ps = con.prepareStatement(sql); ps.setInt(1, id); ResultSet rs = ps.executeQuery(); try (con; ps; rs) { while (rs.next()) { // process result set } } Twitter: @jeanneboyarsky Resource leak!
  • 12. @Deprecated “Very few deprecated APIs were actually removed, leading some people to believe that nothing would ever be removed. On the other hand, other people believed that everything that was deprecated might eventually be removed, which was never the intent either.” From JEP 277 Twitter: @jeanneboyarsky
  • 13. @Deprecated New Attributes Attribute Type Description forRemoval boolean Is the intent to remove API from Java at some point? since String Version of Java when API first became deprecated (not populated for all pre-Java 9 APIs) Twitter: @jeanneboyarsky Only had for new APIs before
  • 15. @Deprecated Warning types • Ordinary Deprecation • Removal @SuppressWarnings("deprecation”) @SuppressWarnings("removal”) @SuppressWarnings({"deprecation", "removal"}) Twitter: @jeanneboyarsky
  • 16. What is deprecated for removal? • Unused code in AWT • Some old security APIs • Some thread and runtime APIs • Some Jigsaw transition modules (but not classes) • And… Twitter: @jeanneboyarsky
  • 18. Streams - takeWhile Stream.iterate(entry(1,1), e -> entry(e.getValue(), e.getKey()+e.getValue())) .map(Entry::getValue) .takeWhile(n -> n < 30) .forEach(System.out::println); How print all Fibonacci #s less than 30? Assumes ordered stream. Takes all elements until one doesn’t match. Twitter: @jeanneboyarsky
  • 19. Streams - dropWhile Stream.iterate(entry(1,1), e -> entry(e.getValue(), e.getKey()+e.getValue())) .map(Entry::getValue) .dropWhile(n -> n < 30) .forEach(System.out::println); How print all Fibonacci #s greater than 30? Note: This doesn’t work. takeWhile and dropWhile aren’t always opposites. See why? Twitter: @jeanneboyarsky
  • 20. Streams - iterate Stream.iterate(10, i-> i-1) .limit(10) .forEach(System.out::println); Stream.iterate(10, i-> i>0, i-> i-1) .forEach(System.out::println); Twitter: @jeanneboyarsky
  • 21. Streams - ofNullable stream = dubiousObj == null ? Stream.empty() : Stream.of(dubiousObj); stream = Stream.ofNullable(dubiousObj); Twitter: @jeanneboyarsky
  • 22. JShell • REPL for Java • Now with tab and up arrow • More packages known than Nashorn Twitter: @jeanneboyarsky
  • 23. Random other changes • Can now have private methods in interfaces • _ is no longer a legal identifier. Still ok to have vars like _temp • sun.misc.Unsafe was replaced by VarHandle. I can’t imagine needing to do either. Maybe for low level APIs • Could use @SafeVarargs on static methods or final instance methods. Now can do the same for private instance methods Twitter: @jeanneboyarsky
  • 24. More new APIs APIs for reactive programming: •Flow.Processor •Flow.Publisher •Flow.Subscriber •Flow.Subscription (new class Flow) Process APIs Process.pid() supportsNormalTermination() CompletableFuture<Process> onExit() info() descendants() children() Twitter: @jeanneboyarsky

Editor's Notes

  1. https://pixabay.com/p-313586/?no_redirect
  2. https://en.wikipedia.org/wiki/Java_Platform_Module_System
  3. https://pixabay.com/p-485050/?no_redirect
  4. http://openjdk.java.net/jeps/269 https://pixabay.com/p-485050/?no_redirect
  5. http://openjdk.java.net/jeps/269 https://pixabay.com/p-485050/?no_redirect
  6. http://openjdk.java.net/jeps/269 https://pixabay.com/p-485050/?no_redirect https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Map_of_USA_with_state_names.svg/2000px-Map_of_USA_with_state_names.svg.png
  7. http://openjdk.java.net/jeps/225 https://c1.staticflickr.com/3/2588/3781549100_6e6fbcd184_b.jpg
  8. http://openjdk.java.net/jeps/225
  9. http://openjdk.java.net/jeps/225
  10. http://openjdk.java.net/jeps/277
  11. http://openjdk.java.net/jeps/277
  12. http://openjdk.java.net/jeps/277
  13. http://openjdk.java.net/jeps/277
  14. http://download.java.net/java/jdk9/docs/api/deprecated-list.html https://pixabay.com/p-1111448/?no_redirect
  15. http://openjdk.java.net/jeps/289 https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Argentina_-_NO_symbol.svg/2000px-Argentina_-_NO_symbol.svg.png
  16. http://openjdk.java.net/jeps/222 http://openjdk.java.net/jeps/236 http://openjdk.java.net/jeps/292 https://www.selikoff.net/2017/05/13/using-java-9s-jshell-for-experimenting/
  17. http://openjdk.java.net/jeps/213
  18. http://openjdk.java.net/jeps/266