IntelliJ IDEA 2018.2 Release Candidate is here!

We are getting closer and closer to the release date, and we’re happy to announce that the first release candidate for the upcoming IntelliJ IDEA 2018.2 is ready to download!

IntelliJ IDEA 2018.2 RC comes with loads of small yet very useful Spring Integration 5.x improvements. We’ve added support for the Spring Integration annotations such as: @BridgeFrom and @BridgeTo annotations, along with support for the @EnablePublisher annotation. Continue reading

Posted in Release Candidates | Tagged , | 11 Comments

Java Annotated Monthly – July 2018

This month’s annotated monthly has a nice wide selection of reading for you to take to the beach, including chunky sections on Community and Culture, since it’s not always about lines of code.  Or, if you actually are going on vacation, you could just leave all this alone for a while and recharge your batteries. I suggest the latter, although that’s a more difficult proposition if you have kids. You might already be looking forward to going back to work…

JavaAnnotatedMonthly@2x

Continue reading

Posted in News & Events | Tagged , | 2 Comments

IntelliJ IDEA 2018.2 Beta 2 is available!

As we race towards the finish line, IntelliJ IDEA 2018.2 is being made more and more stable. It’s the perfect time to try out IntelliJ IDEA 2018.2 Beta 2.

This last week we were mostly working on improvements for the recently added features. You can take a look at the latest changes in our release notes.

Continue reading

Posted in Beta Releases | Tagged , | 4 Comments

Updated Inspections and Intentions in IntelliJ IDEA 2018.2

We’ve talked about a lot of the changes in IntelliJ IDEA 2018.2 here in the blog, such as the improved data flow analysis and advanced contract annotations. In this post we’re going to look at pretty much all the other updates to inspections and intentions.

Continue reading

Posted in New Features | Tagged , | 6 Comments

IntelliJ IDEA 2018.2 Goes Beta

IntelliJ IDEA 2018.2 Beta is ready for download! It’s the perfect time to try out all the new features in the upcoming v2018.2: MacBook Touch Bar support, Java 11 support, breakpoint intentions, Spring Boot enhancement, VCS improvements, and more.

800x400_blog@2x_preview (1)

Continue reading

Posted in Beta Releases | Tagged , , | 7 Comments

Improved Data Flow Analysis in IntelliJ IDEA 2018.2

IntelliJ IDEA gives warnings in the editor if it detects suspicious code based on an analysis of data flow.  In IntelliJ IDEA 2018.2 we can now see information known about a particular symbol.  For example, if a number of instanceof checks have been performed against a parameter, pressing Ctrl+Shift+P twice shows us which types this value may be:

Show data flow information

If we do this with an Optional value, we can see the value is known to be present if, for example, an ifPresent() check has already been done:

This analysis can show really useful information about known values, as you can see from this example with an int value:

Data flow info for ints

Data flow analysis is smarter with array values.  IntelliJ IDEA can now show the possible values from an array if the array was statically initialized. For example, if we have an array containing the number of days in each of the months of the year, and some logic to validate whether a given date value is valid, we can see which values are possible at each stage of the validation:

IntelliJ IDEA 2018.2 also knows if a collection was initialized as an empty collection, and can highlight errors caused by accessing elements that don’t exist:

data-flow-06

Data flow analysis also supports more math operations than before, like division and right-shift.

IntelliJ IDEA 2018.2 can work out if a method returns an immutable value, or an immutable view of a value.  So if, for example, a method returns a list wrapped in Collections.unmodifiableList(), the gutter annotation icon will show that this method has an inferred annotation of @UnmodifiableView, since unmodifiableList returns a view onto a list that cannot be altered.

data-flow-04

This means that if a modifying method is called on the result of this method, IntelliJ IDEA can warn us that this is probably incorrect:

Warning on adding to unmodifiable collection

Also new is the ability to look inside streams created using Stream.of() to work out if downstream operations are logical. If, for example, we create a Stream of Optional values where all the values are known to be present, IntelliJ IDEA will point out that a call to check to see if isPresent is true on all the Optional values will always be true, and can therefore be simplified.

Show Optional information

Because of this increased intelligence, there will also be no warning that the call to get needs a preceding call to isPresent. Note that this feature only works for up to three values inside the Stream.of call.

Smarter warnings are also available for Hamcrest matchers, so when using Hamcrest inside tests we’ll see fewer instances of warnings, for example when calling get on Optional.  Similarly we’ll also see fewer incorrect “may produce NullPointerException” warnings on Nullable values.

Data flow analysis now supports checks using isAssignableFrom and isInstance, so we see fewer false positives and more useful warnings:

Knows about isInstance and isAssignableFrom

Finally on this topic, IntelliJ IDEA 2018.2 has increased support for constant evaluation of simple methods, meaning that if certain Math or String methods are called with constant values, IntelliJ IDEA can warn us that certain conditions will always or never be true:

