Java Annotated Monthly – February 2018

Since Trisha, your regular host, is still away, I’m in charge of updating you on what noteworthy things are going on in the community. My apologies upfront that this time it took a bit longer to compile everything together. Still, I hope you find most of the news and articles fresh and relevant.

Events

In last month on my radar, there was only one event that captured my interest – FOSDEM that took place in Brussels. In case you don’t follow it, FOSDEM is one of the most important events around open source. Since Java is a great part of it, FOSDEM dedicates an entire track to it. Don’t worry if you missed the event. The videos and slides from most of the talks are already available. In case you have time for just one video, my recommendation would be State of OpenJDK by Mark Reinhold.

Also, I should mention here the news that Kotlin Conf 2018 has been announced and will take place on the 3rd-5th of October in Amsterdam. If you use Kotlin or plan to do so, make sure to mark this date in your calendar. In case you’d like to give a talk there, hurry and submit it now.

Java

Oracle published a fresh issue of Java Magazine. The main topic of the issue is reactive programming. If you didn’t watch the topic until now, use this chance to read up on what the whole buzz is about by checking out this issue.

Also, Oracle have updated the Java SE support roadmap. The important news is that the availability of Java SE 8 updates has been extended to January 2019. For non-corporate use, the availability of the updates has been extended to the end of 2020.

Speaking of the Java release cycle, Stephen Colebourne wrote an interesting post on it in regard to Java 9.

Mark Reinhold announced entering the release candidate phase for Java 10. The first release candidate is already out.

If you’d like to refresh your knowledge on what features Java 10 brings with it (beyond the local variable type inference), you may want to read a nice summary about it written by Artem Smotrakov.

In case Java 10 is not cutting-edge enough for you anymore, and you’d like to know what’s coming next, check out the page with the JEPs that target Java 11.

Also, there are a few noteworthy JEP drafts tossed recently: launching single-file source programs (java HelloWorld.java), raw string literals (containing no escaping, supporting newlines), incubating language and VM features (experimental features, see also incubator modules).

Yolande Poirier announced the availability of the new experimental asynchronous API for JDBC as part of OpenJDK 10. You can download the new API and try it out. Your feedback is welcome on the jdbc-spec-discuss@openjdk.java.net mailing list.

If you’d like to learn more about the new HTTP Client API (added with Java 9), there’s a nice official intro with lots of details (including the update on its current status and future).

Meanwhile, Mike Milinkovich shares an update on what’s up with EE4J. Long story short: the code is moving to GitHub; the short-term objective is to ship a Java EE 8-compliant release as quickly as possible. Also, Mike announced that a draft of the EE.next Working Group charter was posted for community review. Comments and feedback are welcomed on the ee4j-community@eclipse.org mail list.

Ivar Grimstad spoke to InfoQ and commented on the status of MVC 1.0 which is going to be integrated into EE4J.

That’s probably all I have got in regards to news and rumors.

Releases

There are at least two notable RCs announced recently: Spring Boot 2.0 and JUnit 5.1. If you’re migrating to JUnit 5 or plan to do so, make sure to read a nice summary of JUnit 5 best practices by Billy Korando.

Android Studio Beta 2 is out and available in the Canary, Dev, and Beta channels. If you are interested, you can learn what’s new in Android Studio 3.1 by checking out this page.

Concerning Android, Kotlin is still taking over conversations in the community. Google announced Kotlin KTX – “a set of extensions designed to make writing Kotlin code for Android more concise, idiomatic, and pleasant”.

Kotlin in turn recently announced the v1.2.20 update. The key highlights are support for Gradle build cache, faster incremental compilation for Android and mixed Java/Kotlin projects, and inlay hints in the IDE.

Articles and videos

Here’s a list of some of the things I came across and found interesting:

Books

In the previous issue, we mentioned the release of the 3rd edition of Effective Java addressing the changes in Java 7, Java 8, and Java 9. If you haven’t read it yet but are curious about what the additions are, read the blog post by Dustin Marx summing them all up.

Tooling

And finally, IntelliJ IDEA 2018.1 EAP is out with tons of improvements and new features.

That’s it for this time. I hope you’ve enjoyed the issue and found at least one or two bits of the news or articles interesting or helpful.

Happy developing!

Subscribe to Java Annotated

