Skip to content

Commit 567696d

Browse files
committed
fix links; Java 15: sealed types
1 parent 3f45d9b commit 567696d

File tree

4 files changed

+110
-24
lines changed

4 files changed

+110
-24
lines changed

README.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ A project to explore more about the new features of Java 8, 9, ...
66

77
## Resume by Version
88

9-
* [Java 8](java-8/README.md)
9+
* [Java 8](java-8/)
1010
* API
1111
* Stream API
1212
* Project Lambda
1313
* Repeating annotations
1414

15-
* [Java 9](java-9/README.md)
15+
* [Java 9](java-9/)
1616
* Milling Project Coin
1717
* Process API
1818
* Platform Logging API and Service
@@ -23,28 +23,28 @@ A project to explore more about the new features of Java 8, 9, ...
2323
* JShell
2424
* much more (see JEPs)
2525

26-
* [Java 10](java-10/README.md) (March 20th, 2018)
26+
* [Java 10](java-10/) (March 20th, 2018)
2727
* Process API improvements
2828
* Collections improvements
2929
* Application Class-Data Sharing
3030
* `var` keyword to declare variables
3131

32-
* [Java 11](java-11/README.md)
32+
* [Java 11](java-11/)
3333
* Removal of Java EE Modules, JavaFX and deprecated API
3434
* Http Client (incubator)
3535
* var in lambda expressions
3636
* API improvements
3737
* Null I/O
3838

39-
* [Java 12](java-12/README.md)
39+
* [Java 12](java-12/)
4040
* Switch expression (preview 1)
4141
* Compact Number Format
4242
* Collectors improvements
4343
* CompletableFuture improvements
4444
* CDS enable by default
4545
* New GC and improvements
4646

47-
* [Java 13](java-13/README.md)
47+
* [Java 13](java-13/)
4848
* Switch expression (preview 2)
4949
* Text blocks
5050
* String API updates
@@ -53,11 +53,13 @@ A project to explore more about the new features of Java 8, 9, ...
5353
* Dynamic CDS Archives
5454
* ZGC: Uncommit Unused Memory
5555

56-
* [Java 14](java-14/README.md) (May 17th, 2020)
56+
* [Java 14](java-14/) (May 17th, 2020)
5757
* Switch expression (standard)
5858
* Pattern matching for `instanceof` (preview)
5959
* Text blocks improvements
6060
* Records (preview)
6161
* Helpful NullPointerExceptions
6262
* Packaging tool
63-
* JFR even streaming
63+
* JFR even streaming
64+
65+
* [Java 15](java-15/)

java-11/README.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@
4242

4343
## JEPs
4444

