SlideShare a Scribd company logo
1 of 47
Download to read offline
Java, what’s next?
by Stephan Janssen
• Founder of Devoxx

• Co-founder of Voxxed (Days)

• Co-founder Devoxx4Kids

• Java Champion

• Passionate Developer
Who am I ?
“The Future Is Complicated”
- John Rose , JVM Architect
“For Java to remain competitive it
must not just continue to move
forward — it must move forward
faster.”
- Mark Reinhold , Chief Architect of the Java Platform Group at Oracle
@Stephan007
More Java Releases
• Every 6 months feature releases (March, September)

• Long-term support releases every 3 years

• Next release for March 2018

• Details @ https://mreinhold.org/blog/forward-faster
@Stephan007
New Java Versioning
• Java SE 18.3
@Stephan007
• Project Amber

• Project Valhalla

• Project Panama - Interconnecting JVM and native code

• Project Loom - Make Concurrency simple(r) again!

• Project Metropolis - The holy Graal : a Java compiler & interpreter
How will this effect you?
@Stephan007
Project Amber
@Stephan007
Project Amber
• Local-Variable Type Inference
• Enhanced Enums
• Lambda Leftovers
• Pattern matching
• Switch expression
https://openjdk.java.net/projects/amber/
JEP 286 Local-Variable Type Inference (LVTI)
(Java 18.3 target release)
@Stephan007
Expanded Type Inference
List<String> empty = Collections.<String>emptyList();
List<String> empty = Collections.emptyList();
	 •	 Java 5: type inference for generic method type arguments
	 •	 Java 7: type inference for constructor type arguments
List<String> newList = new ArrayList<String>();
List<String> newList = new ArrayList<>();
	 •	 Java 8: type inference for lambda formals
