Groovy Improvements in IntelliJ IDEA 2018.2

IntelliJ IDEA 2018.2 comes with support for Groovy 2.5 features, and for the current draft of the Groovy 3.0 specification (note that Groovy 3.0 is in alpha and functionality may change in the future).

Continue reading

Posted in New Features | Tagged , | Leave a comment

Spring and Spring Boot Improvements in IntelliJ IDEA 2018.2

As usual, the latest version of IntelliJ IDEA comes with even better support for developers using the Spring framework.

Continue reading

Posted in New Features | Tagged , , , | Leave a comment

IntelliJ IDEA 2018.1.6 is released!

Even though the release of IntelliJ IDEA 2018.2 is not so far away, we have not forgotten about IntelliJ IDEA 2018.1. And today we are ready to release the sixth bug-fix update for IntelliJ IDEA 2018.1. Get the new IntelliJ IDEA 2018.1.6 from our website or via Toolbox App.

IntelliJ IDEA 2018.1.6 comes with a bunch of bug fixes, with the following worth mentioning:

  • Fixed a throwable exception: unable to get stub builder: IDEA-181227.
  • Fixed the issue that caused the go to Class/File/Symbol pop-ups to leak via the native window and focus traversal policy: IDEA-192184.
  • Сorrected the treatment of a Spring @Nullable annotation: IDEA-182842.

Check out the release notes for the full list of improvements!
Share your feedback with us via issue tracker, discussion forum, Twitter!

Happy Developing!

Posted in Releases | Tagged , | 9 Comments

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 , | 6 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 , | 1 Comment

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 , , | 6 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 , | 5 Comments