Posted in News & Events | Tagged | 2 Comments

Salesforce development plugins, part 2 — JetForcer

Today we’re continuing the series of guest posts from the creators of IntelliJ IDEA plugins for Salesforce (or Force.com) developers. The first post covered Illuminated Cloud 2 plugin.

Please meet the 2nd blog post by Michael Shumenko, co-founder of JetForcer.

Deep dive into Salesforce development with JetForcer

Most people have already heard of Salesforce. This company is behind one of the largest and most well-known platforms for CRM solutions. Today, the company has more than an 18% market share and has surpassed even the giants SAP and Oracle.

Every day, Salesforce developers from all around the world integrate across systems, presenting data in the right place and at the right time to fit their customers’ needs. That’s why an IDE (Integrated Development Environment) should be an unparalleled ally for each developer.

This article is a deep overview of JetForcer – a plugin for Force.com development with JetBrains IDEs, that goal is to get rid of tedious development processes and make the job of developing enjoyable.

Let’s take a closer look at what’s so special about JetForcer.

(Please note that all described features work for Lightning, SOQL or Visualforce as well as for Apex)

Power of Refactorings

As Martin Fauler once said, “Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior”. These techniques are popular in the daily software development process, regardless of the programming language being used.

JetForcer offers a set of powerful refactorings to substantially increase development productivity

Here are a few of them:

– Renaming

1-rename

With rename refactoring, you shouldn’t have to worry about element references. They will be changed automatically in all the places of the entity usage.

– Changing Method Signature

2-change_signature

It will help you to quickly redesign your methods not only by renaming them, but also by modifying the parameter list (adding, reordering, renaming, deleting). Moreover, it makes it possible to change parameter types and default values (that are passed as arguments to the method call).

All usages and overriding method declarations will be updated automatically.

– Extracting Method (Constant, Field, Variable)

3-extract_method

Extracting code to a local variable, constant or method is a simple way to avoid having to copy-paste. Some part of the code (expression or statements) can be moved out and all the duplicated code will be replaced with call the new expression. All the user will be asked is the name of the new member.

A nice trick if you want to forget about the copy-paste action and duplicates in the code.

This is not a full list of all the available refactorings but don’t worry. The ‘Refactor This’ action will always help you find which refactorings can be applied in the current context.

4-refactor_this

Power of Real-Time Error Detection and Quick-Fixes

JetForcer analyzes source code and detects not only syntax but also semantic errors. All the found errors are instantly highlighted in the editor. It not only describes the problem exactly but also suggests quick-fixes. Simply press Alt+Enter and make your choice.

5-quick_fix

Here are just some of the most popular of them:

  • “Create entity from usage” group
    (generates the corresponding symbol based on the usage context)
  • “Change type” group
    (detects incompatible assignments and propose to change one of the assignable types)
  • Implement interface method
    (generate templates for all not implemented methods from interface or abstract class)
  • Cast types
    (detects incompatible assignments and suggest cast type)

Power of Intention Actions and Code generation

Moreover, you may simply redesign or extend your code with the provided ‘intention’ actions or ‘Generate’ action popup. All you need to do is press Alt+Enter or Alt-Insert and choose any action available for the current context.

6-intention_action

Binding a parameter to fields, Introducing a new variable, and generating various code templates is easier than ever before. Just enjoy it.

Power of Code Completion

And last but not the least, for this article, is the editor feature code completion. It helps developers be much faster and more productive.

Following features are available:

  • type-aware completion sorts the suggestion list and shows the most appropriate options on top
  • automatic insertion of paired elements (braces, brackets, quotes etc.)
  • complete current statement (Ctrl+Shift+Enter) action generates necessary tokens (braces, parentheses, semicolons etc.) and places the caret on the position where you can continue typing the next statement.
  • postfix completion helps transform an existing expression into another one based on the postfix you choose. For example the .selfr postfix applied to a sObject name wraps it with an SOQL query.
  • member name completion suggests variables and member names based on the type
  • override or implement methods with completion

… and many other kinds of completion.

7-code_completion

Also, you may want to read the post about the Top 10 features of code completion for Lightning in JetForcer IDE.

Power of Conventional Deploy with VCS-like Approach

The deploy process with JetForcer is powered by ApexVCS – a small integrated VCS, which tracks the difference between the local and server states.