45-
* [181](https://openjdk.java.net/jeps/336) - Nest-Based Access Control
46-
* [309](https://openjdk.java.net/jeps/335) - Dynamic Class-File Constants
47-
* [315](https://openjdk.java.net/jeps/333) - Improve Aarch64 Intrinsics
48-
* [318](https://openjdk.java.net/jeps/332) - Epsilon: A No-Op Garbage Collector
49-
* [320](https://openjdk.java.net/jeps/331) - Remove the Java EE and CORBA Modules
50-
* [321](https://openjdk.java.net/jeps/330) - HTTP Client (Standard)
51-
* [323](https://openjdk.java.net/jeps/329) - Local-Variable Syntax for Lambda Parameters
52-
* [324](https://openjdk.java.net/jeps/328) - Key Agreement with Curve25519 and Curve448
45+
* [181](https://openjdk.java.net/jeps/181) - Nest-Based Access Control
46+
* [309](https://openjdk.java.net/jeps/309) - Dynamic Class-File Constants
47+
* [315](https://openjdk.java.net/jeps/315) - Improve Aarch64 Intrinsics
48+
* [318](https://openjdk.java.net/jeps/318) - Epsilon: A No-Op Garbage Collector
49+
* [320](https://openjdk.java.net/jeps/320) - Remove the Java EE and CORBA Modules
50+
* [321](https://openjdk.java.net/jeps/321) - HTTP Client (Standard)
51+
* [323](https://openjdk.java.net/jeps/323) - Local-Variable Syntax for Lambda Parameters
52+
* [324](https://openjdk.java.net/jeps/324) - Key Agreement with Curve25519 and Curve448
5353
* [327](https://openjdk.java.net/jeps/327) - Unicode 10
54-
* [328](https://openjdk.java.net/jeps/324) - Flight Recorder
55-
* [329](https://openjdk.java.net/jeps/323) - ChaCha20 and Poly1305 Cryptographic Algorithms
56-
* [330](https://openjdk.java.net/jeps/321) - Launch Single-File Source-Code Programs
57-
* [331](https://openjdk.java.net/jeps/320) - Low-Overhead Heap Profiling
58-
* [332](https://openjdk.java.net/jeps/318) - Transport Layer Security (TLS) 1.3
59-
* [333](https://openjdk.java.net/jeps/315) - ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
60-
* [335](https://openjdk.java.net/jeps/309) - Deprecate the Nashorn JavaScript Engine
61-
* [336](https://openjdk.java.net/jeps/181) - Deprecate the Pack200 Tools and API
54+
* [328](https://openjdk.java.net/jeps/328) - Flight Recorder
55+
* [329](https://openjdk.java.net/jeps/329) - ChaCha20 and Poly1305 Cryptographic Algorithms
56+
* [330](https://openjdk.java.net/jeps/330) - Launch Single-File Source-Code Programs
57+
* [331](https://openjdk.java.net/jeps/331) - Low-Overhead Heap Profiling
58+
* [332](https://openjdk.java.net/jeps/332) - Transport Layer Security (TLS) 1.3
59+
* [333](https://openjdk.java.net/jeps/333) - ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
60+
* [335](https://openjdk.java.net/jeps/335) - Deprecate the Nashorn JavaScript Engine
61+
* [336](https://openjdk.java.net/jeps/336) - Deprecate the Pack200 Tools and API
6262

6363
## Links
6464

java-15/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Java 15
2+
3+
To run each example use: `java --enable-preview --source 15 <FileName.java>`
4+
5+
## Features
6+
7+
### Language
8+
9+
* Sealed types
10+
* Pattern matching for `instanceof` (second preview)
11+
* Text blocks (standard)
12+
* Records (second preview)
13+
* Integration with sealed types
14+
15+
### JVM
16+
17+
## JEPs
18+
19+
* [339](https://openjdk.java.net/jeps/339) - Edwards-Curve Digital Signature Algorithm (EdDSA)
20+
* [360](https://openjdk.java.net/jeps/360) - Sealed Classes (Preview)
21+
* [371](https://openjdk.java.net/jeps/371) - Hidden Classes
22+
* [372](https://openjdk.java.net/jeps/372) - Remove the Nashorn JavaScript Engine
23+
* [373](https://openjdk.java.net/jeps/373) - Reimplement the Legacy DatagramSocket API
24+
* [374](https://openjdk.java.net/jeps/374) - Disable and Deprecate Biased Locking
25+
* [375](https://openjdk.java.net/jeps/375) - Pattern Matching for instanceof (Second Preview)
26+
* [377](https://openjdk.java.net/jeps/377) - ZGC: A Scalable Low-Latency Garbage Collector
27+
* [378](https://openjdk.java.net/jeps/378) - Text Blocks
28+
* [379](https://openjdk.java.net/jeps/379) - Shenandoah: A Low-Pause-Time Garbage Collector
29+
* [381](https://openjdk.java.net/jeps/381) - Remove the Solaris and SPARC Ports
30+
* [383](https://openjdk.java.net/jeps/383) - Foreign-Memory Access API (Second Incubator)
31+
* [384](https://openjdk.java.net/jeps/384) - Records (Second Preview)
32+
* [385](https://openjdk.java.net/jeps/385) - Deprecate RMI Activation for Removal
33+
34+
## Links
35+
36+
* [JDK 15 Jeps](https://openjdk.java.net/projects/jdk/15/)
37+
* [Doc about record and sealed types](https://cr.openjdk.java.net/~briangoetz/amber/datum.html)

java-15/SealedTypesExample.java

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* To run: `java --enable-preview --source 15 SealedTypesExample.java`
3+
*/
4+
public class SealedTypesExample {
5+
public static void main(String[] args) {
6+
// get something from somewhere
7+
var player = new Player();
8+
var entity = player.getCollidingEntity();
9+
10+
switch (entity) {
11+
case Player:
12+
player.move();
13+
entity.move();
14+
break;
15+
case Enemy:
16+
player.die();
17+
break;
18+
case Object:
19+
object.move();
20+
break;
21+
// we dont need to do this (nor ifs) - because we restricted the implementations types (we know them)
22+
// default:
23+
// throw IllegalStateException("Unexpected entity");
24+
}
25+
}
26+
}
27+
28+
/**
29+
* Sealed types will help us to restrict which types can extend/implement a type.
30+
* Will allow us to write less verbose polymorphic code.
31+
*/
32+
sealed abstract class GameEntity
33+
permits Player, Enemy, Object {}
34+
35+
class Player extends GameEntity {
36+
/**
37+
* Returns the entity which is colling with the player.
38+
*/
39+
public GameEntity getCollidingEntity() {
40+
// obscure logic
41+
return new Enemy();
42+
}
43+
}
44+
45+
class Enemy extends GameEntity {}
46+
47+
class Object extends GameEntity {}

0 commit comments

Comments
 (0)