DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Support for Java 9 in IntelliJ IDEA

Support for Java 9 in IntelliJ IDEA

Support for Java 9 has come to IntelliJ IDEA! Check out this post to find out some of the Java 9-specific features that have been included.

Trisha Gee user avatar by
Trisha Gee
·
Jul. 13, 17 · Java Zone · News
Like (8)
Save
Tweet
7.59K Views

Join the DZone community and get the full member experience.

Join For Free

As Java 9 continues to evolve, so does IntelliJ IDEA’s support for it. This screencast shows the new features to support Java 9 development in the upcoming IntelliJ IDEA 2017.2 release.

In the rest of this blog post, we’ll break down what’s in the video and talk about each feature.

As you’d expect, a lot of the improvements are to support the Java Platform Module System. One of the new features to help developers getting up to speed with Jigsaw and Java modularity is the new Java Module Diagram. This diagram shows the modules you’ve defined in your project in green; any automatic modules, (those modules that are dependencies on traditional jar files) in blue; and any JDK modules in yellow.

Java Module Diagram

You’ll notice there are two different types of lines in the diagram, the thick blue lines show "requires transitive," the thinner black lines are standard "requires" dependencies.

These diagrams give a clear picture of which modules have been defined and which modules they depend upon, and can help you either to create a clean separation when creating a modular system, or simply visualize what’s going on with the new Java Platform Module System.

If you are working with Java 9 modules, you’ll see code completion and generation has been improved for the module-info.java file. For a start, the generated module name more closely matches the IntelliJ IDEA module name.

Error in open module

Errors and warnings and their suggested fixes have also been improved. For example, if you try to use opens in a module that is already open, the error is clear and you can opt to either remove the opens statement or change the module so it’s no longer open.

Open module fixes

Duplicate opens or provides statements are detected and can be deleted or merged.

Duplicate opens statement

You can also use find usages on a module name to locate other places that use this module, including JDK modules that use it.

Find module usages

And, of course, you can refactor module-info files, for example using rename.

Project Jigsaw has a wider impact than just allowing you to create your own modules. Modularity impacts the visibility of packages, so classes that were previously accessible may not be anymore. This even includes reflection. IntelliJ IDEA’s inspections can help locate reflection code that tries to access modules that are not on the module path, and offers suggestions to fix the problem.

Reflection warnings

There are a few new inspections to help migrate code to Java 9. There’s a section under the Java language level migration aids inspections for Java 9.

New inspections

The first inspection highlights module-info files that require automatic modules – automatic modules are useful during migration to Java 9, but over time code should be migrated to use true modules. By default, this only highlights transitive dependencies, as this means your code is exposing automatic modules to other modules.

Using unmodifiableSet

The second inspection points out places where we can use the new Collections Factory Methods. For example, if we’re creating an unmodifiableSet, this verbose code can be enormously simplified in Java 9. We can also convert unmodifiableList to the new syntax too.

Using Set.of

There’s one final inspection to help us make use of new Java 9 features. If your code has while loops that wait for a particular value to change, they can be updated to add the new onSpinWait hint, which allows the runtime to potentially optimise this operation.

Suggestion to add onSpinWait

Finally, IntelliJ IDEA is also ready for the updates to Javadoc in Java 9. Generated Javadoc is now searchable, letting developers search for classes, methods, or keywords in the documentation. To make the most use of this, you may want to add an index tag to your documentation to provide keywords to the search.

intellij Java (programming language)

Published at DZone with permission of Trisha Gee, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • CockroachDB and Deno: Combining Two “Quick to Start” Technologies
  • Deriving Ideal Indexes: A Guide
  • The Differences You Should Know About Java and Python
  • Conceptual Architecture — Conversational AI/NLP based Platform

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo