Merlin Bögershausen / @mboegie
Mentimeter.com:
Version | GA π | Free π | Extended πΆ |
---|---|---|---|
8 | 2014 | Azul 2030 | Oracle 2030 |
11 | 2018 | Amazon 2027 | Azul 2026 |
17 | 2019 | Azul 2029 | Oracle 2029 |
21 | 2023 | 2028 | Oracle 2031 |
Mentimeter.com: 5520 4780
Mentimeter.com: 5520 4780
Streams
Lambdas
Optional
Collection Factory Methods
Map.of("Vanessa", "π§π»", "Fred", "πΆπΌ", "Merlin", "π§ββοΈ")
.entrySet().stream()
.filter(e -> e.getKey().contains("e"))
.findAny()
.map(e -> e.getKey() + " is " + e.getValue())
.ifPresent(System.out::println);
Local Variable Type Inference
HTTP Client
try-with-Resource
private Interface Methods
var client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.authenticator(Authenticator.getDefault()).build();
var req = HttpRequest.newBuilder()
.GET().uri(URI.create("http://localhost:8080"))
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
Local Variable Type Inference
HTTP Client
try-with-Resource
private Interface Methods
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
try(var in = new ByteArrayInputStream(res.body().getBytes())) {
var byteContent = Arrays.toString(in.readAllBytes());
System.out.println(byteContent);
} catch (IOException e) {
System.out.println("Failed to read response");
}
Java Platform Module System
Execute .java Files
java -XX:StartFlightRecording\
-add-modules java.base Example.java
G1 return Memory to OS π οΈ
Switch Expressions Preview π¬
Text Block preview π¬
ZGC for Windows and MacOS π οΈ
instanceof Patern π¬
Record classes π¬
jpackage tool π¬2
Sealed Classes π¬
Remove of Nashorn π§
Incubation Foreign-Memory Access API π¬2
RMI Deprecation β οΈ
Move to GitHub π
Alpine Linux Port π
Elastic Meta Space π
Incubation Foreign Linker API π¬2
Deprecation of Applet API β οΈ
Hide JDK internals effectively π§
Pattern Matching for switch π¬
RMI Removed π§
Remove AOT and JIT Compiler π§
Sealed class and Records
Type Pattern & Switch Expression
Helpful Null
Text Blocks
JPackage
Sealed Class & Interfaces
Records
sealed interface Shape {
record Cornered(int x, int y, int h, int w)
implements Shape {}
non-sealed interface Round implements Shape {}
final class Weirdo implements Shape {}
}
Type Pattern
Switch Expression
switch (s) {
case Triangle t when t.calculateArea() > 100 ->
System.out.println("Large");
case Triangle t -> System.out.println("Small");
default -> System.out.println("Non-triangle");
}
Helpful Nullpointer Exceptions
Textblocks
JPackage
Exception in thread "main" java.lang.NullPointerException:
Cannot read field "c" because "a.b" is null
at Prog.main(Prog.java:5)
Helpful Nullpointer Exceptions
Textblocks
JPackage
String helloWorldResponse = String.format(
"""
<html>
<body>
<p>Hello, %s</p>
</body>
</html>
""", getName());
Helpful Nullpointer Exceptions
Textblocks
JPackage
jpackage --type app-image\
-i inputDir -n name
--main-class className --main-jar\
myJar.jar
UTF 8 by default π
Simple Web Server π
Record Patterns π¬
Foreign Function & Memory API π¬
Virtual Threads π¬
Structured Concurrency π¬2
Scoped Values π¬2
something big is coming!
Sources: github.com/MBoegers/DataOrientedJava
sealed interface Kunde permits Businesskunde, Privatkunde
{ String name(); String mail(); }
record Privatkunde(String name, String mail)
implements Kunde {}
record Businesskunde(String name, String mail,
boolean isVorsteuerAbzugsberechtigt) implements Kunde {}
static double calculateMwSt(Kunde kunde, double wert) {
return switch (kunde) {
case Businesskunde b when b.isVorsteuerAbzugsberechtigt()
-> 0.0d;
case Businesskunde b -> wert * 0.18d;
case Privatkunde p -> wert * 0.18d;
};
}
switch (rechnung) {
case InterneVerechnung(var abt, double wert) ->
Dummy.storeInDB(abt, wert);
case ExternVersandt(Kunde kunde, var wert) -> {
double mwst = calculateMwSt(kunde, wert);
var txt = formatMail(kunde.name(), wert, mwst);
Dummy.sendViaMail(kunde.mail(), txt);
}
}
String mailText = """
Hallo %s, Bitte senden Sie uns den Rechnungsbetrag in HΓΆhe
von %.2f⬠plus %.2f⬠MwSt.
Mit freundlichen GrΓΌΓen
Merlin BΓΆgershausen
""".formatted(name, wert, mwst);
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
var future1 = executor.submit(() -> fetchURL(url1));
var future2 = executor.submit(() -> fetchURL(url2));
response.send(future1.get() + future2.get());
} catch (ExecutionException | InterruptedException e) {
response.fail(e);
}
Data oriented programming inside Modules
Modularization in the Big
Linea Programming, Concurrent Execution
Poll from freepik.com
Features per Java Release from dev.java
Class Diagramm from GH/MBoegers/DataOrientedJava
Dukes from OpenJDK