Java 9 officially released, Final landing Jigsaw project

Source: Internet
Author: User
Tags java se

September 21, the long-awaited Java 9 is finally officially released, this article with you to quickly review the IntelliJ idea of Java 9 support, and understand the IntelliJ of the 2017.3 in the Java 9 for the introduction of new features.

Jigsaw and Jpms

Referring to Java 9, the biggest feature is the modular system of the core Java platform under the Jigsaw project (Jpms,java Platform module systems). The Jigsaw itself is an ambitious project that aims to improve the Java SE platform to accommodate computing devices of different sizes, improve its security, maintainability, performance, and simplify the development and maintenance of various class libraries and large applications, including the modularity of the JDK itself.

IntelliJ idea supports a modular system of Java platforms with many features.

First, developers can easily create a Module-info.java file for the IntelliJ idea module:

This gives the basic structure of the module declaration, including the module name that matches the name of the IntelliJ idea module. When the developer encodes the Module-info.java file, the code is highlighted.

If the developer runs the code from the module with the Module-info.java file, IntelliJ idea will automatically use the-p parameter (the module path) instead of the-classpath.

IntelliJ idea also provides quick fixes for common problems that occur when migrating code to JPMS, such as adding "require" directives.

or automatic detection of duplicate instructions and other errors that can be fixed.

Developers can also create module diagrams with IntelliJ idea to visualize the modules they are using. In addition, you can see the JDK module, the module you created, and so on, as shown in.

When developers start using modularity, these charts can be useful to help developers understand which modules are being used and the architecture of the modules, and even directly navigate to the specific module code.

IntelliJ idea will also help migrate the code to Java 9. For example, users can highlight dynamic modules that are used.

This means that developers can see something that is not part of the Java 9 module. This is important because these dynamic modules may change over time.

Learn more about the basic support for modules in IntelliJ idea, as well as module diagrams and other quick fixes.

A convenient factory approach

Java 9 introduces a number of small API changes that make it easier for developers. One of them is to simplify the creation with a fixed content collection. The IntelliJ idea can be found in the change function.

As shown, the highlighted code is the result of simplifying the factory method using Java 9.

Thread.onspinwait

Java 9 provides hints for the JVM. Specifically, if the developer's code waits in a loop, then thread.onspinwait can be used to let the runtime know. IntelliJ idea Find code, add this feature may be used to.

Enhanced deprecation

There is a seemingly small feature in Java 9, but it can make it easier for developers to understand the impact of their code, which is enhanced deprecation. Now, the @Deprecated tag supports two useful new properties: "Since" and "Forremoval". A new check was made in IntelliJ idea 2017.3 highlighting the use of code that has been marked as "Forremoval".

If you have already turned on this check and set it to warning (this is the default), then the content labeled "Forremoval" is displayed in the IntelliJ idea with the red bar instead of the previous black.

Jshell Tools

Java 9 First provides Java's REPL (Read-eval-print-loop, read-in-evaluate-print-loop) functionality, called the Jshell tool. Its purpose is to simplify the implementation of prototypes in the form of instant results and feedback, and to help us explore the options available for languages when coding. Users can run REPL from the command line or from a terminal in IntelliJ idea. In addition, the IntelliJ idea 2017.3 has a basic console that can be used from within the IDE Jshell, similar to Groovy console.

Developers can use the console to try code snippets, or choose a module path to run this code.

This feature is currently available only in 2017.3 EAP.

No additional support is required

There are many new features in Java 9, including changes to the Streams API, optional additional functionality, private methods on the interface, and so on.

If the project SDK is set to Java 9, then these new methods are available during encoding.

In addition, you can use the IntelliJ idea common feature to dig up some Java 9 features. For example, generate HTML 5 Javadoc by adding a flag when generating a document.

Developers can even use IntelliJ idea to create multi-release JAR files. This may be the best choice for building tools such as Gradle, Maven, or Ant, which may be updated in the IntelliJ idea blog in the future.

Finally, Oracle announces that it will be released in the future at every six-month rhythm! This means that Java 9 is the last release of the "Keystone" feature-driven version. Oracle also says that Java 8 is still available and its support time will continue until 2022.

Source: CSDN

Java 9 officially released, Final landing Jigsaw project

Related Article

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.