Java 10 new feature summary

Java 10 will come out. There was no Java 9! However, I'm not sure what kind of function it has, so I will summarize it. It's like a brief introduction to the JEPs lined up here. http://openjdk.java.net/projects/jdk/10/

Changes other than JEP, such as the addition of API, are summarized here. Summary of changes other than JEP of Java 10 --Qiita

All the changes are summarized here. 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

286: Local-Variable Type Inference http://openjdk.java.net/jeps/286

Probably the biggest and only change in writing code is local variable type inference.

var str = "123";
var list = List.of("123");

You will be able to write like this. Normally, when you use it when writing code, you often don't know the type of the variable, and it's easy to dislike not knowing the type you knew so far, so I feel that there are few situations that can be used unexpectedly. Is it possible to use it for the time being when the type is explicit to some extent as follows?

var strs = new ArrayList<String>(); //new
var props = (Map<String, List<String>>)input.getAsObject("props"); //cast
var map = Map.of("apple", "Apple",
                 "grape", "Grape"); //Factory or builder

In summary, if the type is written on the right side, it is unnecessary on the left side and var can be used, otherwise var is not used.

However, it is unconditionally convenient in JShell.

The lambda argument is where var seems to work but not.

Stream.of("abc").forEach(s -> System.out.println(s));

Is

Stream.of("abc").forEach((String s) -> System.out.println(s));

Is type inferred, but this is

Stream.of("abc").forEach((var s) -> System.out.println(s));

Cannot be written. Well, it's a local variable type inference, and the lambda argument is not a local variable, so it can't be used. Well, it looks like it can be used, so starting with Java 11, you can use var with lambda arguments as well.

Also, with the introduction of var, the language specifications have changed a bit. As a big thing, var is introduced as a reserved word, not as a reserved word. So you can use var for variable names, method names, package names, etc., but you can no longer use var for class names. In the language specification, Type Identifier is introduced instead of Identifier for types, and the part where the type can be written has been changed from Identifier to Type Identifier.

Also, you can do this.

var anon = new Object() {
    private int a() {
        return 3;
    }
};
System.out.println(anon.a());

By the way

var s = List.of("a", 1);

Compiling code with the -g option causes javac to crash in build 46.

These are ok.

var t = List.of("a");
var u = List.of("a", 1, Optional.empty());
var v = List.of("a", 1, List.of());

Bitterfox has already sent the patch.

296: Consolidate the JDK Forest into a Single Repository http://openjdk.java.net/jeps/296

So, from here on, it doesn't really matter when writing code, so I'll just throw it away. JEP 296 integrates repositories on OpenJDK. It follows the trend of recent single repositories. Until now, getting the source of OpenJDK was like collecting from various repositories with a script, but now you can get the source with a single Mercurial command. I think development will be easier.

As you can see by looking at the JDK9 repositories, each contains 7 repositories. http://hg.openjdk.java.net/jdk9

The old repository remains in JDK10, but it is integrated into master. http://hg.openjdk.java.net/jdk10

And with the integration of repositories, it feels like creating each version repository under the jdk project, which used to be a separate project for each version. http://hg.openjdk.java.net/jdk

304: Garbage-Collector Interface http://openjdk.java.net/jeps/304

We have introduced a GC interface to make the GC independent of the JVM. This increases the modularity of the GC, making it easier to add and remove GCs. Java 11 also includes a nice GC called Epsillon GC (a GC that does not release memory at all), ZGC becomes open source, Shenandoah, etc., so I think that future GC movements will be easier to do.

307: Parallel Full GC for G1 http://openjdk.java.net/jeps/307

The worst case latency in G1GC is to be improved by parallelizing Full GC. G1GC became the default from Java 9 but it seems that the default GC up to Java 8, parallel GC, was doing Full GC in parallel, so the migration can be made smoother.

310: Application Class-Data Sharing http://openjdk.java.net/jeps/310

By making class data sharing (CDS) introduced in JDK5 available for application classes, class metadata can be shared between Java processes, and startup time and memory usage can be improved.

312: Thread-Local Handshakes http://openjdk.java.net/jeps/312

Allow individual thread callbacks to be performed without affecting the safetypoint of the entire VM. It seems that this will improve stack trace acquisition and GC.