Smarter static analysis

The methods that are supported on String are: contains, indexOf, startsWith, endsWith, lastIndexOf, length, trim, substring, equals, equalsIgnoreCase, charAt, codePointAt, compareTo, replace, valueOf.  On Math: abs, sqrt, min, max

In summary, IntelliJ IDEA 2018.2 is even smarter about showing us where our code can be simplified or where possible bugs may be lurking, making it easier to write correct and readable code.

Posted in New Features | Tagged , | Leave a comment

Java 11 in IntelliJ IDEA 2018.2

The next version of Java is due out in September, and IntelliJ IDEA 2018.2 is ready for it.  The main code feature in Java 11 is Local-Variable Syntax for Lambda Parameters – Java 10 gave us the ability to use the var keyword for variables inside methods, now Java 11 lets us use this in lambda expressions:

At first glance, although this removes the type information from:

it’s actually not very compelling when you consider Java 8 already let us remove the type information altogether:

But one of the cases where we might want to use var instead of the full type is if we wanted to apply an annotation to the parameter.  Annotations require us to declare the full type:

With the ability to use var on parameters in a lambda expression, this can be shortened in Java 11 to:

IntelliJ IDEA supports this change as you’d expect, allowing the var keyword in the lambda. But IntelliJ IDEA 2018.2 also helps migrate the code to this updated syntax.  If, for example, you were using annotations in a lambda expression, the inspection for removing the “redundant parameter types” will replace the types with var.

Along with updates for the use of var in Java 11, IntelliJ IDEA 2018.2 also has some improvements for working with var. Holding down Ctrl/ and hovering over the var keyword will show the type of the variable:Var type

Like any other type, we can click here and navigate to the declaration, or we can use Ctrl+B/B to navigate to the declaration via var. We can also use Quick Documentation (Ctrl+Q/F1) or Quick Definition (Ctrl+Shift+I/⌥Space) on var to see the type.

It’s important to remember when working with this new syntax that all relevant type information needs to be on the right of the equals sign since the left side no longer declares the type. There are two inspections that have been updated to reflect this.

Firstly, IntelliJ IDEA 2018.2 understands that while sometimes an initializer is not required for a variable with an explicit type, variables created with var will use an initial value to determine the type.  Therefore any “redundant initializer” warning that applies to explicit type variables is not shown for var:

Similarly, the removal of an array type is not suggested for var since it’s required:

No misleading warnings

In summary, IntelliJ IDEA 2018.2 is not only able to help when using Java 10 features, it’s ready to help us start coding with Java 11 before it’s even released!

Posted in Releases | Tagged , | 8 Comments

IntelliJ IDEA 2018.2 EAP 6: Docker Improvements and more

Another week, another IntelliJ IDEA 2018.2 EAP build! Download and give this new EAP build a thorough try.

Docker improvements

We’ve made several improvements in the upcoming IntelliJ IDEA 2018.2 with the Docker integration. Now you can specify the base directory for executing a Docker build command for a dockerfile. We’ve just added a new “Context folder” field in the Docker run configuration. By default, the Context folder field is set to a parent folder of a specified dockerfile.

image1

 

Continue reading

Posted in EAP Releases | Tagged | 12 Comments

IntelliJ IDEA EAP 5: Dark Window Headers on macOS, Browse Repository at Revision, and more

Today we have a new IntelliJ IDEA 2018.2 EAP build for you to try. You can download it right now from the website, update to it via Toolbox App, or use patches for the in-product update if you’re using previous EAP build.

User Interface

How about making the Darcula theme even darker? Well, if you are on a macOS you can now darken the IntelliJ IDEA title bars, just go to Preferences | Appearance & Behavior | Appearance and enable the Use dark window headers option.

image3

Continue reading

Posted in EAP Releases | Tagged | 11 Comments

IntelliJ IDEA 2018.1.5 is released!

The IntelliJ IDEA 2018.1.5 update is available for download! Get the update from our website, or via Toolbox App.

This update fixes several unpleasant regressions and comes with various bug-fixes. The release notes list all the fixes for this update, but here are some of the most notable improvements worth mentioning:

  • The IDE doesn’t lose focus after using/canceling navigation pop-ups/menus: IDEA-191839.
  • Navigating to class (Сtrl+N /cmd+O) now works correctly again: IDEA-191860.
  • The compiling doesn’t fail for the projects that store .iml externally: IDEA-191328.
  • The IDE doesn’t create a duplicate changelist anymore when parts of the files are submitted in a Perforce changelist: IDEA-191521.
  • You can now evaluate expressions in the lambda body: IDEA-191797.

Feel free to share your feedback in the comments section below, discussion forum, or on Twitter. Please report any problems you find to our issue tracker!

Happy Developing!

Posted in Releases | Tagged , | 15 Comments