Once changed (edited, created or deleted), a metadata file appears in the Version Control / Local Changes view, so the view will contain just your changed files, which allows you to navigate through them quickly. Then, you may review the differences in the changed files with the side-by-side viewer.

If your org is shared with other developers, you should find ApexVCS conflicts resolving feature useful. After the initial implementation of your feature is deployed, you may prefer to deploy the recently edited files immediately, which is also possible with JetForcer.

8-deploy_apexvcs

You may think of ApexVCS as one of the predecessors of SFDX – consider “sfdx force:source:status” command and the related changes processing.

The Power of Retrospective Debugger, Log Viewer, and Log Manager

In the world of Salesforce, the debug log is a container for all the information and code you need to debug and analyze. But having only information is not enough, no less important is having powerful tools for exploring it.

The following tools are at your disposal:

Log Manager includes:

  • Logs tab with the ability to open and filter existing logs, download new logs from the server, distinguish between new/read/unread logs, and quickly activate expired trace flags or create new ones.
  • Trace Flags tab provides tools for managing Trace Flags and Debug Levels

Log Viewer

  • Viewing the log body as a code execution tree
  • Customizing the font color for tree nodes with certain log events
  • Add some log events to be ignored in execution tree
  • Search text occurrences inside an execution tree
  • Navigate to code sources right from the log viewer just by clicking on an execution node

9-log_viewer

Retrospective Debugger
step-by-step execution with Debug tool window

10-retrospective_debugger

DX Support

Salesforce DX is a new way to build Salesforce applications. It introduces a new type of environment: Scratch orgs. JetForcer has the dedicated SFDX view, which provides functionality for manipulating them.

All the functionality available for a conventional org also available for DX orgs (including Execute Anonymous, Runnings Tests, Exploring Debug Logs etc.).

11-dx_support

Others Features:

Also JetForcer provides a SOQL Editor, Test Framework for running Apex tests, Code Coverage Inspector and much more. Read about them on the plugin website.

Conclusion

I hope this article helps you to better understand how to develop with JetForcer, what the benefits of it are for developers and how much of your time it can save.

Contacts

If you find it interesting, you may download a free 30-day trial version from the official website.
Contacts: To submit feature requests or just report bugs, use the plugin’s issue tracker.
A more detailed tutorial on how to use the plugin along with its features description can be found on the plugin’s site.
Make sure you follow @JetForcer on Twitter to be notified about updates, features, new releases and interesting facts about the JetForcer plugin.

Posted in Featured Plugins, Guest Post, Plugin Development | Tagged , | Leave a comment

IntelliJ IDEA 2018.1 EAP: editor enhancements and more

We’ve just rolled out a new IntelliJ IDEA 2018.1 EAP build. This time it’s all about editor enhancements, improvements in the VCS, and new and updated inspections. To try the latest EAP build right away download it from our our website or update to it via Toolbox App.

With IntelliJ IDEA by collapsing some, of the currently unnecessary blocks or code regions you can get a good overview of your code. Although up until now if a collapsed block contained some errors or warnings, the IDE would display notifications as colored stripes only visible in the scroll bar. These notifications are easy to miss, and they don’t provide any information about where exactly in your code the problem exists.

The upcoming IntelliJ IDEA 2018.1 highlights the folded code regions that contain errors or warnings, and colors such blocks according to their validation status. This give you the ability to quickly find the problem in your code.

image5 Continue reading

Posted in EAP Releases, New Features | Tagged , | 20 Comments

Salesforce development plugins, part 1 — Illuminated Cloud

Today we’re starting a 2-part series of guest posts from the creators of IntelliJ IDEA plugins for Salesforce (or Force.com) developers. The plugins are Illuminated Cloud 2 and JetForcer.

Please meet the 1st blog post by Scott Wells, the developer of Illuminated Cloud. And do not miss the second post that covers JetForcer plugin.

In late 2010, I started leading our product engineering organization in the transition from a traditional on-premise Enterprise-style software model to a modern SaaS-based model. After a short evaluation of existing PaaS, SaaS, and IaaS offerings, we determined that the Salesforce App Cloud Platform-as-a-Service (then called Force.com) would play a key role in our SaaS product architecture.

