SlideShare a Scribd company logo
1 of 115
Download to read offline
1
2
Rémi ForaxRémi Forax
StarringStarring
José PaumardJosé Paumard
3
Don’t believe a word
of what we are saying!
Don’t believe a word
of what we are saying!
4
Java Champion
OpenJDK amber & valhalla
ex: jigsaw, lambda, invokedynamic
Rémi in a few wordsRémi in a few words
5
José in a few more wordsJosé in a few more words
@JosePaumard
https://github.com/JosePaumard/
https://josepaumard.github.io/
https://www.youtube.com/user/JosePaumard
6
Questions?
#J11FT
7
Public Poll!
You can get Kahoot! to participate in the poll, just before
the coffee break
8
Introduction: What is Java up to?
What is going on behind the curtain?
How is Java organized: the release train etc…
What is underway for the language and the VM?
9
How is Java organized?
10
OpenJDK Enhancement Proposal
JEP 1: Roadmap Process
JEP 11: Incubator Modules (Java 9)
JEP 12: Preview Language and VM feature (Java 11)
JEP 248: Make G1 the default GC (Java 9)
JEP 286: Local-Variable Type Inference (Java 10)
JEP 291: Deprecate CMS (Java 9)
JEP 326: Raw String Literals (Java 11)
...
12
jdk
Amber
var condy expr switch record
Valhalla
nest mate
value type
preview
jdk 9
release
jdk 10
release
jdk 12
jdk 11
release
13
Time-Based Release Versioning
A release every 6 months
March 2014: Java 8 LTS
Sept 2017: Java 9
March 2018: Java 10
Sept 2018: Java 11 LTS
March 2019: Java 12
Sept 2019: Java 13
...
March 2021: Java 16
Sept 2021: Java 17 LTS
–
14
Java Community Process
JSR 365: Contexts and Dependency Injection 2.0
JSR 376: Java Platform Module System (several JEPs)
Umbrella JSR 383: Java SE 10
Umbrella JSR 384: Java SE 11
Time based release → Inversion of Control!
15
How is it Distributed?
Java SE are distributions that pass the TCK
AdoptOpenJDK
Azul Zulu / Azul Zing
+ C4 (GC) + Falcon (JIT)
IBM J9
OpenJ9 (VM + JIT + GCs)
OpenJDK
Oracle
+ Mission Control, + Flight Recorder (open sourced!)
RedHat
+ Shenandoah (GC)
17
Java 10
18
Local Variable Type Inference
19
Demo!
20
Local Variable Type Inference
Let the compiler infers the type of local variables
var list = List.of("hello", "devoxx");
var max = list.stream().max(String::compareTo);
max.ifPresent(System.out::println);
Fields and methods can not use var
class Foo {
var foo; // fails
int foo(var a); // fails
}
21
Var & Inference
Works with for(:) and try(=)
for (var element: list) {
...
}
try (var lines = Files.lines(path)) {
...
}
Works beautifully with anonymous classes
var counter = new Object() {
int value;
};
list.forEach(e -> counter.value++);
22
Var & Inference (2)
Inference fails for
var a; // fails
var a = null; // fails
var lambda = x -> x; // fails
var methodref = Integer::sum; // fails
var array = { 1, 2, 3 }; // fails
Work surprisingly if return type is needed
var empty = List.of(); // List<Object>
23
When to use var?
Guidelines
Choose variable names that provide useful information.
Consider var when the initializer provides sufficient
information to the reader.
Don't worry too much about "programming to the interface"
with local variables.
http://openjdk.java.net/projects/amber/LVTIstyle.html
24
var local type var inference
10
25
Evil Plan
26
Java 11
Var as Lambda Parameters
Nestmates
Condy
Raw string
27
Var as Lambda Parameters
28
var as Type in Lambda Parameters
Lambda parameters can use var
IntBinaryOperator fun = (var x, var y) -> x + y;
Allow modifiers and annotations
IntBinaryOperator fun =
(final var x, final var y) -> x + y;
BinaryOperator<Integer> fun =
(@NonNull var x, @NonNull var y) -> x + y;
30
NestMates
31
Can You Spot the Problem?
The compiler does stupid things behind your back
interface Foo {
public int value();
private static int helperValue() { return 42; }
public static Foo create() {
return new Foo() {
public int value() { return helperValue(); }
};
}
}
32
The Accessor is Public!
The inner class needs to access Foo.helperValue()
public interface Foo {
public abstract int value();
private static int helperValue();
Code:
0: bipush 42
2: ireturn
public static int access$000();
Code:
0: invokestatic InterfaceMethod helperValue:()I
3: ireturn
}
33
Can You Spot The Problem (2)?
And what about using reflection?
public class Foo {
private int value;
public class Bar {
public int getValue() {
return Foo.class.getDeclaredField("value")
.getInt();
}
}
}
34
35
NestMates
Sync the JVMS and the JLS view on private
Creates two new class attributes
NestMembers (in enclosing class)
List all internal classes
NestHost (in internal classes)
Name the enclosing class
 private access check by the VM
Is it the same class ?
Is the class listed as a nest members of the nest host ?
36
Class Loading Order?
May the VM load more classes than before?
class Foo {
private static int value;
static class Bar {
int m() { return value; }
int m2() { return 42; }
}
}
No, the access resolution is lazy
but IllegalAccessError may appear later
37
Constant Dynamic
38
Constant Dynamic
The VM only allow primitives, String, etc. as constant pool constants
 add arbitrary constant in the constant pool
