SlideShare a Scribd company logo
1 of 66
@MichelSchudel
michel@craftsmen.nl
@MichelSchudel
Java version usage as of october 2018
https://snyk.io/blog/jvm-ecosystem-report-2018/
@MichelSchudel
https://www.infoworld.com/article/3227244/java-9-is-here-everything-you-need-to-know.html
@MichelSchudel
• Solves the encapsulation gab at
module (JAR) level
• No access to internal non-cricital
API’s anymore
• Possibility of releasing small
programs (Jlink)
@MichelSchudel
module-info.java
module nl.craftsmen.myuimodule {
requires nl.craftsmen.myservicemodule;
exports nl.craftsmen.ui;
}
module nl.craftsmen.myservicemodule {
requires java.logging;
exports nl.craftsmen.service;
}
module
package
references
@MichelSchudel
Building a custom image
Jlink
--module-path target/classes
--add-modules moduledemo,java.base
--output moduledemo
--launcher
moduledemo=moduledemo/nl.craftsmen.moduledemo.ModuleDemo
@MichelSchudel
Hello, world! Image: 39MB
http://www.techort.com/review-of-java-9-habrahabr/
var text = "hi JBCNConf!";
var stringList = List.of("a", "b", "c");
var stringMap = Map.of("key1", "value1");
var intSet = Set.of(1,2,3);
var name = getName();
var otherThing = getNull();
String text = "hi JBCNConf!";
List<String> stringList = List.of("a", "b", "c");
Map<String,String> stringMap = Map.of("key1", "value1");
Set<Integer> intSet = Set.of(1,2,3);
String name = getName();
Object otherThing = getNull();
@MichelSchudel
//won't work, no type can be determined
var x;
//won't work, method reference
var name2 = Main::getName;
//won't work, null reference
var nullValue = null;
//won't work, array initializer
var stringArray = {1, 2};
@MichelSchudel
https://blog.overops.com/java-community-survey-results-74-of-developers-want-less-verbosity/
Local variable syntax for Lamba parameters
//java 10
(int x, int y) -> x + y;
//java 11
(var x, var y) -> x + y;
(x, y) -> x + y;
(@NotNull var x, @Nullable var y) -> x + y;
(var x, var y) -> x + y;
@MichelSchudel
Http Client
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.followRedirects(HttpClient.Redirect.NORMAL)
.connectTimeout(Duration.ofSeconds(20))
.build();
HttpRequest httpRequest = HttpRequest
.newBuilder()
.header("myHeader", "myValue")
.uri(URI.create("http://localhost:4567/hello"))
.build();
HttpResponse<String> response = client
.send(httpRequest, HttpResponse.BodyHandlers.ofString());
@MichelSchudel
Some nice API additions
" ".isBlank()  true
 JBCNConfJBCNConf