For our purposes, Salesforce had effectively packaged many of the complex and expensive aspects of a SaaS offering including multitenancy, security, scalability, and pervasive metadata-based configurability. As we started our implementation in earnest, we learned that they had not, however, successfully addressed the all-important aspect of developer tooling.

A Productivity Paradox

One of the key ways that Salesforce has been able to offer a secure metadata-based multitenant platform is by creating their own technologies for business logic (Apex), data access and manipulation (SOQL and SOSL), and presentation tier development (Visualforce and, more recently, Lightning). While these technologies are clearly inspired by more established mainstream development platforms—Apex’s syntax owes a heavy debt to Java, and SOQL is very similar to ORM query languages such as HQL and JPQL—these technologies are explicitly tailored for execution in a secure, governor-limited, multitenant runtime with a very tight-coupling between persisted data and its supporting business logic.

The Salesforce development model is also quite different in that there is no available local runtime execution environment. All source code—along with all other metadata—must be deployed into a Salesforce organization (basically a single tenant “slice” of the Salesforce multitenant runtime) and executed via some type of request. Requests can take multiple forms including UI interactions, API requests, scheduled processes, and unit test execution.

In late 2010/early 2011, very little developer tooling support existed for Salesforce’s programming languages and development model, and what did exist was exceptionally primitive. Salesforce offered the Force.com IDE, an Eclipse plugin with rudimentary syntax highlighting and auto-indentation capabilities as well as the ability to manage the transfer of Salesforce metadata back and forth between the local filesystem and the Salesforce organization. The development community had also implemented plugins and scripts other editors, though features were similarly limited. Having spent over a decade using full IDEs such as IntelliJ IDEA, the existing options seemed primitive and quite limiting. Many of the productivity gains promised by building atop the Salesforce PaaS were being eroded due to the immature state of its tooling.

In Search of a Solution

Developer tooling has always been a passion for me. I’ve always enjoyed creating tools—APIs, scripts, and a few times even plugins for whatever tool I happened to be using at the time—that help increase not just my own productivity but also that of my teammates. As a result, I found myself frequently looking for ways to address this lack of mature tooling for our chosen technology foundation. In the absence of a real code formatter, and with developers applying a myriad of tools to our source files, our code base was becoming utterly chaotic. I tried to adapt existing command-line code formatters to the Apex grammar with varying levels of success. I modeled a custom file type in IntelliJ IDEA for Apex and associated it with the respective source file extensions. I then created external tools for our ant-based command-line metadata deployment and retrieval scripts and added them to the keymap. We could now work in the same IDE we used for Java development, albeit without even simple IDE features such as code completion, a formatter, or reference navigation. It was an improvement, but it was far from a true IDE for what was becoming nearly half of our code base.

A Solution Found

In early 2013, I found myself with some downtime and used it to explore the IntelliJ IDEA plugin SDK, specifically the notion of custom language plugins. Salesforce does not currently publish grammars or language specifications for Apex, SOQL, SOSL, or their presentation tier expression languages. I started by creating a custom grammar for Apex based primarily on the published grammar for Java 5, adding and removing rules based on the differences between Apex and Java. In short order I had a very simple plugin that could effectively replace the custom file type for syntax highlighting, very simple formatting, and keyword completion. However, as it’s prone to do, life got in the way and the project was shelved. A little over a year later I decided to revisit the project. Over the next several months I steadily added features to the plugin including a structure view, code folding, simple identifier code completion, and simple reference injection and navigation. I shared the plugin with my team, and we began to use it as our primary Salesforce development tool.

In late 2014, a few people asked whether they might contribute to the project. This spurred an unexpected internal debate over whether I might instead want to shape the plugin into a commercial offering. After a brief period of introspection and discussion with my family and friends, I decided to pursue the commercial direction. Little did I know how much work that would require, and in particular just how much of that work would have absolutely nothing  to do with writing code. Nor could I have known how incredibly rewarding it would be to create something that can so positively impact developers’ day-to-day work.

In June 2015, I released Illuminated Cloud. In the two-and-a-half years since the initial release, I’ve continuously enhanced the feature set based on both my own priorities as a daily user of the product and the incredible community feedback received via the public issue tracker, discussion groups, direct email contact, and in-person interactions at industry conferences and regional user group meetups. I’ve received enthusiastic support from both Salesforce and JetBrains as I’ve integrated key features of the former into the corresponding first-class plugin SDK extension points exposed by the latter. Illuminated Cloud has been enhanced to support new Salesforce technologies such as Lightning, a presentation tier technology, and Salesforce DX, a developer experience platform (and philosophy).