Predicate<String> isEmpty = (String s) -> s.isEmpty();
Predicate<String> isEmpty = s -> s.isEmpty();
Brian Goetz @ http://bit.ly/2x3Wop9
@Stephan007
Local-Variable
Type Inference (JEP 286)
URL url = new URL(“https://devoxx.com");
URLConnection conn = url.openConnection();
Scanner scanner = new Scanner(conn.getInputStream(), “UTF-8”);
var url = new URL(“https://devoxx.com");
var conn = url.openConnection();
var scanner = new Scanner(conn.getInputStream(), “UTF-8”);
Brian Goetz @ http://bit.ly/2x3Wop9
@Stephan007
LVTI warnings
var x = { 1, 2, 3 }; // array initializer needs an explicit target-type
http://cr.openjdk.java.net/~mcimadamore/8177466/lvti-diags.html
var x = null; // variable initializer is 'null'
var x; // cannot use 'var' on variable without initializer
var x = m(x); // cannot use 'var' on self-referencing variable
class var { } // as of release 9, 'var' is a restricted local variable type
@Stephan007
LVTI warnings
var[] x = s; // ‘var' is not allowed as an element type of an array
http://cr.openjdk.java.net/~mcimadamore/8177466/lvti-diags.html
var x = 1, y = 2; // 'var' is not allowed in a compound declaration
var<String> list() { return null; } // illegal ref to restricted type 'var'
var x = () -> { }; // lambda expression needs an explicit target-type
@Stephan007
Hidden compiler option
-XDfind=local
Detect local variables whose declared type can be replaced by 'var'
http://mail.openjdk.java.net/pipermail/compiler-dev/2017-September/011060.html
class TestLVTI {

void test() {

String s2 = "";

for (String s = s2 ; s != "" ; ) { }

Object o = "";

}

}
TestLVTI.java:3: warning: Redundant type for local variable (replace
explicit type with 'var').
String s2 = "";
^
TestLVTI.java:4: warning: Redundant type for local variable (replace
explicit type with 'var').
for (String s = s2 ; s != "" ; ) { }
^
2 warnings
The type of o is not redundant!
@Stephan007
Other JVM Languages
Groovy Kotlin
def robot = new Robot() // mutable property
var name = “Hello”
// Read-only
// there's no 'new' keyword
val result = Address()
Scala & Lombok
// Mutable
var name = ”Hello”
// Read-only
val result = new Address()
BTW None of these JVM languages demand a semi-colon! 🤓
@Stephan007
Immutability?
http://mail.openjdk.java.net/pipermail/platform-jep-discuss/2016-December/000066.html
“Local variables are in reality the least
important place where we need more
help making things immutable. 

Local variables are immune to data races;
most locals are effectively final anyway.”

- Brian Goetz
@Stephan007
Project Amber
• JEP 286 Local-Variable Type Inference
• JEP 301 Enhanced Enums
• JEP 302 Lambda Leftovers
JEP 301 Enhanced Enums
http://openjdk.java.net/jeps/301
@Stephan007
Generic Enums
“Enhance the expressiveness of the enum construct in the
Java Language by allowing type-variables in enums, and
performing sharper type-checking for enum constants.”
- Maurizio Cimadamore
http://openjdk.java.net/jeps/301
@Stephan007
Enum enhancements
enum Argument<X> { // declares generic enum
STRING<String>(String.class),
INTEGER<Integer>(Integer.class), ... ;
Class<X> clazz;
Argument(Class<X> clazz) { this.clazz = clazz; }
Class<X> getClazz() { return clazz; }
}
Class<String> cs = Argument.STRING.getClazz(); //uses sharper typing of enum constant
http://openjdk.java.net/jeps/301
• Enum constants to carry constant-specific type information

• Constant-specific state and behavior. 
JEP 302 Lambda Leftovers
http://openjdk.java.net/jeps/302
@Stephan007
Treatment of underscores
• Use an uncerscore for unnamed lambda parameters
BiFunction<Integer, String, String> biss = (i, _) -> String.valueOf(i);
http://openjdk.java.net/jeps/302
@Stephan007
Shadowing a lambda parameter
• Allow lambda parameters to shadow variables in enclosing scopes.

• And locals declared with a lambda.
Map<String, Integer> msi = …
…
String key = computeSomeKey();
msi.comuteIfAbstent(key, key -> key.length()); // error!
http://openjdk.java.net/jeps/302
Pattern Matching
@Stephan007
String formatted = “unknown”;
if (constant instanceof Integer) {
int i = (Integer)constant;
formatted = String.format(“int %d”, i);
} else if (constant instanceof Byte) {
byte b = (Byte)constant;
formatted = String.format(“byte %d”, b);
} // …
https://www.voxxed.com/2017/08/pattern-matching-java/
@Stephan007
Pattern Matching
String formatted = “unknown”;
switch(constant) {
case Integer i :
formatted = String.format(“int %d”, i); break;
case Byte b :
formatted = String.format(“byte %d”, b); break;
// …
default: formatted = String.format(“Unknown: %s”, constant);
}
https://www.voxxed.com/2017/08/pattern-matching-java/
@Stephan007
Switch Expression
String formatted =
switch(constant) {
case Integer i -> String.format(“int %d”, i);
case Byte b -> String.format(“byte %d”, b);
case Long l -> String.format(“long %d”, l);
case Double d -> String.format(“double %f”, d);
case String s -> String.format(“string %s”, s);
default -> “Unknown”;
}
https://www.voxxed.com/2017/08/pattern-matching-java/
@Stephan007
Enhanced Switch Expression
Shape s = …
double area = switch (shape) {
case Circle(var center, var radius)
-> PI * radius * radius;
case Square(var lowerLeft, var edge)
-> edge * edge;
case Rect(var lowerLeft, var upperRight)
-> (upperRight.x - lowerLeft.x)
* (upperRight.y - lowerLeft.y);
// …
}
interface Shape { }
class Circle implements Shape {
Point center;
double radius;
}
class Square implements Shape {
Point lowerLeft;
double edge;
}
class Rect implements Shape {
Point lowerLeft;
Point upperRight;
}
JavaOne 2017 keynote : https://www.youtube.com/watch?v=Tf5rlIS6tkg
@Stephan007
val x = Random.nextInt(10)
val value = x match {
case 0 => “zero”
case 1 => "one"
case 2 => "two"
case _ => "many"
}
val value = when(x) {
0 -> “zero”
1 -> "one"
2 -> "two"
else -> "many"
}
@Stephan007
Valhalla
JEP 169 Value Types
“Codes like a class, works like an int!”
@Stephan007
public class Point {
final int x;
final int y;
}
http://cr.openjdk.java.net/~jrose/values/values-0.html
@Stephan007
public class Point {
final int x;
final int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public boolean equals(Object o) {
return o instanceof Point && x == ((Point)o).x && y == ((Point)o).y;
}
public int hashCode() {
return x + 31 * y;
}
public String toString() {
return String.format(“Point[%d,%d]”, x, y);
}
}
http://cr.openjdk.java.net/~jrose/values/values-0.html
Data Classes
“Just data, no identiy”
@Stephan007
public class Point(int x, int y) { }
http://cr.openjdk.java.net/~jrose/values/values-0.html
@Stephan007
Value Types Requirements
• Final, not extensible

• Only interface parents

• Immutable fields

• No identity

• Equality based on state
• No recursive definitions

• Non-nullable values

• Value semantics

• No (representational) polymorphism

• Multiple fields supported
JEP 218 Generics over Primitive Types
ArrayList<int>
@Stephan007
Generic type arguments are
constrained to extend Object
• Supporting generic primitive and value types arguments!
class Box<T> {
private final T t;
public Box(T t) { this.t = t; }
public T get() { return t; }
}
http://openjdk.java.net/jeps/218
• Suppose we want to specialize the following class with T=int
@Stephan007
• Project Amber

• Project Valhalla

• Project Panama - Interconnecting JVM and native code

• Project Loom - Make Concurrency simple(r) again!

• Project Metropolis - The holy Graal
Personal Wishlist
IF expressions
Even better, change all statements into expressions 🤓
@Stephan007
Resources :
Brian Goetz - Java Language Architect, Oracle John Rose, JVM Architect, Oracle
November 22nd, 2017

More Related Content

What's hot

An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersMiles Sabin
 
10 Things I Hate About Scala
10 Things I Hate About Scala10 Things I Hate About Scala
10 Things I Hate About ScalaMeir Maor
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzJAX London
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Aaron Gustafson
 
All You Need to Know About Type Script
All You Need to Know About Type ScriptAll You Need to Know About Type Script
All You Need to Know About Type ScriptFolio3 Software
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the futureAnsviaLab
 
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...Edureka!
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basicsmsemenistyi
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaSaleem Ansari
 

What's hot (19)

An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Scala coated JVM
Scala coated JVMScala coated JVM
Scala coated JVM
 
10 Things I Hate About Scala
10 Things I Hate About Scala10 Things I Hate About Scala
10 Things I Hate About Scala
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
 
Scala fundamentals
Scala fundamentalsScala fundamentals
Scala fundamentals
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 
Google Dart
Google DartGoogle Dart
Google Dart
 
All You Need to Know About Type Script
All You Need to Know About Type ScriptAll You Need to Know About Type Script
All You Need to Know About Type Script
 
Javascript
JavascriptJavascript
Javascript
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
 
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript Basics
Javascript BasicsJavascript Basics
Javascript Basics
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 

Similar to Java, what's next?

Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvmIsaias Barroso
 
Scala Programming for Semantic Web Developers ESWC Semdev2015
Scala Programming for Semantic Web Developers ESWC Semdev2015Scala Programming for Semantic Web Developers ESWC Semdev2015
Scala Programming for Semantic Web Developers ESWC Semdev2015Jean-Paul Calbimonte
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanJimin Hsieh
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To ScalaPeter Maas
 
Introduction to programming in scala
Introduction to programming in scalaIntroduction to programming in scala
Introduction to programming in scalaAmuhinda Hungai
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGSylvain Wallez
 
Intro to scala
Intro to scalaIntro to scala
Intro to scalaJoe Zulli
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistpmanvi
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java ProgrammersEric Pederson
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of JavascriptSamuel Abraham
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaRahul Jain
 
JavaFX In Practice
JavaFX In PracticeJavaFX In Practice
JavaFX In PracticeRichard Bair
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaWO Community
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 

Similar to Java, what's next? (20)

Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
 
Scala Programming for Semantic Web Developers ESWC Semdev2015
Scala Programming for Semantic Web Developers ESWC Semdev2015Scala Programming for Semantic Web Developers ESWC Semdev2015
Scala Programming for Semantic Web Developers ESWC Semdev2015
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 
Introduction to programming in scala
Introduction to programming in scalaIntroduction to programming in scala
Introduction to programming in scala
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
Intro to scala
Intro to scalaIntro to scala
Intro to scala
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
JavaFX In Practice
JavaFX In PracticeJavaFX In Practice
JavaFX In Practice
 
js.pptx
js.pptxjs.pptx
js.pptx
 
Scala.js
Scala.jsScala.js
Scala.js
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 

More from Stephan Janssen

Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)Stephan Janssen
 
The new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & KubernetesThe new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & KubernetesStephan Janssen
 
The new Voxxed websites with JHipster, Angular and GitLab
The new Voxxed websites  with JHipster, Angular and GitLabThe new Voxxed websites  with JHipster, Angular and GitLab
The new Voxxed websites with JHipster, Angular and GitLabStephan Janssen
 
Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5Stephan Janssen
 
Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2Stephan Janssen
 

More from Stephan Janssen (17)

Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)Devoxx speaker training (June 27th, 2018)
Devoxx speaker training (June 27th, 2018)
 