Constant pool constant (use ldc to load)
CONSTANT_InvokeDynamic_info {
u1 tag;
u2 bootstrap_method_attr_index;
u2 name_and_type_index;
}
Bootstrap method (called once)
Object bsm(Lookup lookup, String name, Class<?> type, ...) {
...
}
39
Example in Java (maybe)
Alleviate the burden of the static block if the initialization
is idempotent
class Foo {
private static final lazy boolean DEBUG =
Boolean.valueOf(System.getenv("DEBUG"));
void bar() {
if (DEBUG) { ... }
}
}
40
Example in Java (maybe)
No static block needed, lazy initiailization done by the VM
class Foo {
10: condy constantMetaFactory.bsm $init_DEBUG$
private static boolean $init_DEBUG$() {
return Boolean.valueOf(System.getenv("DEBUG"));
}
void bar() {
ldc 10
ifeq ...
}
}
41
Constant Lambda
All Lambdas are initialized with indy
class Foo {
IntSupplier provider() {
return () -> 42;
}
}
class Foo {
10: indy LambdaMetaFactory.lambda
$lambda$ IntSupplier()
IntSupplier provider() {
indy 10
}
private static int $lambda$() {
return 42;
}
}
42
Constant Lambda with condy
Constant Lambdas should be initialized with condy
class Foo {
IntSupplier provider() {
return () -> 42;
}
}
class Foo {
10: condy lambdaMetaFactory.condy
$lambda$ IntSupplier
IntSupplier provider() {
ldc 10
}
private static int $lambda$() {
return 42;
}
}
43
Constant Dynamic vs Invokedynamic
Differences between condy and indy
Constant Dynamic InvokeDynamic
can represent only constant any expression
creation lazy created (ldc) lazy created (invokedynamic)
interpreter constant non-constant
c1 constant non-constant
c2 constant constant
graal constant constant
44
Lambda Creation
Java 8
All lambdas creation use invokedynamic
Constant lambdas are constant at JIT time
Java 11
Introduction of constant dynamic in the VM
Java 12?
Constant lambdas use constant dynamic
Need re-compilation :(
Constant lambdas are constant at interpreter time
45
Constant Dynamic and Annotation
Annotation values are constants in the constant pool
Condy allows to define any constants !
Proposal: allow any class instance
as an annotation value
Problem: any use cases?
46
Raw String
47
DEMO!
48
Java String Issues
No way to create a non-despecialized string
var pattern = Pattern.compile("");
Not easy to create a multi-lines string
var s = "this is a longn" +
"multi-linesn" +
"of text";
Not easy to embed code
var s = "<a href="javascript: alert(‘hello’)">";
49
Raw String
Add non-despecialized string and multi-lines string
Starts by n-backticks (`) and ends by n-backticks
var pattern = Pattern.compile(``);
var s = `this is a long
multi-lines
of text`;
var s = ```<a href="javascript: alert(‘hello’)">```;
50
Raw String API
strip(): same as trim(), works with UTF-8 spaces!
stripIndent(): removes indenting spaces
stripLeading(), stripTrailing(): removes
leading and trailing spaces
stripMarkers(): removes what is outside the
markers
lines(): streams the lines of the multiline
51
WARNING!
Because you can embed Java code in raw String
var text =
``
var s = `this is a long
multi-lines
of text`;
``;
it means that `` is not the empty String but the start of
a raw String
52
var local type var inference
10
11 var as lambda parameters raw string nestmatescondy
inner classes
private in VM
53
Even More Evil Plan
For World Domination!
54
Java 12+
Switch
Record
55
56
Limitation of Switch
Switch doesn’t work well when the result is an expression
Car car;
switch(text) {
case "upgrade":
case "awesome":
car = new Mustang();
break;
case "regular":
car = new Clio();
break;
default:
throw new WTFException();
}
57
Switch Expression
Use break expression to specify the result of a case
var car = switch(text) {
case "upgrade":
case "awesome":
break new Mustang();
case "regular":
System.out.println("I am a Clio!");
break new Clio();
default:
throw new WTFException();
};
58
Others Limitations
Try to get rid of fall-through
It makes the code unreadable, easy to introduce regression
when refactoring
Try have a story for null
better than throw NPE
Nice to have: a shorter syntax for single expression?
59
Avoid Fall-through
Allow comma separated cases
var car = switch(text) {
case "upgrade", "awesome":
break new Mustang();
case "regular":
System.out.println("I am a Clio!");
break new Clio();
default:
throw new WTFException();
};
60
Allow case null
NPE unless there is a case null
var car = switch(text) {
case "upgrade", "awesome":
break new Mustang();
case "regular":
System.out.println("I am a Clio!");
break new Clio();
case null, default:
throw new WTFException();
};
Allow to mix case: and default:?
61
Retrofit the Statement Switch
Comma separated cases and case null are also
available on the statement switch
Car car;
switch(text) {
case "upgrade", "awesome":
car = new Mustang();
break;
case "regular":
car = new Clio();
break;
case null, default:
throw new WTFException();
}
62
Single Expression Syntax
Use -> instead of : break
var car = switch(text) {
case "upgrade", "awesome" -> new Mustang();
case "regular":
System.out.println("I am a Clio!");
break new Clio();
case null, default -> throw new WTFException();
};
“->” also work for throw?
63
Problem of -> as shorter syntax
-> used here is not the same as the -> used in lambdas
and the syntax -> { } does not work with case:
Alternative syntax
var car = switch(text) {
case "upgrade", "awesome": new Mustang();
case "regular": new Clio();
case null, default: throw new WTFException();
};
64
I suggest you do this poll at Devoxx. Make sure
to wear flame-proof pants!
Brian Goetz
65
Poll!
1. no shorter syntax, break expr is short enough
2. “->” as shorter syntax
case "regular" -> new Clio();
case "regular": break new Clio();
66
Poll!
1. no shorter syntax, break expr is short enough
2. “->” as shorter syntax
3. “:” as shorter syntax
case "regular" -> new Clio();
case "regular": break new Clio();
case "regular": new Clio();
67
Coffee (or whatever)
Break!
Coffee (or whatever)
Break!
68
Java 12+
Switch
Record
69
Bytecode Translation for Switch
70
Current Translation Strategy of Switch on String
in pseudo bytecode
aload 0
invokevirtual String.hashCode ()I
lookupswitch
label -231171556 // "upgrade".hashCode()
test.equals("upgrade")? 0: -1
label 1086463900 // "regular".hashCode()
test.equals("regular")? 1: -1
tableswitch
label 0
… // new Mustang
label 1
… // new Clio
istore 1
var car = switch(text) {
case "upgrade": new Mustang();
case "regular": new Clio();
};
71
Current Translation Strategy of Switch
What if the compiler world and the VM world are not
aligned anymore?
For String:
The solution could be to specify that String.hashCode() can
not be changed
For Enum:
It should state that you can only add enum values at the end
of the list
72
New Translation to Bytecode
invokedynamic is used to associate an int to each case
in pseudo-bytecode
invokedynamic (String)I SwitchMetaFactory.string
["upgrade", "awesome", "regular"], [0, 0, 1]
tableswitch
label 0:
… // new Mustang
label 1:
… // new Clio
astore 1
var car = switch(text) {
case "upgrade": new Mustang();
case "regular": new Clio();
};
73
Performance??
Test avec JMH
old switch new switch cascade
if equals
small
(4 cases)
23.9 +/- 0.2 ns/op 11.6 +/- 0.1 ns/op 16.4 +/- 0.1 ns/op
big
(10 cases)
135.4 +/- 4.0 ns/op 86.2 +/- 1.5 ns/op 25.1 +/- 0.4 ns/op
74
New Translation to Bytecode
Switch on enums, String, double, float, long use indy
The bytecode becomes independent from the compiler world
Usually better performance
Less bytecodes
Dynamic strategies adaptation
But it needs to recompile the old code...
And it puts more pressure on the JIT
It may take longer to reach steady state
75
Extending Switch to Accept Types
(Toward Pattern Matching)
76
Extending Switch to Accept Types
Computing something on a hierarchy you do not control
int computeTax(Vehicle v) {
if (v instanceof Bike) {
return 10;
} else if (v instanceof Car) {
return 42 + ((Car) v).passengers() * 10;
} else if (v instanceof Bus) {
return ((Bus) v).weight() * ((Bus) v).wheels();
} else {
throw new WTFException("unknown vehicle kind");
}
}
77
Extending Switch to Accept Types
One can use a Visitor (if there is a method accept)
int computeTax(Vehicle v) {
return v.accept(VISITOR);
}
private static final Visitor VISITOR = new Visitor() {
public int visitBike(Bike bike) { return 10; }
public int visitCar(Car car) {
return 42 + car.passengers() * 10;
}
public int visitBus(Bus bus) {
return bus.weight() * bus.wheels();
}
};
78
Extending Switch to Accept Types
Computing something on a hierarchy you do not control
int computeTax(Vehicle v) {
return switch(v) {
case Bike: 10;
case Car: 42 + ((Car) v).passengers() * 10;
case Bus: ((Bus) v).weight() * ((Bus) v.wheels();
default: throw new WTFException("unknown ...");
};
}
79
Translation to Bytecode
Same Translation as with Strings
aload 0
invokedynamic (Vehicle)I SwitchMetaFactory.types
[Bike.class, Car.class, Bus.class], [0, 1, 2]
tableswitch
label 0:
bipush 10
label 1:
bipush 42
aload 0
checkcast Car
invokevirtual Car passagers ()I
iadd
label 2:
… // ((Bus) v).weight() * ((Bus) v).wheels()
ireturn
80
Performance??
Test with JMH
instanceof type switch
lot of cases
lot of classes
395 +/- 21.2 ns/op 55 +/- 2.1 ns/op
small n cases
lot of classes
35 +/- 1.6 ns/op 51 +/- 0.7 ns/op
small n cases
small n classes
7 +/- 0.1 ns/op 6 +/- 0.1 ns/op
81
Extending Switch to Accept Types
Naming the type avoid the cast
int computeTax(Vehicle v) {
return switch(v) {
case Bike: 10;
case Car car: 42 + car.passengers() * 10;
case Bus bus: bus.weight() * bus.wheels();
default: throw new WTFException("unknown ...");
};
}
82
Bringing Back the Encapsulation
Allows destructured switch on type
int computeTax(Vehicle v) {
return switch(v) {
case Bike: 10;
case Car(int passengers): 42 + passengers * 10;
case Bus(int weight, int wheels): weight * wheels;
...
};
}
We need the inverse operation of a constructor
83
De-constructor
A de-constructor describes how to get a tuple of values
from an object
class Bus {
Bus(int weight, int wheels) { … }
(int, int) deconstructor() { return …; }
}
But returning several values in not easy in Java (yet!)
84
A Path to a Solution
The problem can be solved for classes with a primary
constructor
record Bus(int weight, int wheels) {
int weight; // compiler generated
int wheels; // compiler generated
public static Extractor extractor() { // compiler generated
return Extractor.of(bus -> bus.weight, bus -> bus.wheels);
}
}
The Extractor is then a list of getters
85
Switch on Records
record Bike implements Vehicle
record Car(int passengers) implements Vehicle
record Bus(int weight, int wheels)
A record provides an extractor that returns its component values
int computeTax(Vehicle v) {
return switch(v) {
case Bike: 10;
case Car(var passengers): 42 + passengers * 10;
case Bus(var weight, var wheels): weight * bus.wheels;
default: throw new WTFException("unknown vehicle kind");
};
}
86
Switch on Records - Translation
The getter from the extractor are defined as Constant Dynamic
0: ConstantDynamic MethodHandle SwitchMetafactory.getter [Car.class, 0];
1: ConstantDynamic MethodHandle SwitchMetafactory.getter [Bus.class, 0];
2: ConstantDynamic MethodHandle SwitchMetafactory.getter [Bus.class, 1];
int computeTax(Vehicle v) {
aload 0
invokedynamic (Vehicle)I SwitchMetaFactory.types
[Bike.class, Car.class, Bus.class] [0, 1, 2]
tableswitch
label 0:
bipush 10
label 1:
bipush 42
aload 0
invokedynamic (Vehicle)I SwitchMetafactory.extract [item 0]
iadd
label 2:
…
ireturn 1
87
Record
88
Record
A plain simple data object
record Point(final int x, final int y)
is translated to
public final class Point {
final int x;
final int y;
public Point(int x, int y) { this.x = x; this.y = y; }
public int x() { return x; }
public int y() { return y; }
// + equals / hashCode / toString / extractor
}
89
Record
Record can have supplementary methods but no
supplementary fields
record Point(final int x, final int y)
record Circle(final Point center, final int radius) {
public double surface() {
return Math.PI * radius * radius;
}
}
90
Record and Precondition
Relax java rule: you can have preconditions before the calls
to the super / default constructor
record Circle(final Point center, final int radius) {
public Circle(Point center, int radius) {
Preconditions.requiresNonNull(center);
Preconditions.requiresPositive(radius);
default(center, radius);
}
}
java.util.Preconditions contains usual precondition tests
91
Setters are not Generated!
Because the compiler doesn’t know about preconditions
record Circle(final Point center, final int radius) {
public Circle(Point center, int radius) {
requiresNonNull(center);
requiresPositive(radius);
default(center, radius);
}
public void center(Point center) {
this.center = requiresNonNull(center);
}
public void radius(int radius) {
this.radius = requiresPositive(radius);
}
}
92
Translating Records to Bytecode
93
equals / hashCode / toString / extractor
The code is not generated by the compiler
Use invokedynamic + constant dynamic
/*record*/ final class Bus {
10: constant dynamic Extractor RecordMetafactory.extractor
[Bus::weight, Bus::wheels]
final int weight;
final int wheels;
public String toString() {
return invokedynamic RecordMetafactory.toString
[constant item 10]
}
}
94
Indy + Condy
The Extractor is computed once lazily
equals(), balance the cascade of if … else depending on
the cost of equals() for each components
can re-balance the cascade if..else at runtime!
equals and hashCode can do nullcheck implicitly
95
Extractor
Use ldc + constant dynamic
/*record*/ final class Bus {
10: constant dynamic Extractor RecordMetafactory.extractor
[Bus::weight, Bus::wheels]
final int weight;
final int wheels;
public static /*extractor*/ Extractor extractor() {
ldc [constant item 10]
areturn
}
}
96
Record vs Property
Is Record + Extractor like Rémi / Stephen Colebourne
Property Proposal written 10 years ago!
shhhhhhhhhhhhhh!
97
var local type var inference
10
11 var as lambda parameters raw string nestmatescondy
12 - 13
inner classes
private in VM
expr switch
type switch
const lambda
record
98
99
Java 14+
Sealed interfaces
Pattern matching
Value types
100
Exhaustive Switch
101
Exhaustive Switch??
record Bike() implements Vehicle
record Car(final int passengers) implements Vehicle
record Bus(final int weight, final int wheels) implements Vehicle
How can we remove this pesky default ?
int computeTax(Vehicle v) {
return switch(v) {
case Bike: 10;
case Car(var passengers): 42 + passengers * 10;
case Bus(var weight, var wheels): weight * bus.wheels;
default: throw new WTFException("unknown vehicle kind");
};
}
102
Answer: Sealed Interface!
Close the interface by listing all the subtypes
sealed interface Vehicle {
record Bike implements Vehicle
record Car(...) implements Vehicle
record Bus(...) implements Vehicle
}
Implemented using NestMates + flag on the interface
103
Sealed Interface Enables Exhaustive Switch
The compiler knows that all the subtypes are covered
int computeTax(Vehicle v) {
return switch(v) {
case Bike: 10;
case Car(var passengers): 42 + passengers * 10;
case Bus(var weight, var wheels): weight * wheels;
};
}
How does the VM know that the switch is exhaustive?
104
Sealed Interface Enables Exhaustive Switch
How does the VM know that the switch is exhaustive?
sealed interface Vehicle {
record Bike implements Vehicle
record Car(...) implements Vehicle
record Bus(...) implements Vehicle
}
Because the subtypes are nestmates!
105
Generalized Pattern Matching
106
Generalized Pattern Matching
Constants are allowed
Can extract value from different objects
“_” means whatever
var value = switch(shape) {
case Circle(_, 0): 0;
case Circle(_, var radius): PI*radius*radius;
case Rectangle(Point(var x1, var y1), Point(var x2, var y2)):
abs(x2 – x1)*abs(y2 – y1);
}
108
109
Value Type
110
Problems
Time ratio to read a value in a CPU register vs RAM
circa 1990: 1 to 1
nowadays: 1 to 100
The cost of cache misses dramatically increases!
Modern programming => more abstractions
=> JITs are more powerful
but the programming model prevents JITs to deliver
zero cost abstraction
111
Value Type
Writes like a class, works like an int
No reference, only direct value
No identity, == returns false
System.identityHashCode(), synchronized, wait()
all this fails
No need to be allocated on the heap
112
The Value Type Color
A value type has fields and methods
value class Color {
final int red;
final int green;
final int blue;
public static Color <create>() { … }
public int red() { return red; }
}
A value type is immutable!
113
An Instance of Color in Memory
Color
red
blue
green
header
114
An Array of Color Instances
header
With references With value types
red
blue
green
header
red
blue
green
header
red
blue
green
header
red
blue
green
red
blue
green
red
blue
green
117
Performance!
Value types
More pressure on the JITs (never escape)
Less pressure to the GCs
JMH on an array of Color
1 000 000
of colors
creation time
(write)
calculation time
(read)
jdk10 97.2 ms 52.5 ms
jdk10-mvt 30.5 ms 18.5 ms
118
Value Based Class and Compatibility
Since 8, some classes are documented as
value based classes
Beware, they will becomes value types in the future
119
var local type var inference
10
11 var as lambda parameters raw string nestmatescondy
12 - 13
inner classes
private in VM
expr switch
type switch
const lambda
record
14+ sealed interface
pattern matching
value type
120
That’s it!
121
Questions?

More Related Content

What's hot

The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of FlatteryJosé Paumard
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoMuhammad Abdullah
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJosé Paumard
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Dhaval Dalal
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Groupbaroquebobcat
 
AST Transformations
AST TransformationsAST Transformations
AST TransformationsHamletDRC
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better JavaGarth Gilmour
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsBartosz Kosarzycki
 
Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvAnton Arhipov
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8Dhaval Dalal
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developersJava SE 8 for Java EE developers
Java SE 8 for Java EE developersJosé Paumard
 
JDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easyJDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easyJosé Paumard
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 pramode_ce
 

What's hot (20)

The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of Flattery
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demo
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelization
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better Java
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
Java Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lvJava Bytecode Fundamentals - JUG.lv
Java Bytecode Fundamentals - JUG.lv
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developersJava SE 8 for Java EE developers
Java SE 8 for Java EE developers
 
JDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easyJDK8 : parallel programming made (too ?) easy
JDK8 : parallel programming made (too ?) easy
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017
 

Similar to Java Full Throttle

invokedynamic for Mere Mortals [Code One 2019]
invokedynamic for Mere Mortals [Code One 2019]invokedynamic for Mere Mortals [Code One 2019]
invokedynamic for Mere Mortals [Code One 2019]David Buck
 
Lies Told By The Kotlin Compiler
Lies Told By The Kotlin CompilerLies Told By The Kotlin Compiler
Lies Told By The Kotlin CompilerGarth Gilmour
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
Patterns for JVM languages JokerConf
Patterns for JVM languages JokerConfPatterns for JVM languages JokerConf
Patterns for JVM languages JokerConfJaroslaw Palka
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityGeorgePeterBanyard
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondMario Fusco
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Codenoamt
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean CodeGR8Conf
 
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...lennartkats
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Ganesh Samarthyam
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationJames Hamilton
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RaceBaruch Sadogursky
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Mohamed Nabil, MSc.
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Anton Arhipov
 
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureWhy the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureJorge Ortiz
 

Similar to Java Full Throttle (20)

invokedynamic for Mere Mortals [Code One 2019]
invokedynamic for Mere Mortals [Code One 2019]invokedynamic for Mere Mortals [Code One 2019]
invokedynamic for Mere Mortals [Code One 2019]
 
Lies Told By The Kotlin Compiler
Lies Told By The Kotlin CompilerLies Told By The Kotlin Compiler
Lies Told By The Kotlin Compiler
 
Android code convention
Android code conventionAndroid code convention
Android code convention
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Patterns for JVM languages JokerConf
Patterns for JVM languages JokerConfPatterns for JVM languages JokerConf
Patterns for JVM languages JokerConf
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
 
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
 
Decompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 PresentationDecompiling Java - SCAM2009 Presentation
Decompiling Java - SCAM2009 Presentation
 
1- java
1- java1- java
1- java
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools Race
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
Why the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID ArchitectureWhy the Dark Side should use Swift and a SOLID Architecture
Why the Dark Side should use Swift and a SOLID Architecture
 

More from José Paumard

Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19José Paumard
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfJosé Paumard
 
The Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern MatchingThe Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern MatchingJosé Paumard
 
Designing functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patternsDesigning functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patternsJosé Paumard
 
Designing functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor PatternDesigning functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor PatternJosé Paumard
 
Construire son JDK en 10 étapes
Construire son JDK en 10 étapesConstruire son JDK en 10 étapes
Construire son JDK en 10 étapesJosé Paumard
 
Asynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowAsynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowJosé Paumard
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
 
Collectors in the Wild
Collectors in the WildCollectors in the Wild
Collectors in the WildJosé Paumard
 
JAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJosé Paumard
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses étatsJosé Paumard
 
Linked to ArrayList: the full story
Linked to ArrayList: the full storyLinked to ArrayList: the full story
Linked to ArrayList: the full storyJosé Paumard
 
ArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateauArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateauJosé Paumard
 
Asynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureAsynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureJosé Paumard
 
Java 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java ComparisonJava 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java ComparisonJosé Paumard
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developersJava SE 8 for Java EE developers
Java SE 8 for Java EE developersJosé Paumard
 
Going reactive in java
Going reactive in javaGoing reactive in java
Going reactive in javaJosé Paumard
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJosé Paumard
 

More from José Paumard (20)

Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdf
 
The Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern MatchingThe Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern Matching
 
Designing functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patternsDesigning functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patterns
 
Designing functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor PatternDesigning functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor Pattern
 
Construire son JDK en 10 étapes
Construire son JDK en 10 étapesConstruire son JDK en 10 étapes
Construire son JDK en 10 étapes
 
Asynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowAsynchronous Systems with Fn Flow
Asynchronous Systems with Fn Flow
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) Bridge
 
Collectors in the Wild
Collectors in the WildCollectors in the Wild
Collectors in the Wild
 
Streams in the wild
Streams in the wildStreams in the wild
Streams in the wild
 
JAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridge
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
 
Linked to ArrayList: the full story
Linked to ArrayList: the full storyLinked to ArrayList: the full story
Linked to ArrayList: the full story
 
Free your lambdas
Free your lambdasFree your lambdas
Free your lambdas
 
ArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateauArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateau
 
Asynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureAsynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFuture
 
Java 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java ComparisonJava 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java Comparison
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developersJava SE 8 for Java EE developers
Java SE 8 for Java EE developers
 
Going reactive in java
Going reactive in javaGoing reactive in java
Going reactive in java
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
 

Recently uploaded

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 

Recently uploaded (20)

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 

Java Full Throttle

  • 1. 1
  • 3. 3 Don’t believe a word of what we are saying! Don’t believe a word of what we are saying!
  • 4. 4 Java Champion OpenJDK amber & valhalla ex: jigsaw, lambda, invokedynamic Rémi in a few wordsRémi in a few words
  • 5. 5 José in a few more wordsJosé in a few more words @JosePaumard https://github.com/JosePaumard/ https://josepaumard.github.io/ https://www.youtube.com/user/JosePaumard
  • 7. 7 Public Poll! You can get Kahoot! to participate in the poll, just before the coffee break
  • 8. 8 Introduction: What is Java up to? What is going on behind the curtain? How is Java organized: the release train etc… What is underway for the language and the VM?
  • 9. 9 How is Java organized?
  • 10. 10 OpenJDK Enhancement Proposal JEP 1: Roadmap Process JEP 11: Incubator Modules (Java 9) JEP 12: Preview Language and VM feature (Java 11) JEP 248: Make G1 the default GC (Java 9) JEP 286: Local-Variable Type Inference (Java 10) JEP 291: Deprecate CMS (Java 9) JEP 326: Raw String Literals (Java 11) ...
  • 11. 12 jdk Amber var condy expr switch record Valhalla nest mate value type preview jdk 9 release jdk 10 release jdk 12 jdk 11 release
  • 12. 13 Time-Based Release Versioning A release every 6 months March 2014: Java 8 LTS Sept 2017: Java 9 March 2018: Java 10 Sept 2018: Java 11 LTS March 2019: Java 12 Sept 2019: Java 13 ... March 2021: Java 16 Sept 2021: Java 17 LTS –
  • 13. 14 Java Community Process JSR 365: Contexts and Dependency Injection 2.0 JSR 376: Java Platform Module System (several JEPs) Umbrella JSR 383: Java SE 10 Umbrella JSR 384: Java SE 11 Time based release → Inversion of Control!
  • 14. 15 How is it Distributed? Java SE are distributions that pass the TCK AdoptOpenJDK Azul Zulu / Azul Zing + C4 (GC) + Falcon (JIT) IBM J9 OpenJ9 (VM + JIT + GCs) OpenJDK Oracle + Mission Control, + Flight Recorder (open sourced!) RedHat + Shenandoah (GC)
  • 18. 20 Local Variable Type Inference Let the compiler infers the type of local variables var list = List.of("hello", "devoxx"); var max = list.stream().max(String::compareTo); max.ifPresent(System.out::println); Fields and methods can not use var class Foo { var foo; // fails int foo(var a); // fails }
  • 19. 21 Var & Inference Works with for(:) and try(=) for (var element: list) { ... } try (var lines = Files.lines(path)) { ... } Works beautifully with anonymous classes var counter = new Object() { int value; }; list.forEach(e -> counter.value++);
  • 20. 22 Var & Inference (2) Inference fails for var a; // fails var a = null; // fails var lambda = x -> x; // fails var methodref = Integer::sum; // fails var array = { 1, 2, 3 }; // fails Work surprisingly if return type is needed var empty = List.of(); // List<Object>
  • 21. 23 When to use var? Guidelines Choose variable names that provide useful information. Consider var when the initializer provides sufficient information to the reader. Don't worry too much about "programming to the interface" with local variables. http://openjdk.java.net/projects/amber/LVTIstyle.html
  • 22. 24 var local type var inference 10
  • 24. 26 Java 11 Var as Lambda Parameters Nestmates Condy Raw string
  • 25. 27 Var as Lambda Parameters
  • 26. 28 var as Type in Lambda Parameters Lambda parameters can use var IntBinaryOperator fun = (var x, var y) -> x + y; Allow modifiers and annotations IntBinaryOperator fun = (final var x, final var y) -> x + y; BinaryOperator<Integer> fun = (@NonNull var x, @NonNull var y) -> x + y;
  • 28. 31 Can You Spot the Problem? The compiler does stupid things behind your back interface Foo { public int value(); private static int helperValue() { return 42; } public static Foo create() { return new Foo() { public int value() { return helperValue(); } }; } }
  • 29. 32 The Accessor is Public! The inner class needs to access Foo.helperValue() public interface Foo { public abstract int value(); private static int helperValue(); Code: 0: bipush 42 2: ireturn public static int access$000(); Code: 0: invokestatic InterfaceMethod helperValue:()I 3: ireturn }
  • 30. 33 Can You Spot The Problem (2)? And what about using reflection? public class Foo { private int value; public class Bar { public int getValue() { return Foo.class.getDeclaredField("value") .getInt(); } } }
  • 31. 34
  • 32. 35 NestMates Sync the JVMS and the JLS view on private Creates two new class attributes NestMembers (in enclosing class) List all internal classes NestHost (in internal classes) Name the enclosing class  private access check by the VM Is it the same class ? Is the class listed as a nest members of the nest host ?
  • 33. 36 Class Loading Order? May the VM load more classes than before? class Foo { private static int value; static class Bar { int m() { return value; } int m2() { return 42; } } } No, the access resolution is lazy but IllegalAccessError may appear later
  • 35. 38 Constant Dynamic The VM only allow primitives, String, etc. as constant pool constants  add arbitrary constant in the constant pool Constant pool constant (use ldc to load) CONSTANT_InvokeDynamic_info { u1 tag; u2 bootstrap_method_attr_index; u2 name_and_type_index; } Bootstrap method (called once) Object bsm(Lookup lookup, String name, Class<?> type, ...) { ... }
  • 36. 39 Example in Java (maybe) Alleviate the burden of the static block if the initialization is idempotent class Foo { private static final lazy boolean DEBUG = Boolean.valueOf(System.getenv("DEBUG")); void bar() { if (DEBUG) { ... } } }
  • 37. 40 Example in Java (maybe) No static block needed, lazy initiailization done by the VM class Foo { 10: condy constantMetaFactory.bsm $init_DEBUG$ private static boolean $init_DEBUG$() { return Boolean.valueOf(System.getenv("DEBUG")); } void bar() { ldc 10 ifeq ... } }
  • 38. 41 Constant Lambda All Lambdas are initialized with indy class Foo { IntSupplier provider() { return () -> 42; } } class Foo { 10: indy LambdaMetaFactory.lambda $lambda$ IntSupplier() IntSupplier provider() { indy 10 } private static int $lambda$() { return 42; } }
  • 39. 42 Constant Lambda with condy Constant Lambdas should be initialized with condy class Foo { IntSupplier provider() { return () -> 42; } } class Foo { 10: condy lambdaMetaFactory.condy $lambda$ IntSupplier IntSupplier provider() { ldc 10 } private static int $lambda$() { return 42; } }
  • 40. 43 Constant Dynamic vs Invokedynamic Differences between condy and indy Constant Dynamic InvokeDynamic can represent only constant any expression creation lazy created (ldc) lazy created (invokedynamic) interpreter constant non-constant c1 constant non-constant c2 constant constant graal constant constant
  • 41. 44 Lambda Creation Java 8 All lambdas creation use invokedynamic Constant lambdas are constant at JIT time Java 11 Introduction of constant dynamic in the VM Java 12? Constant lambdas use constant dynamic Need re-compilation :( Constant lambdas are constant at interpreter time
  • 42. 45 Constant Dynamic and Annotation Annotation values are constants in the constant pool Condy allows to define any constants ! Proposal: allow any class instance as an annotation value Problem: any use cases?
  • 45. 48 Java String Issues No way to create a non-despecialized string var pattern = Pattern.compile(""); Not easy to create a multi-lines string var s = "this is a longn" + "multi-linesn" + "of text"; Not easy to embed code var s = "<a href="javascript: alert(‘hello’)">";
  • 46. 49 Raw String Add non-despecialized string and multi-lines string Starts by n-backticks (`) and ends by n-backticks var pattern = Pattern.compile(``); var s = `this is a long multi-lines of text`; var s = ```<a href="javascript: alert(‘hello’)">```;
  • 47. 50 Raw String API strip(): same as trim(), works with UTF-8 spaces! stripIndent(): removes indenting spaces stripLeading(), stripTrailing(): removes leading and trailing spaces stripMarkers(): removes what is outside the markers lines(): streams the lines of the multiline
  • 48. 51 WARNING! Because you can embed Java code in raw String var text = `` var s = `this is a long multi-lines of text`; ``; it means that `` is not the empty String but the start of a raw String
  • 49. 52 var local type var inference 10 11 var as lambda parameters raw string nestmatescondy inner classes private in VM
  • 50. 53 Even More Evil Plan For World Domination!
  • 52. 55
  • 53. 56 Limitation of Switch Switch doesn’t work well when the result is an expression Car car; switch(text) { case "upgrade": case "awesome": car = new Mustang(); break; case "regular": car = new Clio(); break; default: throw new WTFException(); }
  • 54. 57 Switch Expression Use break expression to specify the result of a case var car = switch(text) { case "upgrade": case "awesome": break new Mustang(); case "regular": System.out.println("I am a Clio!"); break new Clio(); default: throw new WTFException(); };
  • 55. 58 Others Limitations Try to get rid of fall-through It makes the code unreadable, easy to introduce regression when refactoring Try have a story for null better than throw NPE Nice to have: a shorter syntax for single expression?
  • 56. 59 Avoid Fall-through Allow comma separated cases var car = switch(text) { case "upgrade", "awesome": break new Mustang(); case "regular": System.out.println("I am a Clio!"); break new Clio(); default: throw new WTFException(); };
  • 57. 60 Allow case null NPE unless there is a case null var car = switch(text) { case "upgrade", "awesome": break new Mustang(); case "regular": System.out.println("I am a Clio!"); break new Clio(); case null, default: throw new WTFException(); }; Allow to mix case: and default:?
  • 58. 61 Retrofit the Statement Switch Comma separated cases and case null are also available on the statement switch Car car; switch(text) { case "upgrade", "awesome": car = new Mustang(); break; case "regular": car = new Clio(); break; case null, default: throw new WTFException(); }
  • 59. 62 Single Expression Syntax Use -> instead of : break var car = switch(text) { case "upgrade", "awesome" -> new Mustang(); case "regular": System.out.println("I am a Clio!"); break new Clio(); case null, default -> throw new WTFException(); }; “->” also work for throw?
  • 60. 63 Problem of -> as shorter syntax -> used here is not the same as the -> used in lambdas and the syntax -> { } does not work with case: Alternative syntax var car = switch(text) { case "upgrade", "awesome": new Mustang(); case "regular": new Clio(); case null, default: throw new WTFException(); };
  • 61. 64 I suggest you do this poll at Devoxx. Make sure to wear flame-proof pants! Brian Goetz
  • 62. 65 Poll! 1. no shorter syntax, break expr is short enough 2. “->” as shorter syntax case "regular" -> new Clio(); case "regular": break new Clio();
  • 63. 66 Poll! 1. no shorter syntax, break expr is short enough 2. “->” as shorter syntax 3. “:” as shorter syntax case "regular" -> new Clio(); case "regular": break new Clio(); case "regular": new Clio();
  • 67. 70 Current Translation Strategy of Switch on String in pseudo bytecode aload 0 invokevirtual String.hashCode ()I lookupswitch label -231171556 // "upgrade".hashCode() test.equals("upgrade")? 0: -1 label 1086463900 // "regular".hashCode() test.equals("regular")? 1: -1 tableswitch label 0 … // new Mustang label 1 … // new Clio istore 1 var car = switch(text) { case "upgrade": new Mustang(); case "regular": new Clio(); };
  • 68. 71 Current Translation Strategy of Switch What if the compiler world and the VM world are not aligned anymore? For String: The solution could be to specify that String.hashCode() can not be changed For Enum: It should state that you can only add enum values at the end of the list
  • 69. 72 New Translation to Bytecode invokedynamic is used to associate an int to each case in pseudo-bytecode invokedynamic (String)I SwitchMetaFactory.string ["upgrade", "awesome", "regular"], [0, 0, 1] tableswitch label 0: … // new Mustang label 1: … // new Clio astore 1 var car = switch(text) { case "upgrade": new Mustang(); case "regular": new Clio(); };
  • 70. 73 Performance?? Test avec JMH old switch new switch cascade if equals small (4 cases) 23.9 +/- 0.2 ns/op 11.6 +/- 0.1 ns/op 16.4 +/- 0.1 ns/op big (10 cases) 135.4 +/- 4.0 ns/op 86.2 +/- 1.5 ns/op 25.1 +/- 0.4 ns/op
  • 71. 74 New Translation to Bytecode Switch on enums, String, double, float, long use indy The bytecode becomes independent from the compiler world Usually better performance Less bytecodes Dynamic strategies adaptation But it needs to recompile the old code... And it puts more pressure on the JIT It may take longer to reach steady state
  • 72. 75 Extending Switch to Accept Types (Toward Pattern Matching)
  • 73. 76 Extending Switch to Accept Types Computing something on a hierarchy you do not control int computeTax(Vehicle v) { if (v instanceof Bike) { return 10; } else if (v instanceof Car) { return 42 + ((Car) v).passengers() * 10; } else if (v instanceof Bus) { return ((Bus) v).weight() * ((Bus) v).wheels(); } else { throw new WTFException("unknown vehicle kind"); } }
  • 74. 77 Extending Switch to Accept Types One can use a Visitor (if there is a method accept) int computeTax(Vehicle v) { return v.accept(VISITOR); } private static final Visitor VISITOR = new Visitor() { public int visitBike(Bike bike) { return 10; } public int visitCar(Car car) { return 42 + car.passengers() * 10; } public int visitBus(Bus bus) { return bus.weight() * bus.wheels(); } };
  • 75. 78 Extending Switch to Accept Types Computing something on a hierarchy you do not control int computeTax(Vehicle v) { return switch(v) { case Bike: 10; case Car: 42 + ((Car) v).passengers() * 10; case Bus: ((Bus) v).weight() * ((Bus) v.wheels(); default: throw new WTFException("unknown ..."); }; }
  • 76. 79 Translation to Bytecode Same Translation as with Strings aload 0 invokedynamic (Vehicle)I SwitchMetaFactory.types [Bike.class, Car.class, Bus.class], [0, 1, 2] tableswitch label 0: bipush 10 label 1: bipush 42 aload 0 checkcast Car invokevirtual Car passagers ()I iadd label 2: … // ((Bus) v).weight() * ((Bus) v).wheels() ireturn
  • 77. 80 Performance?? Test with JMH instanceof type switch lot of cases lot of classes 395 +/- 21.2 ns/op 55 +/- 2.1 ns/op small n cases lot of classes 35 +/- 1.6 ns/op 51 +/- 0.7 ns/op small n cases small n classes 7 +/- 0.1 ns/op 6 +/- 0.1 ns/op
  • 78. 81 Extending Switch to Accept Types Naming the type avoid the cast int computeTax(Vehicle v) { return switch(v) { case Bike: 10; case Car car: 42 + car.passengers() * 10; case Bus bus: bus.weight() * bus.wheels(); default: throw new WTFException("unknown ..."); }; }
  • 79. 82 Bringing Back the Encapsulation Allows destructured switch on type int computeTax(Vehicle v) { return switch(v) { case Bike: 10; case Car(int passengers): 42 + passengers * 10; case Bus(int weight, int wheels): weight * wheels; ... }; } We need the inverse operation of a constructor
  • 80. 83 De-constructor A de-constructor describes how to get a tuple of values from an object class Bus { Bus(int weight, int wheels) { … } (int, int) deconstructor() { return …; } } But returning several values in not easy in Java (yet!)
  • 81. 84 A Path to a Solution The problem can be solved for classes with a primary constructor record Bus(int weight, int wheels) { int weight; // compiler generated int wheels; // compiler generated public static Extractor extractor() { // compiler generated return Extractor.of(bus -> bus.weight, bus -> bus.wheels); } } The Extractor is then a list of getters
  • 82. 85 Switch on Records record Bike implements Vehicle record Car(int passengers) implements Vehicle record Bus(int weight, int wheels) A record provides an extractor that returns its component values int computeTax(Vehicle v) { return switch(v) { case Bike: 10; case Car(var passengers): 42 + passengers * 10; case Bus(var weight, var wheels): weight * bus.wheels; default: throw new WTFException("unknown vehicle kind"); }; }
  • 83. 86 Switch on Records - Translation The getter from the extractor are defined as Constant Dynamic 0: ConstantDynamic MethodHandle SwitchMetafactory.getter [Car.class, 0]; 1: ConstantDynamic MethodHandle SwitchMetafactory.getter [Bus.class, 0]; 2: ConstantDynamic MethodHandle SwitchMetafactory.getter [Bus.class, 1]; int computeTax(Vehicle v) { aload 0 invokedynamic (Vehicle)I SwitchMetaFactory.types [Bike.class, Car.class, Bus.class] [0, 1, 2] tableswitch label 0: bipush 10 label 1: bipush 42 aload 0 invokedynamic (Vehicle)I SwitchMetafactory.extract [item 0] iadd label 2: … ireturn 1
  • 85. 88 Record A plain simple data object record Point(final int x, final int y) is translated to public final class Point { final int x; final int y; public Point(int x, int y) { this.x = x; this.y = y; } public int x() { return x; } public int y() { return y; } // + equals / hashCode / toString / extractor }
  • 86. 89 Record Record can have supplementary methods but no supplementary fields record Point(final int x, final int y) record Circle(final Point center, final int radius) { public double surface() { return Math.PI * radius * radius; } }
  • 87. 90 Record and Precondition Relax java rule: you can have preconditions before the calls to the super / default constructor record Circle(final Point center, final int radius) { public Circle(Point center, int radius) { Preconditions.requiresNonNull(center); Preconditions.requiresPositive(radius); default(center, radius); } } java.util.Preconditions contains usual precondition tests
  • 88. 91 Setters are not Generated! Because the compiler doesn’t know about preconditions record Circle(final Point center, final int radius) { public Circle(Point center, int radius) { requiresNonNull(center); requiresPositive(radius); default(center, radius); } public void center(Point center) { this.center = requiresNonNull(center); } public void radius(int radius) { this.radius = requiresPositive(radius); } }
  • 90. 93 equals / hashCode / toString / extractor The code is not generated by the compiler Use invokedynamic + constant dynamic /*record*/ final class Bus { 10: constant dynamic Extractor RecordMetafactory.extractor [Bus::weight, Bus::wheels] final int weight; final int wheels; public String toString() { return invokedynamic RecordMetafactory.toString [constant item 10] } }
  • 91. 94 Indy + Condy The Extractor is computed once lazily equals(), balance the cascade of if … else depending on the cost of equals() for each components can re-balance the cascade if..else at runtime! equals and hashCode can do nullcheck implicitly
  • 92. 95 Extractor Use ldc + constant dynamic /*record*/ final class Bus { 10: constant dynamic Extractor RecordMetafactory.extractor [Bus::weight, Bus::wheels] final int weight; final int wheels; public static /*extractor*/ Extractor extractor() { ldc [constant item 10] areturn } }
  • 93. 96 Record vs Property Is Record + Extractor like Rémi / Stephen Colebourne Property Proposal written 10 years ago! shhhhhhhhhhhhhh!
  • 94. 97 var local type var inference 10 11 var as lambda parameters raw string nestmatescondy 12 - 13 inner classes private in VM expr switch type switch const lambda record
  • 95. 98
  • 98. 101 Exhaustive Switch?? record Bike() implements Vehicle record Car(final int passengers) implements Vehicle record Bus(final int weight, final int wheels) implements Vehicle How can we remove this pesky default ? int computeTax(Vehicle v) { return switch(v) { case Bike: 10; case Car(var passengers): 42 + passengers * 10; case Bus(var weight, var wheels): weight * bus.wheels; default: throw new WTFException("unknown vehicle kind"); }; }
  • 99. 102 Answer: Sealed Interface! Close the interface by listing all the subtypes sealed interface Vehicle { record Bike implements Vehicle record Car(...) implements Vehicle record Bus(...) implements Vehicle } Implemented using NestMates + flag on the interface
  • 100. 103 Sealed Interface Enables Exhaustive Switch The compiler knows that all the subtypes are covered int computeTax(Vehicle v) { return switch(v) { case Bike: 10; case Car(var passengers): 42 + passengers * 10; case Bus(var weight, var wheels): weight * wheels; }; } How does the VM know that the switch is exhaustive?
  • 101. 104 Sealed Interface Enables Exhaustive Switch How does the VM know that the switch is exhaustive? sealed interface Vehicle { record Bike implements Vehicle record Car(...) implements Vehicle record Bus(...) implements Vehicle } Because the subtypes are nestmates!
  • 103. 106 Generalized Pattern Matching Constants are allowed Can extract value from different objects “_” means whatever var value = switch(shape) { case Circle(_, 0): 0; case Circle(_, var radius): PI*radius*radius; case Rectangle(Point(var x1, var y1), Point(var x2, var y2)): abs(x2 – x1)*abs(y2 – y1); }
  • 104. 108
  • 106. 110 Problems Time ratio to read a value in a CPU register vs RAM circa 1990: 1 to 1 nowadays: 1 to 100 The cost of cache misses dramatically increases! Modern programming => more abstractions => JITs are more powerful but the programming model prevents JITs to deliver zero cost abstraction
  • 107. 111 Value Type Writes like a class, works like an int No reference, only direct value No identity, == returns false System.identityHashCode(), synchronized, wait() all this fails No need to be allocated on the heap
  • 108. 112 The Value Type Color A value type has fields and methods value class Color { final int red; final int green; final int blue; public static Color <create>() { … } public int red() { return red; } } A value type is immutable!
  • 109. 113 An Instance of Color in Memory Color red blue green header
  • 110. 114 An Array of Color Instances header With references With value types red blue green header red blue green header red blue green header red blue green red blue green red blue green
  • 111. 117 Performance! Value types More pressure on the JITs (never escape) Less pressure to the GCs JMH on an array of Color 1 000 000 of colors creation time (write) calculation time (read) jdk10 97.2 ms 52.5 ms jdk10-mvt 30.5 ms 18.5 ms
  • 112. 118 Value Based Class and Compatibility Since 8, some classes are documented as value based classes Beware, they will becomes value types in the future
  • 113. 119 var local type var inference 10 11 var as lambda parameters raw string nestmatescondy 12 - 13 inner classes private in VM expr switch type switch const lambda record 14+ sealed interface pattern matching value type