-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3473 from Rawi01/jdk21
Add support for JDK21
- Loading branch information
Showing
12 changed files
with
116 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
record Point(int x, int y) { | ||
} | ||
record Rectangle(Point upperLeft, Point lowerRight) { | ||
} | ||
|
||
public class RecordPattern21 { | ||
void recordPattern(Object o) { | ||
if (o instanceof Point(int x, int y)) { | ||
} | ||
if (o instanceof Rectangle(Point(var x1, var y1), Point(int x2, int y2))) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
public class Switch21 { | ||
String switchPatternMatching(Object o) { | ||
return switch (o) { | ||
case Integer i -> String.format("int %d", i); | ||
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 -> o.toString(); | ||
}; | ||
} | ||
|
||
String switchNull(Object o) { | ||
return switch (o) { | ||
case null, default -> "?"; | ||
}; | ||
} | ||
|
||
String switchGuardPattern(Object o) { | ||
return switch (o) { | ||
case String s when s.length() > 1 -> s; | ||
case String s -> s; | ||
default -> o.toString(); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// version 21: | ||
record Point(int x, int y) { | ||
} | ||
record Rectangle(Point upperLeft, Point lowerRight) { | ||
} | ||
|
||
public class RecordPattern21 { | ||
void recordPattern(Object o) { | ||
if (o instanceof Point(int x, int y)) { | ||
} | ||
if (o instanceof Rectangle(Point(var x1, var y1), Point(int x2, int y2))) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// version 21: | ||
public class Switch21 { | ||
String switchPatternMatching(Object o) { | ||
return switch (o) { | ||
case Integer i -> String.format("int %d", i); | ||
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 -> o.toString(); | ||
}; | ||
} | ||
|
||
String switchNull(Object o) { | ||
return switch (o) { | ||
case null, default -> "?"; | ||
}; | ||
} | ||
|
||
String switchGuardPattern(Object o) { | ||
return switch (o) { | ||
case String s when s.length() > 1 -> s; | ||
case String s -> s; | ||
default -> o.toString(); | ||
}; | ||
} | ||
} |