Arrays.stream(someText.split("r")).forEach(System.out::println);
Optional<String> optional = getStringValue();
If (optional.isEmpty() {..}
someText.lines().forEach(System.out::println);
new String(new char[2])
.replace("0", “JBCNConf"));
“JBCNConf".repeat(2)
@MichelSchudel
https://docs.google.com/document/d/1nFGazvrCvHMZJgFstlbz
oHjpAVwv5DEdnaBr_5pKuHo/preview#heading=h.p3qt2oh5ec
zi
@MichelSchudel
You have to pay Oracle a periodic subscription fee if
• You use the OracleJDK commercially
• You‘re on java 9+ or want to use Java 8u211 or higher
Using the OracleJDK non-commercially is free
(at least until september 2020)
$2.5(USD) per month per user
$25(USD) per month per server
https://docs.google.com/document/d/1nFGazvrCvHMZJgFstlbz
oHjpAVwv5DEdnaBr_5pKuHo/preview#heading=h.p3qt2oh5ec
zi
@MichelSchudel
• Not free for commercial use since april 16th, 2019
• JDK8u211
• Older versions ARE free for commercial use
• AdoptOpenJDK (https://adoptopenjdk.net/)
• Amazon Corretto (https://aws.amazon.com/corretto/)
• Jclarity OpenJDK (https://www.jclarity.com/index.php)
If you want the latest security patches
• Get a subscription, or grab and openjdk build:
• OracleJDK not free for commercial use
• OpenJDK is free under GPLv2+CE license
• Only two quarterly updates, however
• AdoptOpenJDK (https://adoptopenjdk.net/)
• Amazon Corretto (https://aws.amazon.com/corretto/)
• Jclarity OpenJDK (https://www.jclarity.com/index.php)
• Get a subscription for the OracleJDK
• Get the Oracle OpenJDK (https://jdk.java.net/)
• For the latest security patches, grab an OpenJDK build:
https://blog.overops.com/the-complete-guide-to-java-12-new-features/
• JEP 325: Switch expressions
• Some small api changes
• JEP 326: Raw string literals
• JEP 189: Shenandoah GC
• JEP 341: Default CDS archives
• JEP 334: Constants API
• JEP 344: Abortable G1
@MichelSchudel
Switch expressions are experimental
To try out switch expressions, use
--enable-preview
parameterwhen starting JVM
https://github.com/MichelSchudel/java12demo
@MichelSchudel
• Ultra low-pause garbage collector
java -XX:+UseShenandoahGC
@since 13
@MichelSchudel
/**
* The singleton instance for the 'Reiwa' era (2019-05-01 - )
* which has the value 3. The end date of this era is not specified, unless
* the Japanese Government defines it.
*
* @since 13
*/
public static final JapaneseEra REIWA = new JapaneseEra(3, LocalDate.of(2019, 5, 1));
@MichelSchudel
Value Types (JEP-169)
class Tuple {
int val1;
int val2;
}
Object
header
val1
val2
Object
header
val1
val2
Object
header
val1
val2
value class Tuple
{
int value1;
int value2;
}
val1, val2
val1, val2
val1, val2
@MichelSchudel
Cl
Value Types (JEP-169)
• No object identity (does NOT extend Object)
• Instances are equal based on their data
• Immutable (just like primitives)
“Codes like a class, works like an int” – Brian Goetz
…but what about generics?
@MichelSchudel
With introducing value types, restriction on
Object when using generics becomes more
cumbersome
List<int> integers;
List<Tuple> tuples;
Generic specialization (JEP-218)
@MichelSchudel
Current threading model
Runnable
Runnable
Executor
Thread
Thread
Thread
Thread
Current threading model
Thread
Task Scheduler
Instructions Switch thread
OS OS
Current threading model
• Thread call stack includes native stack (big
footprint)
• No way to guarantee that two related
threads run on the same cpu (core)
@MichelSchudel
Solution
Core Core
Core Core
Fibers
Threads
Java Fiber Scheduler
OS Thread Scheduler
(fe ForkJoinPool)
@MichelSchudel
Delivered
• Local-variable type inference (JEP-286), JDK10
• Local-variable syntax for lambda parameters (JEP-323), JDK11
Preview
• Switch expressions (JEP-325) (JDK12)
In development
• Raw string literals (JEP-326) Text blocks (JEP-355)
• Pattern matching (JEP-310)
On hold
• Enhanced enums (JEP-301)
@MichelSchudel
Text blocks (JEP-355)
String html = "<html>n" +
" <body>n" +
" <p>Hello, "world"</p>n" +
" </body>n“ +
"</html>n";
String html = """
<html>
<body>
<p>Hello, "world"</p>
</body>
</html>
""";
..............
..............
..............
..............
..............
..............
@MichelSchudel
Pattern matching (JEP-355)
Object obj =…
if (obj instanceof String) {
String s = (String)obj;
System.out.println(s.toUpperCase());
} else if (obj instanceof Integer) {
Integer i = (Integer)obj;
System.out.println(i.doubleValue());
}
Object obj =…
if (obj instanceof String s) {
System.out.println(s.toUpperCase());
} else if (obj instanceof Integer i) {
System.out.println(i.doubleValue());
}
@MichelSchudel
Pattern matching (JEP-355)
String formatted = switch (obj) {
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 -> String.format("Object %s", obj);
};
@MichelSchudel
interface Expression{
int evaluate();
}
class SimpleExpression implements Expression {
int value;
int evaluate() {
return value;
}
}
class ComplexExpression implements Expression {
Expression left, right;
int evaluate() {
return left.evaluate() + right.evaluate();
}
}
Pattern matching (JEP-355)
@MichelSchudel
interface ExpressionVisitor<T> {
T visit(SimpleExpression expression);
T visit(ComplexExpression expression);
}
Pattern matching (JEP-355)
class MyVisitor implements ExpressionVisitor<Integer> {
Integer visit(SimpleExpression expr) { return expr.value; }
Integer visit(ComplexExpression expr) { return expr.left.accept(this)
+ expr.right.accept(this); }
}
@MichelSchudel
int evaluate(Expression expr) {
return switch(expr) {
case SimpleExpression(int value) -> value;
case ComplexExpression(Expression left, Expression right) ->
evaluate(left) + evaluate(right);
};
}
Pattern matching (JEP-355)
Deconstruction patterns
class SimpleExpression { value }
class ComplexExpression { left, right }
value
value
@MichelSchudel
https://openjdk.java.net/projects/panama/
https://openjdk.java.net/projects/valhalla/
https://openjdk.java.net/projects/amber/
https://openjdk.java.net/projects/loom/
• Java 9, 10, 11 recap
• Java 12 overview
• Java 13 preview
• The Java future
• Panama
• Valhalla
• Loom
• Amber
Uncovering project Amber
Mala Gupta
Java Futures
Brian Goetz
OpenJDK, the Future of Java
Mario Torre
How to participate in the future of Java
Heather VanCura
https://github.com/MichelSchudel/java12demo
@MichelSchudel
michel@craftsmen.nl
Demo slides
(in case you didn’t see the demo
about what’s new in java 12
Traditional switch statement
public String getConference(Conference conference) {
switch (conference) {
case JBCNCONF:
return "JBCNConf";
case DEVOXX:
return "Devoxx";
case DEVOXX_UK:
return "Devoxx UK";
default:
throw new RuntimeException("unknown type!");
}
}
A traditional switch statement. Notice that the default must be specified,
Even although the enum’s values are exhausted
Switch expression
public String getConferenceExpression(Conference conference) {
String s = switch (conference) {
case JBCNCONF:
break "JBCNConf";
case DEVOXX:
break "Devoxx";
case DEVOXX_UK:
break "DevoxxUK";
};
return s;
}
A switch expression. The break returns the value. Since it’s an expression,
You dont need a default statement since all enum values are convered.
Switch expression, lamba style
public String getConferenceLambdas(Conference conference) {
String s = switch (conference) {
case JBCNCONF -> "JBCNConf";
case DEVOXX -> "Devoxx";
case DEVOXX_UK -> "DevoxxUK";
};
return s;
}
Switch expressions can be elegantly written lamba style.
Multilabel switch expressions
public String getConferenceMultiLabel(Conference conference) {
String s = switch (conference) {
case JBCNCONF -> "JBCNConf";
case DEVOXX, DEVOXX_UK -> "Devoxx";
};
return s;
}
You can state multiple labels for one branch, without the nasty fallthrough cases without breaks.
public String getConferenceMultiStatement(Conference conference) {
String s = switch (conference) {
case JBCNCONF -> {
System.out.println("conference = [" + conference + "]");
break "JBCNConf";
}
case DEVOXX, DEVOXX_UK -> "Devoxx";
};
return s;
}
Switch expression, multiline
Multiple expressions are delimited by {}. In this case, you MUST use a break.
Switch expression, supertype
public Object getConferenceTypeResolving(Conference conference) {
Object s = switch (conference) {
case JBCNCONF -> {
System.out.println("conference = [" + conference + "]");
break "JBCNConf";
}
case DEVOXX, DEVOXX_UK -> "Devoxx";
default -> new RuntimeException();
};
return s;
}
When multiple branches return multiple types, the type of the switch expression is the closest
common supertype.
Teeing collector
The teeing collector takes two Collectors, and passes both Collector results to a function.
public void teeingDemo() {
double average = Stream.of(1, 4, 2, 7, 4, 12)
.collect(Collectors.teeing(
Collectors.summingDouble(i -> i),
Collectors.counting(),
(sum, n) -> sum / n));
System.out.println(average);
}
String transform method
The new transform method takes a function to transform a string. The output can be any type.
public void transformDemo() {
String conference = "2019";
Integer i = conference.transform(Integer::parseInt);
System.out.println(i);
}

More Related Content

What's hot

Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Raffi Khatchadourian
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
 
What's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverWhat's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverCodemotion
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University
 
Java Review
Java ReviewJava Review
Java Reviewpdgeorge
 
Android MvRx Framework 介紹
Android MvRx Framework 介紹Android MvRx Framework 介紹
Android MvRx Framework 介紹Kros Huang
 
Scalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureNicholas Zakas
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptKaty Slemon
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized projectFabio Collini
 
Системный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестовСистемный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестовCOMAQA.BY
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New FeaturesNaveen Hegde
 
When Sightly Meets Slice by Tomasz Niedźwiedź
When Sightly Meets Slice by Tomasz NiedźwiedźWhen Sightly Meets Slice by Tomasz Niedźwiedź
When Sightly Meets Slice by Tomasz NiedźwiedźAEM HUB
 
An Empirical Study on the Use and Misuse of Java 8 Streams
An Empirical Study on the Use and Misuse of Java 8 StreamsAn Empirical Study on the Use and Misuse of Java 8 Streams
An Empirical Study on the Use and Misuse of Java 8 StreamsRaffi Khatchadourian
 

What's hot (20)

Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...Defaultification Refactoring: A Tool for Automatically Converting Java Method...
Defaultification Refactoring: A Tool for Automatically Converting Java Method...
 
Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
 
EMF Tips n Tricks
EMF Tips n TricksEMF Tips n Tricks
EMF Tips n Tricks
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
What's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverWhat's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - Weaver
 
Collections
CollectionsCollections
Collections
 
Commit University - Exploring Angular 2
Commit University - Exploring Angular 2Commit University - Exploring Angular 2
Commit University - Exploring Angular 2
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Java Review
Java ReviewJava Review
Java Review
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java Annotations and Pre-processing
Java  Annotations and Pre-processingJava  Annotations and Pre-processing
Java Annotations and Pre-processing
 
Android MvRx Framework 介紹
Android MvRx Framework 介紹Android MvRx Framework 介紹
Android MvRx Framework 介紹
 
Scalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application Architecture
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescript
 
Using hilt in a modularized project
Using hilt in a modularized projectUsing hilt in a modularized project
Using hilt in a modularized project
 
Системный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестовСистемный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестов
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
When Sightly Meets Slice by Tomasz Niedźwiedź
When Sightly Meets Slice by Tomasz NiedźwiedźWhen Sightly Meets Slice by Tomasz Niedźwiedź
When Sightly Meets Slice by Tomasz Niedźwiedź
 
An Empirical Study on the Use and Misuse of Java 8 Streams
An Empirical Study on the Use and Misuse of Java 8 StreamsAn Empirical Study on the Use and Misuse of Java 8 Streams
An Empirical Study on the Use and Misuse of Java 8 Streams
 

Similar to Java n-plus-1-incl-demo-slides

WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James NelsonGWTcon
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java DevelopersYakov Fain
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_HourDilip Patel
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)Jose Manuel Pereira Garcia
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
Scala Frustrations
Scala FrustrationsScala Frustrations
Scala Frustrationstakezoe
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Matt Raible
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteorKen Ono
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteorKen Ono
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Getting Reactive with CycleJS and XStream
Getting Reactive with CycleJS and XStream Getting Reactive with CycleJS and XStream
Getting Reactive with CycleJS and XStream TechExeter
 

Similar to Java n-plus-1-incl-demo-slides (20)

WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java Developers
 
Java 7: Quo vadis?
Java 7: Quo vadis?Java 7: Quo vadis?
Java 7: Quo vadis?
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Angular
AngularAngular
Angular
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Scala Frustrations
Scala FrustrationsScala Frustrations
Scala Frustrations
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
JS Essence
JS EssenceJS Essence
JS Essence
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
MDE in Practice
MDE in PracticeMDE in Practice
MDE in Practice
 
Getting Reactive with CycleJS and XStream
Getting Reactive with CycleJS and XStream Getting Reactive with CycleJS and XStream
Getting Reactive with CycleJS and XStream
 

More from Michel Schudel

Testing an onion architecture - done right
Testing an onion architecture - done rightTesting an onion architecture - done right
Testing an onion architecture - done rightMichel Schudel
 
What makes a high performance team tick?
What makes a high performance team tick?What makes a high performance team tick?
What makes a high performance team tick?Michel Schudel
 
Atonomy of-a-tls-handshake-mini-conferentie
Atonomy of-a-tls-handshake-mini-conferentieAtonomy of-a-tls-handshake-mini-conferentie
Atonomy of-a-tls-handshake-mini-conferentieMichel Schudel
 
Spring boot Under Da Hood
Spring boot Under Da HoodSpring boot Under Da Hood
Spring boot Under Da HoodMichel Schudel
 
Cryptography 101 for Java Developers - Devoxx 2019
Cryptography 101 for Java Developers - Devoxx 2019Cryptography 101 for Java Developers - Devoxx 2019
Cryptography 101 for Java Developers - Devoxx 2019Michel Schudel
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Michel Schudel
 
Cryptography 101 for_java_developers, Fall 2019
Cryptography 101 for_java_developers, Fall 2019Cryptography 101 for_java_developers, Fall 2019
Cryptography 101 for_java_developers, Fall 2019Michel Schudel
 
Cryptography 101 for Java Developers - JavaZone2019
Cryptography 101 for Java Developers - JavaZone2019Cryptography 101 for Java Developers - JavaZone2019
Cryptography 101 for Java Developers - JavaZone2019Michel Schudel
 
Cryptography 101 for Java developers
Cryptography 101 for Java developersCryptography 101 for Java developers
Cryptography 101 for Java developersMichel Schudel
 
Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!Michel Schudel
 
Cryptography 101 for Java developers
Cryptography 101 for Java developersCryptography 101 for Java developers
Cryptography 101 for Java developersMichel Schudel
 
Let's Build A Blockchain... in 40 minutes!
Let's Build A Blockchain... in 40 minutes!Let's Build A Blockchain... in 40 minutes!
Let's Build A Blockchain... in 40 minutes!Michel Schudel
 
Test your microservices with REST-Assured
Test your microservices with REST-AssuredTest your microservices with REST-Assured
Test your microservices with REST-AssuredMichel Schudel
 

More from Michel Schudel (16)

Testing an onion architecture - done right
Testing an onion architecture - done rightTesting an onion architecture - done right
Testing an onion architecture - done right
 
What makes a high performance team tick?
What makes a high performance team tick?What makes a high performance team tick?
What makes a high performance team tick?
 
Atonomy of-a-tls-handshake-mini-conferentie
Atonomy of-a-tls-handshake-mini-conferentieAtonomy of-a-tls-handshake-mini-conferentie
Atonomy of-a-tls-handshake-mini-conferentie
 
Spring boot Under Da Hood
Spring boot Under Da HoodSpring boot Under Da Hood
Spring boot Under Da Hood
 
Cryptography 101 for Java Developers - Devoxx 2019
Cryptography 101 for Java Developers - Devoxx 2019Cryptography 101 for Java Developers - Devoxx 2019
Cryptography 101 for Java Developers - Devoxx 2019
 
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition! Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
Battle Of The Microservice Frameworks: Micronaut versus Quarkus edition!
 
Cryptography 101 for_java_developers, Fall 2019
Cryptography 101 for_java_developers, Fall 2019Cryptography 101 for_java_developers, Fall 2019
Cryptography 101 for_java_developers, Fall 2019
 
Cryptography 101 for Java Developers - JavaZone2019
Cryptography 101 for Java Developers - JavaZone2019Cryptography 101 for Java Developers - JavaZone2019
Cryptography 101 for Java Developers - JavaZone2019
 
Micronaut brainbit
Micronaut brainbitMicronaut brainbit
Micronaut brainbit
 
Cryptography 101 for Java developers
Cryptography 101 for Java developersCryptography 101 for Java developers
Cryptography 101 for Java developers
 
Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!
 
Cryptography 101 for Java developers
Cryptography 101 for Java developersCryptography 101 for Java developers
Cryptography 101 for Java developers
 
Let's Build A Blockchain... in 40 minutes!
Let's Build A Blockchain... in 40 minutes!Let's Build A Blockchain... in 40 minutes!
Let's Build A Blockchain... in 40 minutes!
 
What's new in Java 11
What's new in Java 11What's new in Java 11
What's new in Java 11
 
Java 9 overview
Java 9 overviewJava 9 overview
Java 9 overview
 
Test your microservices with REST-Assured
Test your microservices with REST-AssuredTest your microservices with REST-Assured
Test your microservices with REST-Assured
 

Recently uploaded

WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 

Recently uploaded (20)

WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 

Java n-plus-1-incl-demo-slides

  • 3. Java version usage as of october 2018 https://snyk.io/blog/jvm-ecosystem-report-2018/ @MichelSchudel
  • 4.
  • 7. • Solves the encapsulation gab at module (JAR) level • No access to internal non-cricital API’s anymore • Possibility of releasing small programs (Jlink) @MichelSchudel
  • 8. module-info.java module nl.craftsmen.myuimodule { requires nl.craftsmen.myservicemodule; exports nl.craftsmen.ui; } module nl.craftsmen.myservicemodule { requires java.logging; exports nl.craftsmen.service; } module package references @MichelSchudel
  • 9. Building a custom image Jlink --module-path target/classes --add-modules moduledemo,java.base --output moduledemo --launcher moduledemo=moduledemo/nl.craftsmen.moduledemo.ModuleDemo @MichelSchudel Hello, world! Image: 39MB
  • 11.
  • 12.
  • 13. var text = "hi JBCNConf!"; var stringList = List.of("a", "b", "c"); var stringMap = Map.of("key1", "value1"); var intSet = Set.of(1,2,3); var name = getName(); var otherThing = getNull(); String text = "hi JBCNConf!"; List<String> stringList = List.of("a", "b", "c"); Map<String,String> stringMap = Map.of("key1", "value1"); Set<Integer> intSet = Set.of(1,2,3); String name = getName(); Object otherThing = getNull(); @MichelSchudel
  • 14. //won't work, no type can be determined var x; //won't work, method reference var name2 = Main::getName; //won't work, null reference var nullValue = null; //won't work, array initializer var stringArray = {1, 2}; @MichelSchudel
  • 16.
  • 17. Local variable syntax for Lamba parameters //java 10 (int x, int y) -> x + y; //java 11 (var x, var y) -> x + y; (x, y) -> x + y; (@NotNull var x, @Nullable var y) -> x + y; (var x, var y) -> x + y; @MichelSchudel
  • 18. Http Client HttpClient client = HttpClient.newBuilder() .version(HttpClient.Version.HTTP_1_1) .followRedirects(HttpClient.Redirect.NORMAL) .connectTimeout(Duration.ofSeconds(20)) .build(); HttpRequest httpRequest = HttpRequest .newBuilder() .header("myHeader", "myValue") .uri(URI.create("http://localhost:4567/hello")) .build(); HttpResponse<String> response = client .send(httpRequest, HttpResponse.BodyHandlers.ofString()); @MichelSchudel
  • 19. Some nice API additions " ".isBlank()  true  JBCNConfJBCNConf Arrays.stream(someText.split("r")).forEach(System.out::println); Optional<String> optional = getStringValue(); If (optional.isEmpty() {..} someText.lines().forEach(System.out::println); new String(new char[2]) .replace("0", “JBCNConf")); “JBCNConf".repeat(2) @MichelSchudel
  • 20.
  • 21.
  • 23. You have to pay Oracle a periodic subscription fee if • You use the OracleJDK commercially • You‘re on java 9+ or want to use Java 8u211 or higher Using the OracleJDK non-commercially is free (at least until september 2020) $2.5(USD) per month per user $25(USD) per month per server https://docs.google.com/document/d/1nFGazvrCvHMZJgFstlbz oHjpAVwv5DEdnaBr_5pKuHo/preview#heading=h.p3qt2oh5ec zi @MichelSchudel
  • 24.
  • 25. • Not free for commercial use since april 16th, 2019 • JDK8u211 • Older versions ARE free for commercial use • AdoptOpenJDK (https://adoptopenjdk.net/) • Amazon Corretto (https://aws.amazon.com/corretto/) • Jclarity OpenJDK (https://www.jclarity.com/index.php) If you want the latest security patches • Get a subscription, or grab and openjdk build:
  • 26. • OracleJDK not free for commercial use • OpenJDK is free under GPLv2+CE license • Only two quarterly updates, however • AdoptOpenJDK (https://adoptopenjdk.net/) • Amazon Corretto (https://aws.amazon.com/corretto/) • Jclarity OpenJDK (https://www.jclarity.com/index.php) • Get a subscription for the OracleJDK • Get the Oracle OpenJDK (https://jdk.java.net/) • For the latest security patches, grab an OpenJDK build:
  • 27.
  • 29.
  • 30. • JEP 325: Switch expressions • Some small api changes • JEP 326: Raw string literals • JEP 189: Shenandoah GC • JEP 341: Default CDS archives • JEP 334: Constants API • JEP 344: Abortable G1 @MichelSchudel
  • 31. Switch expressions are experimental To try out switch expressions, use --enable-preview parameterwhen starting JVM https://github.com/MichelSchudel/java12demo @MichelSchudel
  • 32. • Ultra low-pause garbage collector java -XX:+UseShenandoahGC
  • 33.
  • 34.
  • 36.
  • 37. /** * The singleton instance for the 'Reiwa' era (2019-05-01 - ) * which has the value 3. The end date of this era is not specified, unless * the Japanese Government defines it. * * @since 13 */ public static final JapaneseEra REIWA = new JapaneseEra(3, LocalDate.of(2019, 5, 1)); @MichelSchudel
  • 38.
  • 39.
  • 40. Value Types (JEP-169) class Tuple { int val1; int val2; } Object header val1 val2 Object header val1 val2 Object header val1 val2 value class Tuple { int value1; int value2; } val1, val2 val1, val2 val1, val2 @MichelSchudel
  • 41. Cl Value Types (JEP-169) • No object identity (does NOT extend Object) • Instances are equal based on their data • Immutable (just like primitives) “Codes like a class, works like an int” – Brian Goetz …but what about generics? @MichelSchudel
  • 42. With introducing value types, restriction on Object when using generics becomes more cumbersome List<int> integers; List<Tuple> tuples; Generic specialization (JEP-218) @MichelSchudel
  • 44. Current threading model Thread Task Scheduler Instructions Switch thread OS OS
  • 45. Current threading model • Thread call stack includes native stack (big footprint) • No way to guarantee that two related threads run on the same cpu (core) @MichelSchudel
  • 46. Solution Core Core Core Core Fibers Threads Java Fiber Scheduler OS Thread Scheduler (fe ForkJoinPool) @MichelSchudel
  • 47. Delivered • Local-variable type inference (JEP-286), JDK10 • Local-variable syntax for lambda parameters (JEP-323), JDK11 Preview • Switch expressions (JEP-325) (JDK12) In development • Raw string literals (JEP-326) Text blocks (JEP-355) • Pattern matching (JEP-310) On hold • Enhanced enums (JEP-301) @MichelSchudel
  • 48. Text blocks (JEP-355) String html = "<html>n" + " <body>n" + " <p>Hello, "world"</p>n" + " </body>n“ + "</html>n"; String html = """ <html> <body> <p>Hello, "world"</p> </body> </html> """; .............. .............. .............. .............. .............. .............. @MichelSchudel
  • 49. Pattern matching (JEP-355) Object obj =… if (obj instanceof String) { String s = (String)obj; System.out.println(s.toUpperCase()); } else if (obj instanceof Integer) { Integer i = (Integer)obj; System.out.println(i.doubleValue()); } Object obj =… if (obj instanceof String s) { System.out.println(s.toUpperCase()); } else if (obj instanceof Integer i) { System.out.println(i.doubleValue()); } @MichelSchudel
  • 50. Pattern matching (JEP-355) String formatted = switch (obj) { 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 -> String.format("Object %s", obj); }; @MichelSchudel
  • 51. interface Expression{ int evaluate(); } class SimpleExpression implements Expression { int value; int evaluate() { return value; } } class ComplexExpression implements Expression { Expression left, right; int evaluate() { return left.evaluate() + right.evaluate(); } } Pattern matching (JEP-355) @MichelSchudel
  • 52. interface ExpressionVisitor<T> { T visit(SimpleExpression expression); T visit(ComplexExpression expression); } Pattern matching (JEP-355) class MyVisitor implements ExpressionVisitor<Integer> { Integer visit(SimpleExpression expr) { return expr.value; } Integer visit(ComplexExpression expr) { return expr.left.accept(this) + expr.right.accept(this); } } @MichelSchudel
  • 53. int evaluate(Expression expr) { return switch(expr) { case SimpleExpression(int value) -> value; case ComplexExpression(Expression left, Expression right) -> evaluate(left) + evaluate(right); }; } Pattern matching (JEP-355) Deconstruction patterns class SimpleExpression { value } class ComplexExpression { left, right } value value @MichelSchudel
  • 55. • Java 9, 10, 11 recap • Java 12 overview • Java 13 preview • The Java future • Panama • Valhalla • Loom • Amber
  • 56. Uncovering project Amber Mala Gupta Java Futures Brian Goetz OpenJDK, the Future of Java Mario Torre How to participate in the future of Java Heather VanCura
  • 58. Demo slides (in case you didn’t see the demo about what’s new in java 12
  • 59. Traditional switch statement public String getConference(Conference conference) { switch (conference) { case JBCNCONF: return "JBCNConf"; case DEVOXX: return "Devoxx"; case DEVOXX_UK: return "Devoxx UK"; default: throw new RuntimeException("unknown type!"); } } A traditional switch statement. Notice that the default must be specified, Even although the enum’s values are exhausted
  • 60. Switch expression public String getConferenceExpression(Conference conference) { String s = switch (conference) { case JBCNCONF: break "JBCNConf"; case DEVOXX: break "Devoxx"; case DEVOXX_UK: break "DevoxxUK"; }; return s; } A switch expression. The break returns the value. Since it’s an expression, You dont need a default statement since all enum values are convered.
  • 61. Switch expression, lamba style public String getConferenceLambdas(Conference conference) { String s = switch (conference) { case JBCNCONF -> "JBCNConf"; case DEVOXX -> "Devoxx"; case DEVOXX_UK -> "DevoxxUK"; }; return s; } Switch expressions can be elegantly written lamba style.
  • 62. Multilabel switch expressions public String getConferenceMultiLabel(Conference conference) { String s = switch (conference) { case JBCNCONF -> "JBCNConf"; case DEVOXX, DEVOXX_UK -> "Devoxx"; }; return s; } You can state multiple labels for one branch, without the nasty fallthrough cases without breaks.
  • 63. public String getConferenceMultiStatement(Conference conference) { String s = switch (conference) { case JBCNCONF -> { System.out.println("conference = [" + conference + "]"); break "JBCNConf"; } case DEVOXX, DEVOXX_UK -> "Devoxx"; }; return s; } Switch expression, multiline Multiple expressions are delimited by {}. In this case, you MUST use a break.
  • 64. Switch expression, supertype public Object getConferenceTypeResolving(Conference conference) { Object s = switch (conference) { case JBCNCONF -> { System.out.println("conference = [" + conference + "]"); break "JBCNConf"; } case DEVOXX, DEVOXX_UK -> "Devoxx"; default -> new RuntimeException(); }; return s; } When multiple branches return multiple types, the type of the switch expression is the closest common supertype.
  • 65. Teeing collector The teeing collector takes two Collectors, and passes both Collector results to a function. public void teeingDemo() { double average = Stream.of(1, 4, 2, 7, 4, 12) .collect(Collectors.teeing( Collectors.summingDouble(i -> i), Collectors.counting(), (sum, n) -> sum / n)); System.out.println(average); }
  • 66. String transform method The new transform method takes a function to transform a string. The output can be any type. public void transformDemo() { String conference = "2019"; Integer i = conference.transform(Integer::parseInt); System.out.println(i); }

Editor's Notes

  1. Hi there! Thank you for coming to this session. My name is Michel Schudel, I’m a Java developer for a software company in the Netherlands called Craftsmen. I’ve been a Java developer since 1998, that’s oh, 21 year already. I’ve always been interested in the evolvement of the Java ecosystem, and of course, since now we get a new Java version every six months, there’s walys something new on the horizon, and I get to give talk every six months! ! So today, I want to share with you what’s new in Java 12, and look to what’s beyond java 12!
  2. So today we’re going to talk about the following: first, we’ll do a quick recap of java 9,10 and 11. What were the main features of those releases? Secondly, the present, java 12. What are the highlights of java12? And for the third part of this presentation, we’ll look ahead to future releases, and see what’s in store in the near future. It’s a high overview, nothing too much in depth. There are more talks on this conference that go more in-depth about the various parts mentioned in this talk, and I’m going to mention those at the end of this session.
  3. But before we go on, I’m really curius about the adoption of Java 11 and beyond. The most recent report based on any significant data was this report from Snyk from october 2018, they’re working one a new one, please go fill in tht one, and as you can see it doens’t show any usage about java 11, or even java 12. So a show of hands, who’s already on java 11 in production? Who is working on getting to java 11 in production?there' dd Ok, so that’s about 20% of you. Interesting to know that at least a lot of you are already working on going to java 11. So, for those of you that aren’t on Java 11, or are not quite sure what has been added to the language, let’s do a recap of what came before, since java 8, ok?
  4. So I will call this part of the presentation, “previously in Java land….” (schrappen?)
  5. So, back to Java 9. Released in september 2017, The first release in the new six months release cycle. And it was, understandably, quite a big release, since there are 3,5 years between this release and java 8.
  6. So what was the biggest change in Java 9? Yeah, that’s right, the module syste, also Known as project Jigaw.
  7. So one of the problems that the module system tried to solve, is the encapsulation gab at the Jar level. Remember, there was no way to actually tell java which *packages* were considered public, only which classes. The module system solves that. Secondly, it became possible to encapsulate the Java APIs themselves. That meant that classes that were never meant for public use became inaccessible. So, for people that us Spring Boot, for example, you’ve seen this IllegalAccess warning on startup quite a few times, right? Well, at least warning was emitted in Java 9. Thirdly, because all modules are known at compile time, you can use the JLINK tool to build custom java images. These images are quite a lot smaller than distributing the whole JVM.
  8. So, I’m curious again. This is a result of a poll that was released before Java 9 came out. The module system was by far the greatest thing people looked forward to. So, show of hands, how many of you are using the module system in production? (eloborate) I don’t extactly know why it hasn’t caught up yet, maybe we’re still waiting on full libraty compatibilty. Interesting that jshell isn’t on here.
  9. So, on to java 10!
  10. So, biggest change in Java 10? I’ll give you a hint: it’s in the language.
  11. So here are a couple of typical declrations. So now, instead of this, you can do *this* (show vars example). It relieves some clutter. It only works on local variables, so no fields, parameters or whatever
  12. Of course it doesn’t work on every st
  13. Now, this is a poll that was done in 2016! 75% of the asked pollers thought it was a great idea, basically, only 10% explicitly aid it was a bad idea. Show of hands, how many of you like local type variable interference? Why not?
  14. Now, on to java 11. Well, languages wise, nothin much changed although a few interesting api additions were present. So let’s look at those, then.
  15. So now we have some local variable syntx
  16. And of course, we go a nice http client, which now has a fluent api. It was already there since java 8 or 9, but it’s left experimental mode and become official.
  17. S
  18. But the biggest change is that Java 11 is an LTS release! Well, it bascially means that this java version will by supported by Oracle for a long time. Oracle public updates basically end when a non-LTS release comes out, effectively ending the support for the last release. So in any kind of serous production environment in my opinion, it makes sense to skip the non-LTS releases and go from 8 to 11 to, yes, 17.
  19. So, now we come to the question: is Java still free? You’ve probably heard this new commercial license for the OracleJDK, right? So basically…
  20. It depends, ok? There’s a live document on google docs which goes into much detail about how what is still free and what is not, butI’ll try to give you the management summary here.
  21. But you probably dont want that. So, if you still want to run Java in production free of charge, you have the following options:
  22. So on to the present! Let’s look at the current release, java 12!
  23. So, that brings us to Java 12! Note, this is not an LTS release so that means you will get two quaterly updates before Oracle transitions everyone to the next version.
  24. So, you’re probably know what I’m pointing at here, right? That’s right, switch expressions!
  25. So that’s the first one, we’ll look at that in a moment. Now, string literals were originally targeted for java 12 as an expiremental feature, but this has been withdrawn. But we’re going to take a look at it in a moment. For the rest, we have these features: Shenandoah is the low pause time garbage collector that reduces GC pause times by performing more garbage collection work concurrently with the running Java program. Shenandoah does the bulk of GC work concurrently, including the concurrent compaction, which means its pause times are no longer directly proportional to the size of the heap. Garbage collecting a 200 GB heap or a 2 GB heap should have the similar low pause behavior. Enhance the JDK build process to generate a class data-sharing (CDS) archive, using the default class list, on 64-bit platforms. Constants API is describing the nominal form of types whose values can be stored in a constant pool. Abortable G1 means the G1 garbage collector has two parts, a mandatory part and an optinal part. If there is still time for the optional part, the G1 GC will execute this optional part if there is time left. After completing collection of any part of the optional collection set, G1 can decide to stop the collection depending on the remaining time.
  26. So ,now I’m going to give a switch expression demo. Note: this is experimental. To enable it, add –enable-preview as a startup parameter.
  27. So, now we’ve seen what Java 12 entails. Now, on to the future! What does Java have in store for us?
  28. So the first release of Java will be Java 13. It’s slated to be released on 17th of september this year. Let’s take a look at the early-access builds and see what they came up with. It must have a bunch of new goodies in store for us developers. Or has it?
  29. Well, so far nothing very exicting, although probably important. The socket API is getting a refactor overhaul, and it will probably be more efficient performancewise. There’s an extension of application class-data sharing to improve startup time and memory usage. Futhermore, the Z garbage collector will return unused memory to the operating system. So I decided to download an early access build myself and swift through the API to see what’s new. Nothing particulary interesting so far, but I did encounter this these two
  30. So does anyone know who the guy on the right is? That’s right, that’s the Japanese emperor Akihito and who’s the guy on the left? That’s right, that’s his son, crown prince Naruhito, who will be the new emperor of Japan. So what does this have to do with Java, anyone? (Not you, Brian!) Will, Akihito is probably the only person in the world who is singlehandedly responsible for a change in the Java API. You see, when a new Japanese emperor is sworn in for duty, a new Japanese Era begins. The new one is called Reiwa, signyfying order and harmony. So it’s basically a new calendar. Now, Java wouldn’t be much good if it didn’t support it, right?
  31. So there you have it: change 8174268: Declare a public field for the new Era, starting the 1st of may 2019! Now, it’s backported to most previous java versions as well. I thought this was a curious change and I wanted to share that with you.
  32. Oh, and another one that’s pretty important: apparently, there’s a lot of swearing in the JDK source, so they fixed that… there was even some discussion about what actually constitued a swear word, and there are some f-bombs in jszip.js, which is a javascript library for mananing ZIP files… oh well, I’d be swearing too if I had to do that in javascript.
  33. So, if we want to look at what JAVA HAS IN STORE FOR US, we have to look a little further ahead. Fortunately, the most exicting stuff is bundled into four umbrella projects. These projects bundle a lot of JEPs or Java Enhancement Proposals. So let’s go through them and examine them in more detail. Project panama is about improving connectivity between the JVM and native code. We’re not going into that today. Project Valhalla introduces value types and generic specialization. Project Loom is a project to implement easy-to-use, light-weight concurrency to the JVM. Yes, apparentely that’s a “loom”, some kind of knitting machine with a lot of threads, so it’s clear where the project name comes from, I guess. And Project Amber concist of multiple, small, improvements to the JDK and the java language.
  34. So lets’look at project Valhalla first. Consider an object Tuple. It has two values. It’s bascially a data carrier, but it still has the overhead of a normal object like an object header, object identitiy etc. So,if you store these object in an araay, for example, you still hava quite a lot of overhead. You store the references in the array, and they point to an adress on the heap. So store basically some ints, you have quite a lot of overhead. So the proposal of project Valhalla is to introduce something called a value class. It has no object identifity and can basically be squashed like this. It can even be put on the stack. Now, if you want to have a value object, you need to sacrifice some stuff.
  35. So, this is an analogy I shamelessly copied from Brian Goetz This means a value object has no object identity, instances are equal based on their data, and object is immutable (what about inheritance?) Now, the problem is, how to fit this into Generics? Everything generic assumes an extension of Object right now.
  36. So the generic specialization JEP is aiming to make this possible: use primitives or value objects possible.
  37. Now over to loom,. You currently have this threading mode.
  38. Normally you would offer tasks to an scheduler like an executor service
  39. So, Loom tries to fix these problems, briging the concurrency model closer the the JVM.
  40. NEEDS ELABORATION Now, loom introduces Fibers, an abstraction over Threads that are managed in the JVM. It’s easy to see that since the JVM can figure out, or maybe can be hinted at, what fibers belong together, it can execute them on the same thread. Simialry, the callstack footprint will be reduced.
  41. On to project amber, which is the last i’m going to cover here. Now, project Amber actually has delivered some stuff already. So lvti and lvsflp have been devilvered in java 10 and 11, respecvitely? A preview of switch expressions is in java
  42. So, on to tekst blocks. Ok, how many of you had to program something like this in the past? Now, the idea is, still draft, to add text blocks to the Java language. So instead of doing something like this, you could end up doing something like.. This (click)`. Now, the begin and end blocks are delimited with three double quotes, so you can use double quotes like normal. Futhermore, line feeds are canonicalized to a line feed character, thats hexadecimal \0A for you. If you wonder how this is indentited, like this: it starts with the leftmost quote of the begin block. There are some details here but I won’t go into that right now since this is still a draft and under review.
  43. So, on to pattern matching.
  44. Remeber these switch expressions? We could take this one step further. We could apply this to switch expressions as well.
  45. Now, we can take this one step further. You have an interrface called “expression”, with two implementations: 1 simple one with one field, and another, complex expression, that consists of two expressions and adds their evualalte result together.
  46. Now, if you would want to separate the data from the logic, you would use a visitor pattern, for example writing a class MyVistor that would traverse all expressions.
  47. So now, suppose we had the value types from project Valhalla.