The new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & KubernetesThe new DeVoxxEd websites with JHipster, Angular & Kubernetes
The new DeVoxxEd websites with JHipster, Angular & Kubernetes
 
The new Voxxed websites with JHipster, Angular and GitLab
The new Voxxed websites  with JHipster, Angular and GitLabThe new Voxxed websites  with JHipster, Angular and GitLab
The new Voxxed websites with JHipster, Angular and GitLab
 
Programming 4 kids
Programming 4 kidsProgramming 4 kids
Programming 4 kids
 
Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5Devoxx2011 timesheet day3-4-5
Devoxx2011 timesheet day3-4-5
 
Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2Devoxx2011 timesheet day1-2
Devoxx2011 timesheet day1-2
 
EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
 
BeJUG JAX-RS Event
BeJUG JAX-RS EventBeJUG JAX-RS Event
BeJUG JAX-RS Event
 
Whats New In Java Ee 6
Whats New In Java Ee 6Whats New In Java Ee 6
Whats New In Java Ee 6
 
Glass Fishv3 March2010
Glass Fishv3 March2010Glass Fishv3 March2010
Glass Fishv3 March2010
 
Advanced Scrum
Advanced ScrumAdvanced Scrum
Advanced Scrum
 
Scala by Luc Duponcheel
Scala by Luc DuponcheelScala by Luc Duponcheel
Scala by Luc Duponcheel
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Kick Start Jpa
Kick Start JpaKick Start Jpa
Kick Start Jpa
 
