What's new in Java 9,10,11

Introduction

Hi, this is @chan_kaku! This time, I will explain the APIs and functions added in Java 9 to 11 for those who are thinking about migrating from Java 8 to Java 11.

Java9 Please refer to here for new features of Java9.

Modular system

In Java 9, there was a project called Project Jigsaw. Details can be found at the link below About Project Jigsaw In other words, the following four points were the goals of this project

Make it easier for developers to construct and maintain libraries and large applications

Facilitates maintenance of libraries and large applications

Improve the security and maintainability of Java SE Platform Implementations in general, and the JDK in particular

Improved security and maintainability of the Java SE platform

Enable improved application performance

Improved application performance

Enable the Java SE Platform, and the JDK, to scale down for use in small computing devices and dense cloud deployments.

Java SE platform and JDK can be scaled down for use in low-performance computing devices and dense cloud deployments

To solve these problems, Java 9 introduced a modular system.

The module system is explained in detail in Around here.

In other words, when using the public and protected members of another module (library), or when using the public and protected members for another module, it is necessary to prepare a file called module-info.java. This module system makes it easier to understand module dependencies and hierarchies than ever before.

Java10 The new features of Java 10 are summarized in here. I will pick up the functions that I personally care about

Type inference

JEP 286: Local-Variable Type Inference

This is a type inference function for local variables

sample.java


var list = new ArrayList<String>();  // infers ArrayList<String>
var stream = list.stream();          // infers Stream<String>

In Java, if you use this var for anything, you will not know the type well, so I do not have the impression that you use it so often, but you can use it if the type is specified on the right side as described above. Isn't it?

Java11 As usual, the new features of Java 11 are summarized in here. I would like to pick up some of them.

Nested class access restrictions

JEP 181: Nest-Based Access Control

It is described here that the private access of the nested mate is restricted as the access rule of the JVM. By the way, the nested mate that came out here is defined as follows

A field or method R is accessible to a class or interface D if and only if any of thefollowing conditions are true: ・ R is private and is declared in a different class or interface C, and C and D, are nestmates.

This is the same for the user, but when I use bytecode, I read a method that I didn't understand until now, and now it's what I intended. It's like that

HTTP client

JEP 321: HTTP Client (Standard)

This is said to support Modan APi, HTTP2, WebSocket, Reactive.

Type inference

JEP 323: Local-Variable Syntax for Lambda Parameters

This says that type inference, which was also explained in Java 10, can now be used as a parameter for lambda expressions.

Finally

Various features have been added in Java 9 ~ 11, but personally, I have the impression that it's okay if you hold down the areas introduced here. If you don't know about this feature, please comment!

Recommended Posts

What's new in Java 8
What's new in Java 9,10,11
Let's keep this in mind What's new in Java 9
What's new in Apache Camel 2.19.0
Partization in Java
Changes in Java 11
Rock-paper-scissors in Java
Pi in Java
FizzBuzz in Java
I tried the new era in Java
[java] sort in list
Read JSON in Java
Interpreter implementation in Java
Java 12 new feature summary
Rock-paper-scissors app in Java
Constraint programming in Java
Put java8 in centos7
NVL-ish guy in Java
Combine arrays in Java
"Hello World" in Java
Callable Interface in Java
Java 13 new feature summary
Comments in Java source
Format XML in Java
Simple htmlspecialchars in Java
Boyer-Moore implementation in Java
Hello World in Java
Use OpenCV in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Heapsort implementation (in java)
Zabbix API in Java
ASCII art in Java
Compare Lists in Java
Express failure in Java
Create JSON in Java
Date manipulation in Java 8
Java 10 new feature summary
Use PreparedStatement in Java
Java 14 new feature summary
Parallel execution in Java
Initializing HashMap in Java
[Java] New Thread generation method (2)
Read binary files in Java 1
Avoid Yubaba's error in Java
[Neta] Sleep Sort in Java
Edit ini in Java: ini4j
Java history in this world
Let Java segfault in 6 lines
Try calling JavaScript in Java
Try developing Spresense in Java (1)
I made roulette in Java.
New features from Java7 to Java8
Create hyperlinks in Java PowerPoint
Implement two-step verification in Java
Refactoring: Make Blackjack in Java
Write flyway callbacks in Java
Topic Analysis (LDA) in Java
Importing Excel data in Java 2