The implementation of Illuminated Cloud has presented many technical challenges. Not only are there no published grammars or language specifications for Salesforce’s languages, but there is also no formal SDK for Apex. In fact, each organization has a unique SDK based on its enabled features and customizations. To overcome this omission, at the heart of Illuminated Cloud is the Offline Symbol Table, a high-fidelity, organization-specific SDK for Salesforce development generated using the Salesforce APIs with extensive tweaks and corrections based on other resources, both documented and undocumented. Without the Offline Symbol Table, it would be virtually impossible to implement the pervasive real-time expression type inference which is so critical to IDE features such as contextually-aware code completion, reference tracking and navigation, integrated API documentation, refactoring, and real-time static code analysis.

The reception to Illuminated Cloud by the amazing Salesforce developer community has been nothing short of incredible and is easily my favorite aspect of this entire endeavor. The feedback I receive from users, both positive and critical,  is invaluable in the ongoing evolution of the product’s feature set. As someone with a passion for developer tooling, this experience has truly been a dream come true.

The Next Generation

Since starting Illuminated Cloud, my end goal has always been to minimize the feature gap between IntelliJ IDEA for Java development and Illuminated Cloud for Salesforce development. The first major version of the product included contextually aware code completion for all of Salesforce’s languages, pervasive reference tracking and navigation, powerful live templates for Apex and SOQL, integrated unit testing and code coverage, ad hoc Apex and SOQL script execution, an integrated log viewer, a log-based post-mortem debugger, integrated API documentation, and much more. However, it was still lacking many of the modern features that make tools like JetBrains’ IDEs seem nearly magical—in particular refactoring, real-time static code analysis and automated fixes, intelligent code generation, and type inference-based code completion. I decided that those features would form the structure of the second major version of the product.

In December 2017, I released Illuminated Cloud 2 with all of the features of Illuminated Cloud plus:

  • WebStorm support – In addition to IntelliJ IDEA, Illuminated Cloud 2 fully supports WebStorm, extending its HTML, JavaScript, and CSS editors for best-in-class development of Salesforce Lightning and Visualforce applications.
  • Refactoring – Illuminated Cloud 2 includes rename, extraction, inline, safe delete, copy, and move refactorings.
  • Code inspections and intentions – Illuminated Cloud 2 includes many code inspections to help ensure code validity without the need for a server round trip, to identify and eliminate unused source code, and to help manage standards compliance across the code base.
  • Code generation – Illuminated Cloud 2 automatically generates correct implementations of unimplemented methods from base classes and interfaces.

As always, I’m constantly enhancing the product’s feature set. New and enhanced refactorings, code inspections and intentions, and intelligent code generation capabilities are released on a frequent basis. Very shortly I will be adding full support for smart completion in Apex so that offered code completions can be filtered based on the expected data types. I also intend to integrate the Apex Debugger to facilitate interactive debugging of live requests.

With so many of IntelliJ IDEA’s features now present in Illuminated Cloud 2, I often find myself reaching for a feature that’s not yet implemented. When that happens, I use that as key input into my backlog’s list of features and their relative prioritization.

As both the developer and a daily user, I’m extremely excited about the new version of Illuminated Cloud and how it allows Salesforce developers to truly own and evolve their product source code. It certainly represents a huge shift from the productivity paradox of just a few years ago.

Scott Wells

Scott Wells has been developing software professionally for nearly a quarter of a century and as a hobbyist since receiving his first computer, a Commodore VIC-20, in the early ’80s. In addition to Illuminated Cloud, he is the Chief Technology Officer for Sirono, a provider of healthcare financial management solutions built on the Salesforce platform. He has previously held positions as Chief Architect for Zilliant and Principal Architect for Vignette. Scott currently resides in Austin, TX with his wife, twin children, and new puppy.

Posted in Guest Post, Plugin Development | Tagged , , | 2 Comments

What’s New in IntelliJ IDEA 2018.1 EAP?

