Java 13 has been released on 9/17/2019. Java SE 13 Platform JSR 388
I was able to download it from the OpenJDK site. https://jdk.java.net/13/
You can now download it from the archive site. https://jdk.java.net/archive/
It's not LTS, so I don't think it's necessary to download it from now on except for verification purposes. SDKMAN! is recommended for installation on Mac and Linux
Other than Oracle OpenJDK, the following distributions are available for commercial use free of charge.
Since it is not LTS, it does not seem to be released on Amazon Corretto.
You can use the Oracle JDK for development purposes, but you must purchase a Java SE Subscription for commercial use.
JEP The changes are organized as JEP. https://openjdk.java.net/projects/jdk/13/
This time around 5 JEPs are included. JEP 350: Dynamic CDS Archives JEP 351: ZGC: Uncommit Unused Memory (Experimental) JEP 353: Reimplement the Legacy Socket API JEP 354: Switch Expressions (Second Preview) JEP 355: Text Blocks (Preview)
JEP 355: Text Blocks (Preview) A multi-line string literal was introduced as a preview.
String html = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";
Space escaping etc. have been added and become standard in Java 15. See the Java 14 description for detailed specifications. Java 14 New Features Summary-Qiita
JEP 354: Switch Expressions (Second Preview) Make the Switch statement an expression.
int numLetters = switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
case THURSDAY, SATURDAY -> 8;
case WEDNESDAY -> 9;
};
Compared to Java 12, the syntax for returning a value in a switch expression has changed from break
to yield
.
It is standardized in Java 14.
See the Java 14 description for detailed specifications.
Java 14 New Features Summary-Qiita
Create a CDS archive at runtime by adding -XX: ArchiveClassesAtExit
.
I think this is a good reference for how to use it.
Java 13 Dynamic CDS boots faster than I expected--Kishida Hatena
In the feeling I tried, it was faster to start by creating a CDS archive normally rather than at runtime. Self-dumped dump truck from Java 10 starts faster than Dynamic CDS-Kishida Hatena
JEP 351: ZGC: Uncommit Unused Memory (Experimental)
Unused memory in ZGC will be released.
JEP 353: Reimplement the Legacy Socket API
The TCP socket API has been reimplemented to support asynchronous processing in Project Loom.
API
Some APIs have also changed.
String
TextBlocks related APIs have been added.
However, as of Java 13, it can be used at any time just by specifying @Deprecated
, but in Java 14, it can be used only with --enable-preview
.
formatted
Make String.format
available as an instance method.
For example
callQuery(String.format("select * from table where id=%d", id));
What was written
callQuery("select * from table where id=%d".formatted(id));
It is convenient to write like. https://bugs.openjdk.java.net/browse/JDK-8203444
translateEscapes
Treat \ n
etc. as escape characters.
Looking at the code, it is confusing with escapes, but the \ n
in the string is converted to a newline.
jshell> var s = "test\\ntest\\n"
s ==> "test\\ntest\\n"
jshell> System.out.println(s)
test\ntest\n
jshell> s.translateEscapes()
$18 ==> "test\ntest\n"
jshell> System.out.println(s.translateEscapes())
test
test
https://bugs.openjdk.java.net/browse/JDK-8223780
stripIndent
Remove the indent.
https://bugs.openjdk.java.net/browse/JDK-8223775
Map.of
has been added in JDK9.
In JDK9 and JDK10, an instance of Map0
when the number of elements is 0, Map1
when the number of elements is 1, and MapN
when the number of elements is 2 or more is returned, andMap.of (). Get (null)
Returned null
.
C:\Users\naoki>java\jdk\jdk-10.0.1\bin\jshell
|Welcome to JShell--Version 10.0.1
|For an overview, type:: /help intro
jshell> Map.of().get(null)
$1 ==> null
jshell> Map.of(1,2).get(null)
$2 ==> null
jshell> Map.of(1,2,3,4).get(null)
| java.lang.NullPointerException thrown
| at ImmutableCollections$MapN.probe (ImmutableCollections.java:779)
| at ImmutableCollections$MapN.get (ImmutableCollections.java:721)
| at (#3:1)
Even when the number of elements is 0 in JDK11, MapN
is used andMap.of (). Get (null)
is nullpo.
C:\Users\naoki>java\jdk\jdk-11.0.1\bin\jshell
|Welcome to JShell--Version 11.0.1
|For an overview, type:: /help intro
jshell> Map.of().get(null)
|Exception java.lang.NullPointerException
| at Objects.requireNonNull (Objects.java:221)
| at ImmutableCollections$MapN.get (ImmutableCollections.java:843)
| at (#1:1)
jshell> Map.of(1,2).get(null)
$2 ==> null
jshell> Map.of(1,2,3,4).get(null)
|Exception java.lang.NullPointerException
| at ImmutableCollections$MapN.probe (ImmutableCollections.java:926)
| at ImmutableCollections$MapN.get (ImmutableCollections.java:846)
| at (#3:1)
In the case of Map.of (1,2) .get (null)
, null
was returned from JDK9 to JDK12.
From JDK13, Map.of (1,2) .get (null)
will also be Nullpo.
Earlier versions have also been fixed in JDK 12.0.2 and JDK 11.0.4.
http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-April/059533.html
It's also interesting to use the equals call instead of requireNonNull for null checking.
http://cr.openjdk.java.net/~smarks/reviews/8221924/webrev.0/src/java.base/share/classes/java/util/ImmutableCollections.java.patch
http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-May/060258.html
A default constructor has been added to the Number
class.
However, the implementation looks like this.
public Number() {super();}
This is unnecessary because it is implicitly defined even if you do not define it. It looks like I added it to fool lint
The new era "Reiwa" has started on May 1, 2019.
Java 8 update, Java 11 and Java 12 also supported Reiwa in format and perspective, but it was not officially defined in Japanese Era.
You can use JapaneseEra.REIWA
from Java 13.
In Java 11, the era name was not decided, so it was displayed as New Era.
jshell> java.time.chrono.JapaneseDate.now()
$1 ==> Japanese NewEra 2-07-21
Since the era name was decided in 11.0.3, it was displayed as REIWA.
jshell> java.time.chrono.JapaneseDate.of(2020,5,1)
$1 ==> Japanese Reiwa 2-05-01
For this, JapaneseEra.NEWERA
and JapaneseEra.REIWA
were also defined, but since it was package private and could not be used from the code, it became public from Java 13 and anyone can use it. became.
There are some changes in rmic.
http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-April/059683.html
[JDK-8217412] deprecate rmic for removal - Java Bug System
It disappears in Java 15.
Recommended Posts