Friends of OpenJDK Today

Java on Visual Studio Code – July 2023

July 31, 2023

Author(s)

  • Avatar photo
    Nick Zhu

    Senior Program Manager at Developer Division in Microsoft. Our team is currently based in Shanghai, China. I have worked on various product areas at Microsoft, such as Bing Ads, Azure ... Learn more

Hi everyone, welcome to our July update for Visual Studio Code for Java!

In this article, we are going to provide you an exciting update about our improved decompiler functionality.

Additionally, we are going to do a deep-dive into our code completion.

Let's get started!

Decompiler Support Upgrade

Java decompiler is essential for understanding third-party libraries, debugging, and learning from well-written code. It helps the developer to reverse engineer compiled Java bytecode back into human-readable Java source code, enhancing the productivity and code comprehension.

Previously, users have reported that our extensions did not have good support of proper decompiling and debugging code. In our latest release, we have embedded a powerful Java decompiler called Fernflower (Currently an open-source project and used in IntelliJ IDEA) in our extension pack.

With this decompiler, our extension allows you to directly click into libraries and it will automatically decompile the bytecode into readable source code. Inside the decompiled code, you can debug like what you do normally. We hope this feature will greatly boost your productivity during development. Here's a simple demo.

Decompiler experience upgrade

Decompiler experience upgrade, image

Decompiler experience upgrade

Toggling Inlay Hint on the Fly

Inlay Hint is a popular feature in Visual Studio Code and many other developer tools. It adds inline information to the source code to help you understand what the code does, such as parameter names, parameter types, variable types and so on.

However, we have heard from Java developers that sometimes these inline markers have obscured the original code and the editor becomes too crowded.

Actually, Visual Studio Code has a setting that allows you to toggle inlay hints on the fly so you can turn it on/off as you are typing the code, easily tuning your experience. The setting can be found by searching for "inlay hints" and selecting the options from the image below.

Toggling Inlay Hints on the fly

Toggling Inlay Hints on the fly

Here's a simple demo.

Toggle inlay hints on the fly demo

Toggle inlay hints on the fly demo, image

Toggle inlay hints on the fly demo

Code Completion Performance Improvement Deep-Dive

We have consistently stressed the importance of code completion performance and its critical role of boosting the developer's productivity.

In our previous blog post, we have shown the latency improvement of our recent code performance. In this month, we are pleased to share even more progress and technical details of how we have managed to make this improvement.

Reduction in code completion time (compared to previous release)

Extension Version Average P99 P95 P90 P75 P50
1.18 13.85% 56.15% 49.36% 50.22% 13.69% 34.38%
1.19 55.65% 17.19% 17.01% 15.18% 14.14% 9.52%

As the table shows, after 1.19 release, the code completion latency has been reduced significantly in average time and in all percentile ranks.

The code completion optimization efforts are tightly linked to the Eclipse Java Development (JDT) Language Server and our work is focused on three main areas.

1. Optimize Diagnostic Jobs

Related Pull Requests: PR #2587PR #2574,  PR #2664

The diagnostic jobs in the Eclipse JDT Language Server are responsible for analyzing Java source code and providing feedback on potential issues such as compiler errors and warnings. These PRs introduce optimizations to the diagnostic job processing, resulting in improved performance and reduced latency in providing code diagnostics. By fine-tuning the diagnostic analysis, developers can receive faster feedback and gain insights into their codebase more promptly.

2. Optimize Request Handler Scheduling Rules

Related Pull Requests: PR #2637PR #2641PR #2643PR #2659PR #2660

Effective scheduling of request handlers is vital in handling incoming code completion requests from the IDE. The mentioned PRs focus on optimizing the scheduling rules used by the Eclipse JDT Language Server to prioritize and process code completion requests efficiently. These improvements enable the server to allocate resources more effectively, resulting in reduced contention and faster response times. By streamlining request handler scheduling, developers can experience a more responsive code completion workflow.

3. Optimize Completion Request Handler

Related Pull Requests: PR #2642PR #2639PR #2621PR #2614PR #2638

The completion request handler is responsible for generating code completion suggestions based on the context within the IDE. These PRs introduce optimizations to the completion request handling process, resulting in faster and more accurate suggestion generation. The work was mainly focused in two areas

  • Return suggestion list first and lazily calculate the inserted text
  • Reduce the payload size for completion response and reduce the serialization/deserialization and cost

By enhancing the completion request handler, developers can experience a significant improvement in the speed and relevance of code completion suggestions, enabling them to write code more efficiently.

We want to thank everyone in the open-source community who is involved in these PRs. The progress we have achieved in enhancing code completion serves as a promising milestone of our ongoing commitment to improving Visual Studio Code Java's performance.

In addition to code completion, we will continue to refine and optimize the reliability and compatibility of our Java language server (such as less crash in our extension and errors when building the projects). Please stay tuned with our upcoming blog posts.

Install Extension Pack for Java

To use all features mentioned above, please download and install Extension Pack for Java on Visual Studio Code.

Extension pack for Java

If you are a Spring developer working on a Spring Boot application, you can also download the Spring Boot Extension Pack for specialized Spring experience.

Spring boot extension pack

Feedback and suggestions

As always, your feedback and suggestions are very important to us and will help shape our product in future. There are several ways to give us feedback

Resources

Here is a list of links that are helpful to learn Java on Visual Studio Code.

Related Articles

View All

Author(s)

  • Avatar photo
    Nick Zhu

    Senior Program Manager at Developer Division in Microsoft. Our team is currently based in Shanghai, China. I have worked on various product areas at Microsoft, such as Bing Ads, Azure ... Learn more

Comments (1)

Your email address will not be published. Required fields are marked *

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Save my name, email, and website in this browser for the next time I comment.

Steve Prior

Before anyone else wonders, VMWare bought Pivotal so the Spring Boot Extension Pack is now shown to be from them.

Subscribe to foojay updates:

https://foojay.io/feed/
Copied to the clipboard