Summary of changes other than JEP of Java10

Java 10 is finally released today. ~~ Maybe ~~ I think it will be available for download from here ~~. http://jdk.java.net/10/

Here is a summary of the new features in Java 10 that have JEP. Java 10 new feature summary --Qiita

However, there are quite a few changes other than those with JEP. Here, we will summarize the API and other changes that are likely to have an impact on changes other than JEP. Extraction from here. Click here for more information. 109 New Features In JDK 10 - Azul Systems, Inc.

Click here to download OpenJDK JDK 10 GA Release

Click here to download the Oracle JDK Java SE Development Kit 10- - Downloads

API changes

Get process ID

A getPid () method has been added to java.lang.management.RuntimeMXBean to get the process ID.

import java.lang.management.ManagementFactory;

long pid = ManagementFactory.getRuntimeMXBean().getPid();
System.out.println(pid);

By the way, considering readability, it is better not to use var in such a case. It is hard to say that " var is fine because you can see that it is long by looking at the definition ofgetPid ()."

Get version

Java 9 added Runtime.version (), but the Runtime.Version class it takes has changed according to the new versioning. feature (), ʻinterim (), ʻupdate (), patch () have been added, and major (), minor (), and security () have been deprecated. ..

Runtime.Version version = Runtime.version();
System.out.printf("%d.%d.%d.%d%n",
        version.feature(), version.interim(), version.update(), version.patch());

Transfer from Reader to Writer

In Java 9, the transferTo method was added to java.io.InputStream to allow transfer from ʻInputStream to ʻOutputStream, but in Java 10 it was changed to java.io.Reader. The transferTo method has been added so that Reader can also transfer to Writer.

var sr = new StringReader("abc\ndef\n");
var sw = new StringWriter();
sr.transferTo(sw);
System.out.println(sw);

When using such a new, you can see the type by looking at the right side, so I think that var is fine.

Make an immutable copy of List / Set / Map

The copyOf method has been added to java.util.List, java.util.Set, and java.util.Map to make copies of List and so on.

var list = List.copyOf(List.of("aa", "bb", "cc"));

In the case of List, it is an instance of java.util.ImmutableCollections $ ListN, a private class that is also used in List.of. If there are 0 to 2 elements, it will be an instance of a dedicated class such as List0. If it was originally ʻImmutableCollections $ ListN`, as in this example, the given instance will be returned as is. In JDK11, it seems to be unified to ListN. http://hg.openjdk.java.net/jdk/jdk/rev/a14ede52a278

By the way, it is delicate whether copyOf can be received by var.

Optinal / OptionalInt Other orElseThrow ()

ʻOptional Other than that, ʻor ElseThrow (Supplier <Throwable>) is already available. Java 10 added ʻorElseThrow ()with no arguments. Theget () method throws an exception when ʻOptional has no value. Therefore, at the beginning of writing this article, I thought that ʻor ElseThrow ()was unnecessary and omitted it, but in realityget () is properly aware that an exception is thrown. I had to use it, and I realized that I should use ʻor ElseThrow () instead of get (). Perhaps it seems that get () may become Deprecated in the future.

Immutable List / Set / Map generation from Stream

ToUnmodifiableList, toUnmodifiableSet, and toUnmodifiableMap have been added to java.util.stream.Collectors.

List<String> strs = Stream.of("aa", "bb")
        .collect(Collectors.toUnmodifiableList());

It doesn't matter if there are duplicates in toUnmodifiableSet (), and one of them will be selected, but toUnmodifiableMap () will throw java.lang.IllegalStateException if there are duplicate keys.

javax.ButtonModel#getGroup()

Swing also changed! !! !!

Other changes

{@ Summary} JavaDoc tag

JavaDoc summaries can now be written in multiple lines using the {@Summary} tag.

Docker compatible

Until now, even if the JVM was running with Docker, the number of CPUs and memory etc. ignored the Docker settings and returned the number of CPUs and memory size of the platform, but from Java 10 it will read the Docker settings. I did. This had an effect when using Hadoop, Spark, etc. with Docker even if Java was not mainly used, so many people may be grateful.

-d32 Removed -d64

There were switches to choose between the 32-bit and 64-bit versions of the JVM, but these switches are gone as only the 64-bit version is available.

Remove policy tool

It was deleted

Kerberos settings

If there is a file called * .conf in ʻINCLUDEDIR, it will be included in krb5.conf`.

What was mistakenly deprecated is back

XMLInputFactory # newFactory () was incorrectly labeled with @Deprecated, but it has been removed. There is also such a thing.

Recommended Posts

Summary of changes other than JEP of Java10
Summary of Java support 2018
[Java] Summary of regular expressions
[Java] Summary of operators (operator)
Summary of Java language basics
[Java] Summary of for statements
Summary of Java Math class
[Java] Summary of control syntax
Summary of java error processing
[Java] Summary of design patterns
[Java] Summary of mathematical operations
Spring Framework 5.0 Summary of major changes
[For beginners] Summary of java constructor
Summary of [Java silver study] package
Summary of object-oriented programming using Java
[Java Silver] Summary of access modifier points
Summary of in-house newcomer study session [Java]
[java] Summary of how to handle char
[Java] Personal summary of conditional statements (basic)
[Java] [Maven3] Summary of how to use Maven3
Java Summary of frequently searched type conversions
Summary of Java Math.random and import (Calendar)
Java knowledge summary
[java] Summary of how to handle character strings
Java Generics Summary
Summary of Java environment settings for myself [mac]
[Java] Summary of how to abbreviate lambda expressions
Java related summary
Changes in Java 11
Java 8 documentation summary
Example of using addition faster than using StringBuilder (Java)
Java 11 document summary
[Java] Overview of Java
[Java] Basic summary of Java not covered by Progate ~ Part 1 ~
This is convenient! Summary of popular Java library + α
[Java Silver] Summary of points related to lambda expressions
Summary of revisions (new era) support by Java version
[java.io] Summary of Java string input (InputStream, Reader, Scanner)
Summary of knowledge required to pass Java SE8 Silver
Summary of Java communication API (1) How to use Socket
Summary of Java communication API (3) How to use SocketChannel
Summary of Java communication API (2) How to use HttpUrlConnection
Summary of how to implement default arguments in Java
Summary of file reading method for each Java file format
Predicted Features of Java
Java 12 new feature summary
[Java] Significance of serialVersionUID
Changes from Java 8 to Java 11
effective java 3rd summary
Review of java Shilber
Java 13 new feature summary
Summary of OpenJDK sources
Summary of strong parameters
java --Unification of comments
Summary of jar files
Java static [Personal summary]
History of Java annotation
Summary of information security
Summary of using FragmentArgs
java (merits of polymorphism)
Thread safe summary ~ Java ~