Java on Visual Studio Code – July 2023

Nick Zhu

Hi everyone, welcome to our July update for Visual Studio Code for Java! In this blog 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 Experience 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

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

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 version)

Extension Version Average P99 P95 P90 P75 P50
1.18 (compared to 1.17) 13.85% 56.15% 49.36% 50.22% 13.69% 34.38%
1.19 (compared to 1.18) 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.

Optimize Diagnostic Jobs

Related Pull Requests: PR #2587, PR #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. 

Optimize Request Handler Scheduling Rules

Related Pull Requests: PR #2637, PR #2641, PR #2643, PR #2659, PR #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. 

Optimize Completion Request Handler

Related Pull Requests: PR #2642, PR #2639, PR #2621, PR #2614, PR #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

  • Leave your comment on this blog post
  • Open an issue on our GitHub Issues page
  • Send an email to: vscjfeedback@microsoft.com

Resources

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

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • James Tharpe 1

    Thanks so much for this! Java has been one of the most difficult languages to work with in VS Code but it keeps getting easier and easier!

    • Nick ZhuMicrosoft employee 0

      Thank you! Please let us know if you have feedback for us at any time

Feedback usabilla icon