Today we have exciting news to share – a new IntelliJ IDEA 2018.1 EAP build is available for download! Get the fresh build here or update within the Toolbox App. Let’s cut to the chase and a take a look at the goodies that are inside the latest IntelliJ IDEA 2018.1 EAP build.

Now the IDE lets you navigate to the next or previous identifier occurrence, using the Alt + Wheel down or Alt + Wheel up shortcuts. Place the caret on an identifier, and the IDE highlights its usages,  you can now jump to the next or the previous occurrence. This new feature is also available through the main menu in Edit | Find | Go to next (previous) highlighted element usage.

NextPreviousOccuor

Continue reading

Posted in EAP Releases, New Features | Tagged , | 2 Comments

IntelliJ IDEA 2017.3.4 is released

Meet the newly released IntelliJ IDEA 2017.3.4! Packed with a whole variety of improvements, our fourth bug fix update for IntelliJ IDEA 2017.3 is ready for download. Grab the latest version from our website or update via Toolbox App.

Here are the most notable bugs that have been fixed with the update:

  • Now renaming a module is reflected in the dependent module’s file (.iml):
    IDEA-176554.
  • You can now use the TAB key to jump to the Result pane in the Evaluate Expression window (fixed a regression): IDEA-158873.
  • Fixed the issue with Gradle silent import doing nothing when the Gradle JDK is invalid: IDEA-183962.
  • The Show Local Changes as UML action doesn’t let you scroll infinitely: IDEA-172583.
  • Unlimited resizing in Diagrams when scrolling with the mouse wheel has been fixed: IDEA-90162.
  • New shortcuts Shift + Del and Сtrl + X (cmd + X) have been assigned to the remove results action in the Find Tool Window: IDEA-144928.

Continue reading

Posted in Releases | Tagged | 1 Comment

What’s New in IntelliJ IDEA 2018.1 EAP?

Last week we opened the IntelliJ IDEA 2018.1 Early Access Program, and we hope you have already given this new version a try! Today we’re publishing a brand new IntelliJ IDEA EAP build. Download the latest EAP build via Toolbox App or get a copy from our website. Read this blog post to learn about all the new features this EAP build has prepared for you.

The improvements are coming for the Spring Boot framework. Now, after you run a Spring Boot web application, a new icon is shown in the gutter for methods with @RequestMapping annotations that handle incoming HTTP requests. By simply clicking  this gutter icon you can open all mappings in a scratch file with an .http extension and perform an HTTP request in the editor via the new REST client.

SpringBootMapping

Continue reading

Posted in EAP Releases, New Features | Tagged , | 27 Comments

Fumigating the IDEA Ultimate code using dataflow analysis

IntelliJ IDEA ships with thousands of Java code inspections. Most of them work like very advanced regular expressions: they look for specific patterns in the code which look like typos, are not very performant, confusing, or overly verbose. However one of them is not of that kind. Its name is “Constant conditions & exceptions” which sounds somewhat confusing. In fact, it performs data flow analysis of Java methods using a technique called “symbolic execution” and reveals suspicious facts about the code. Here are some examples of the facts it can reveal:

  • Dereference may cause a NullPointerException on some code path
  • Condition is always true or false in all possible code paths
  • Array index is always out of bounds in all possible code paths
  • Type cast will always fail

These facts do not always signal a bug. For example, one may want to add an always-true statement for code clarity, like in this case:

Continue reading

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

2018.1 changes to Subversion integration

Summary

Subversion working copies 1.6 and earlier are no longer supported, and it is now required to use a command-line svn client for integration with Subversion.

Note that Subversion allows using higher working copy formats with an older server, so even if you have 1.6 svn server, you could use 1.7 or 1.8 working copy. If for some reasons you still need to use the 1.6 working copy format and cannot update it, please comment on the request. Continue reading

Posted in EAP Releases | Tagged , , | 10 Comments

IntelliJ IDEA starts 2018.1 Early Access Program

We are pleased to announce the start of the Early Access Program for our next major release – IntelliJ IDEA 2018.1! The first IntelliJ IDEA 2018.1 EAP build is already available for download, and it brings you lots of improvements and a full bag of new features. If you want to know more about the highlights of the release planned for this spring – read this blog post.

ij2018_1_eap_blog Continue reading

Posted in EAP Releases, New Features | Tagged , | 39 Comments