New features and prospects of JDK 15 and Java 15

With the cold winter of 2020 and the rampant COVID-19, JAVA has ushered in the JAVA 14 that has not been long before. Since the release of Java 9 in 2017, the release version of Java has kept up with the pace of agile development. The release rhythm of Java platform has changed from the main version every three years to the function release every six months. Now, new version features are released in March and September every year.

March is over. Is September far behind?

In Java 14, the final version of switch is launched and NVM is supported.

Today, this article will look forward to the new features that Java 15 will bring us.

Overall, five JEPs will be submitted to Java 15.

what? You ask me what JEP is?

The full name of JEP is JDK enhancement proposals. To put it simply, it is like proposals for Java improvement. These proposals will be added to the specific version of JDK at the right time and place.

Let's look at the contents of the five proposals:

JEP 371: Hidden Classes

Usually, when we use large frameworks or lambda expressions, many classes will be generated dynamically. Unfortunately, the standard API for defining classes: classloader:: defineclass and lookup:: defineclass cannot distinguish whether these classes are dynamically generated (run-time generated) or statically generated (compiled generated).

In general, dynamically generated classes have a shorter life cycle and lower visibility. However, the existing JDK does not have this function.

All proposals with hidden classes can be defined as hidden classes when generating dynamic classes through hidden classes, whether JDK or the framework outside JDK, so as to more effectively control the life cycle and visibility of these dynamically generated classes.

JEP 372: delete nashorn JavaScript engine

Actually JDK scripting. Nashorn and JDK scripting. nashorn. The two shells have been marked as deprecated in jdk11. Just delete them in jdk15.

JEP 377: the new garbage collector ZGC is officially launched

Z garbage collector (ZGC) is a garbage collector introduced in Java 11, but it has always been an experimental version. In JDK 15, it is finally going online.

ZGC is a redesigned concurrent garbage collector, which can greatly improve the performance of GC.

JEP 378: text blocks standardization

Text blocks is the first JEP 355 that appears as a preview function in JDK 13. Then the second version JEP 368 appears in JDK 14. Finally, there can be a final version in JDK 15.

Text block is a multi line string text, which avoids the need of most escape sequences and automatically formats the string in a predictable way.

HTML example

Traditional way:

String html = "<html>\n" +
              "    <body>\n" +
              "        <p>Hello,world</p>\n" +
              "    </body>\n" +
              "</html>\n";

Text block mode:

String html = """
              <html>
                  <body>
                      <p>Hello,world</p>
                  </body>
              </html>
              """;

sql example

Traditional way:

String query = "SELECT `EMP_ID`,`LAST_NAME` FROM `EMPLOYEE_TB`\n" +
               "WHERE `CITY` = 'INDIANAPOLIS'\n" +
               "ORDER BY `EMP_ID`,`LAST_NAME`;\n";

Text block mode:

String query = """
               SELECT `EMP_ID`,`LAST_NAME` FROM `EMPLOYEE_TB`
               WHERE `CITY` = 'INDIANAPOLIS'
               ORDER BY `EMP_ID`,`LAST_NAME`;
               """;

JEP 379: new garbage collector Shenandoah Online

Like ZGC, Shenandoah introduced JEP 189 in Java 12 with experimental features. Now I finally want to become a regular in Java 15.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>