Development Status of the new Java version and the new java version

Source: Internet
Author: User

Development Status of the new Java version and the new java version

Java 9 was officially released in September 21, and Oracle announced that it would adjust the release cycle of the new Java version to every six months. Currently, the development of the new Java version has officially entered the stage. According to the published news, the next version of Java is expected to be released in March 2018, and the version number will be 18.3. The features planned to be added include JEP 286 and 296.

According to discussions on the reddit site, the first update is JEP 296, And Valhalla is expected to be added soon. The OpenJDK homepage shows that JEP 18.3 and 286 are required in version 296.

JEP 296 combines JDK Repository Forest into a warehouse to reduce the cost of managing a large number of warehouse groups. According to InfoQ, the merger of the Repository group has been completed. These software repositories have been split and generated in the history of OpenJDK development. They will continue to exist in OpenJDK 9 and earlier versions. Before this merge operation, OpenJDK split into multiple different Mercurial software warehouse groups, which caused many problems, for example, you cannot fix vulnerabilities in multiple software repositories in an atomic manner ). After OpenJDK is merged, only one software warehouse is available and copied to three development lines. To simplify repository management, JDK also creates a tool for moving changes between merged and unmerged versions.

JEP 286 proposes to introduce the type inference of local variables in Java. This JEP was introduced in 2016. InfoQ once reported the JEP overview and related developer survey results. The purpose of this JEP is to reduce the ritual content related to Java code, improve the experience of developers, and ensure the static nature of the Java language. It will reduce unnecessary variable type declarations when developers declare local variables. If this JEP is implemented, you can use the following method when declaring local variables:

var list = new ArrayList();  // infers ArrayListvar stream = list.stream();          // infers Stream

This statement can only be used for local variables with initializer, enhanced indexes in for-loop, and local variables declared in traditional for-loop. It cannot be used in method declaration, constructor declaration, method return value, field, catch statement, or other types of variable declaration.

For the type inference of local variables, both the language in the JVM system and other languages provide certain forms of support, such as C ++ (auto), C # (var) scala (var/val) and Go (declared through: = ). As for whether to use var as the keyword, or use let or auto similar to C/C ++ as the keyword, there was a survey for developers before. About 84% of the answers indicate that it is appropriate to use the keyword var to define variable content. Only a few percent of respondents suggest using auto. According to Brian Goetz, a Java language architect, this function should use the keyword var.

The usage of this feature is discussed in reddit. Some people say that this feature is rarely used even in languages that support the "auto" syntax, because some people want to see the type of the variable at a glance. Some people also think that var has a space for its application. In a small code block, it is okay to instantiate an object directly with it. If you want to explicitly declare the type as the return value of the method, Java's type inference does not support the return value of the method, so you don't have to worry about it. If a function or code block is long, we do not recommend using var and rewrite the code in a timely manner. Time and experience will make us more clear about when to use new features. Just like when Optional was launched, it took some time to determine the applicable scenarios of its recommendation.

The Valhalla project contains some interesting JEP, including Value Type, implementation of generic functions for the original Type, and enhanced volatile, it is expected that the content will be added to the new version.

 

Join the study exchange group 569772982 to learn and exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.