BeJUG - Di With Spring
BeJUG - Di With SpringBeJUG - Di With Spring
BeJUG - Di With Spring
 
BeJUG - Spring 3 talk
BeJUG - Spring 3 talkBeJUG - Spring 3 talk
BeJUG - Spring 3 talk
 
BeJug.Org Java Generics
BeJug.Org   Java GenericsBeJug.Org   Java Generics
BeJug.Org Java Generics
 

Recently uploaded

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 

Recently uploaded (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

Java, what's next?

  • 1. Java, what’s next? by Stephan Janssen
  • 2. • Founder of Devoxx • Co-founder of Voxxed (Days) • Co-founder Devoxx4Kids • Java Champion • Passionate Developer Who am I ?
  • 3. “The Future Is Complicated” - John Rose , JVM Architect
  • 4. “For Java to remain competitive it must not just continue to move forward — it must move forward faster.” - Mark Reinhold , Chief Architect of the Java Platform Group at Oracle
  • 5. @Stephan007 More Java Releases • Every 6 months feature releases (March, September) • Long-term support releases every 3 years • Next release for March 2018 • Details @ https://mreinhold.org/blog/forward-faster
  • 7. @Stephan007 • Project Amber • Project Valhalla • Project Panama - Interconnecting JVM and native code • Project Loom - Make Concurrency simple(r) again! • Project Metropolis - The holy Graal : a Java compiler & interpreter
  • 8. How will this effect you?
  • 10. @Stephan007 Project Amber • Local-Variable Type Inference • Enhanced Enums • Lambda Leftovers • Pattern matching • Switch expression https://openjdk.java.net/projects/amber/
  • 11. JEP 286 Local-Variable Type Inference (LVTI) (Java 18.3 target release)
  • 12. @Stephan007 Expanded Type Inference List<String> empty = Collections.<String>emptyList(); List<String> empty = Collections.emptyList(); • Java 5: type inference for generic method type arguments • Java 7: type inference for constructor type arguments List<String> newList = new ArrayList<String>(); List<String> newList = new ArrayList<>(); • Java 8: type inference for lambda formals Predicate<String> isEmpty = (String s) -> s.isEmpty(); Predicate<String> isEmpty = s -> s.isEmpty(); Brian Goetz @ http://bit.ly/2x3Wop9
  • 13. @Stephan007 Local-Variable Type Inference (JEP 286) URL url = new URL(“https://devoxx.com"); URLConnection conn = url.openConnection(); Scanner scanner = new Scanner(conn.getInputStream(), “UTF-8”); var url = new URL(“https://devoxx.com"); var conn = url.openConnection(); var scanner = new Scanner(conn.getInputStream(), “UTF-8”); Brian Goetz @ http://bit.ly/2x3Wop9
  • 14. @Stephan007 LVTI warnings var x = { 1, 2, 3 }; // array initializer needs an explicit target-type http://cr.openjdk.java.net/~mcimadamore/8177466/lvti-diags.html var x = null; // variable initializer is 'null' var x; // cannot use 'var' on variable without initializer var x = m(x); // cannot use 'var' on self-referencing variable class var { } // as of release 9, 'var' is a restricted local variable type
  • 15. @Stephan007 LVTI warnings var[] x = s; // ‘var' is not allowed as an element type of an array http://cr.openjdk.java.net/~mcimadamore/8177466/lvti-diags.html var x = 1, y = 2; // 'var' is not allowed in a compound declaration var<String> list() { return null; } // illegal ref to restricted type 'var' var x = () -> { }; // lambda expression needs an explicit target-type
  • 16. @Stephan007 Hidden compiler option -XDfind=local Detect local variables whose declared type can be replaced by 'var' http://mail.openjdk.java.net/pipermail/compiler-dev/2017-September/011060.html class TestLVTI { void test() { String s2 = ""; for (String s = s2 ; s != "" ; ) { } Object o = ""; } } TestLVTI.java:3: warning: Redundant type for local variable (replace explicit type with 'var'). String s2 = ""; ^ TestLVTI.java:4: warning: Redundant type for local variable (replace explicit type with 'var'). for (String s = s2 ; s != "" ; ) { } ^ 2 warnings The type of o is not redundant!
  • 17. @Stephan007 Other JVM Languages Groovy Kotlin def robot = new Robot() // mutable property var name = “Hello” // Read-only // there's no 'new' keyword val result = Address() Scala & Lombok // Mutable var name = ”Hello” // Read-only val result = new Address() BTW None of these JVM languages demand a semi-colon! 🤓
  • 18. @Stephan007 Immutability? http://mail.openjdk.java.net/pipermail/platform-jep-discuss/2016-December/000066.html “Local variables are in reality the least important place where we need more help making things immutable. Local variables are immune to data races; most locals are effectively final anyway.” - Brian Goetz
  • 19. @Stephan007 Project Amber • JEP 286 Local-Variable Type Inference • JEP 301 Enhanced Enums • JEP 302 Lambda Leftovers
  • 21. @Stephan007 Generic Enums “Enhance the expressiveness of the enum construct in the Java Language by allowing type-variables in enums, and performing sharper type-checking for enum constants.” - Maurizio Cimadamore http://openjdk.java.net/jeps/301
  • 22. @Stephan007 Enum enhancements enum Argument<X> { // declares generic enum STRING<String>(String.class), INTEGER<Integer>(Integer.class), ... ; Class<X> clazz; Argument(Class<X> clazz) { this.clazz = clazz; } Class<X> getClazz() { return clazz; } } Class<String> cs = Argument.STRING.getClazz(); //uses sharper typing of enum constant http://openjdk.java.net/jeps/301 • Enum constants to carry constant-specific type information • Constant-specific state and behavior. 
  • 24. @Stephan007 Treatment of underscores • Use an uncerscore for unnamed lambda parameters BiFunction<Integer, String, String> biss = (i, _) -> String.valueOf(i); http://openjdk.java.net/jeps/302
  • 25. @Stephan007 Shadowing a lambda parameter • Allow lambda parameters to shadow variables in enclosing scopes. • And locals declared with a lambda. Map<String, Integer> msi = … … String key = computeSomeKey(); msi.comuteIfAbstent(key, key -> key.length()); // error! http://openjdk.java.net/jeps/302
  • 27. @Stephan007 String formatted = “unknown”; if (constant instanceof Integer) { int i = (Integer)constant; formatted = String.format(“int %d”, i); } else if (constant instanceof Byte) { byte b = (Byte)constant; formatted = String.format(“byte %d”, b); } // … https://www.voxxed.com/2017/08/pattern-matching-java/
  • 28. @Stephan007 Pattern Matching String formatted = “unknown”; switch(constant) { case Integer i : formatted = String.format(“int %d”, i); break; case Byte b : formatted = String.format(“byte %d”, b); break; // … default: formatted = String.format(“Unknown: %s”, constant); } https://www.voxxed.com/2017/08/pattern-matching-java/
  • 29. @Stephan007 Switch Expression String formatted = switch(constant) { case Integer i -> String.format(“int %d”, i); case Byte b -> String.format(“byte %d”, b); case Long l -> String.format(“long %d”, l); case Double d -> String.format(“double %f”, d); case String s -> String.format(“string %s”, s); default -> “Unknown”; } https://www.voxxed.com/2017/08/pattern-matching-java/
  • 30. @Stephan007 Enhanced Switch Expression Shape s = … double area = switch (shape) { case Circle(var center, var radius) -> PI * radius * radius; case Square(var lowerLeft, var edge) -> edge * edge; case Rect(var lowerLeft, var upperRight) -> (upperRight.x - lowerLeft.x) * (upperRight.y - lowerLeft.y); // … } interface Shape { } class Circle implements Shape { Point center; double radius; } class Square implements Shape { Point lowerLeft; double edge; } class Rect implements Shape { Point lowerLeft; Point upperRight; } JavaOne 2017 keynote : https://www.youtube.com/watch?v=Tf5rlIS6tkg
  • 31. @Stephan007 val x = Random.nextInt(10) val value = x match { case 0 => “zero” case 1 => "one" case 2 => "two" case _ => "many" } val value = when(x) { 0 -> “zero” 1 -> "one" 2 -> "two" else -> "many" }
  • 33. JEP 169 Value Types “Codes like a class, works like an int!”
  • 34. @Stephan007 public class Point { final int x; final int y; } http://cr.openjdk.java.net/~jrose/values/values-0.html
  • 35. @Stephan007 public class Point { final int x; final int y; public Point(int x, int y) { this.x = x; this.y = y; } public boolean equals(Object o) { return o instanceof Point && x == ((Point)o).x && y == ((Point)o).y; } public int hashCode() { return x + 31 * y; } public String toString() { return String.format(“Point[%d,%d]”, x, y); } } http://cr.openjdk.java.net/~jrose/values/values-0.html
  • 36. Data Classes “Just data, no identiy”
  • 37. @Stephan007 public class Point(int x, int y) { } http://cr.openjdk.java.net/~jrose/values/values-0.html
  • 38. @Stephan007 Value Types Requirements • Final, not extensible • Only interface parents • Immutable fields • No identity • Equality based on state • No recursive definitions • Non-nullable values • Value semantics • No (representational) polymorphism • Multiple fields supported
  • 39. JEP 218 Generics over Primitive Types
  • 41. @Stephan007 Generic type arguments are constrained to extend Object • Supporting generic primitive and value types arguments! class Box<T> { private final T t; public Box(T t) { this.t = t; } public T get() { return t; } } http://openjdk.java.net/jeps/218 • Suppose we want to specialize the following class with T=int
  • 42. @Stephan007 • Project Amber • Project Valhalla • Project Panama - Interconnecting JVM and native code • Project Loom - Make Concurrency simple(r) again! • Project Metropolis - The holy Graal
  • 44. IF expressions Even better, change all statements into expressions 🤓
  • 45.
  • 46. @Stephan007 Resources : Brian Goetz - Java Language Architect, Oracle John Rose, JVM Architect, Oracle