313: Remove the Native-Header Generation Tool (javah) http://openjdk.java.net/jeps/313

Since Java 8 can generate C headers for JNI with javac, javah will be removed.

314: Additional Unicode Language-Tag Extensions http://openjdk.java.net/jeps/314

java.util.Locale Expanded support for BCP47 language tags in other APIs. What was supported by calendar ca and number nu in Java 7 will be extended to support currency cu, week start fw, region rg, and time zone tz. ..

316: Heap Allocation on Alternative Memory Devices http://openjdk.java.net/jeps/316

Allows Java object heaps to be placed on other user-specified memory devices, such as NV-DIMMs. Future systems will have a complex memory architecture with memory like 3D XPoint, which will use non-DRAM with different characteristics in addition to DRAM. As an application example, it is considered that a high-priority process uses DRAM, a low-priority process uses NV-DIMM, or NV-DIMM is used for big data or in-memory DB.

317: Experimental Java-Based JIT Compiler http://openjdk.java.net/jeps/317

As a test, enable Graal, a Java-based JIT compiler, on Linux / x64 platforms. Although Graal is the basis of the pre-compilation (AoT) introduced in JDK 9, it can also be used as a JIT compiler to explore the next stage of Java-based JIT.

319: Root Certificates http://openjdk.java.net/jeps/319

As it is, OpenJDK does not have a root certificate by default, and security-important functions such as TLS did not work, so prepare a root certificate to make it easier to develop with OpenJDK and to make a difference with Oracle JDK. It seems.

322: Time-Based Release Versioning http://openjdk.java.net/jeps/322

The version description will be revised in response to the time-based release. It has the following format. $FEATURE.$INTERIM.$UPDATE.$PATCH With a semi-annual release, $ FEATURE will increase by one and $ UPDATE will be 0. $ INTERIM is always 0. A $ UPDATE will be added for maintenance releases one month and four months after the feature release. $ PATCH is not normally used. The next release in March will be October, the release in April will be 10.0.1. The release in July will be 10.0.2, and the release in September will be 11.

These version numbers can be obtained with feature (), ʻinterim (), patch (), ʻupdate () of java.lang.Runtime.Version.

Recommended Posts

Java 13 new feature summary
Java 10 new feature summary
Java 14 new feature summary
Java EE 8 (Jakarta EE 8) New feature summary
Java knowledge summary
Java Generics Summary
Java related summary
java1.8 new features
Java 8 documentation summary
Java 11 document summary
[Summary] Java environment preparation
effective java 3rd summary
Java static [Personal summary]
Java 8 lambda expression Feature
Thread safe summary ~ Java ~
Java Primitive Specialization Summary
Java development link summary
What's new in Java 8
JSF2.3 new function summary
java regular expression summary
What's new in Java 9,10,11
Summary of Java support 2018
Java design pattern summary
Java reserved word summary
Java8 Stream Rough Summary
Summary of revisions (new era) support by Java version
What is Java Assertion? Summary.
[Java] New Thread generation method (2)
[Java11] Stream Summary -Advantages of Stream-
Progate Java (Beginner) Review & Summary
New features from Java7 to Java8
[Java] Summary of regular expressions
[Java] Summary of operators (operator)
Java8 stream, lambda expression summary
Object-oriented summary by beginners (Java)
Java tips --Spring execution Summary
[Java] Summary of for statements
Summary of Java Math class
PrimeFaces 6.0.x New Features Summary
[Java11] Stream Usage Summary -Basics-
[Java] Summary of control syntax
Summary of java error processing
[Java] Summary of design patterns
[Java] New Thread generation method (1)
[Java] Summary of mathematical operations
New grammar for Java 12 Switch statements
Consideration on Java Persistence Framework 2017 (Summary) -1
[For beginners] Summary of java constructor
Java release date and EOL summary
Summary of [Java silver study] package
Java 9 new features and sample code
Summary
Java "pass by reference" problem summary
Java
Summary of object-oriented programming using Java
Try Eclipse 4.7 Oxygen New 30+ / Java 10 var!
[Java Silver] Summary of access modifier points
Summary of in-house newcomer study session [Java]
How to make a Java calendar Summary
Memorandum of new graduate SES [Java basics]
[java] Summary of how to handle char