Hi everyone, welcome to the October update of Visual Studio Code Java. We have brought a lot of improvements in code editing and debugging experience this time, so let’s get started!
Debugging Experience Enhancements
Visual indicator for inline breakpoints
Consider a line like this:
Stream.of(“Frank”).map(name -> name.toUpperCase()).forEach((item -> System.out.println(item));
Now when you set a breakpoint on this line, Visual Studio Code will automatically identify the lambda expressions in this line, and visualize them with grey dots. If you want to further set inline breakpoints on those lambda expressions, you can directly click on those grey dots, and the grey dots will turn into red dots like normal breakpoints, then the debugger will stop at these breakpoints during the code execution. This will provide you much easier debugging experience for these lambda expressions. Here’s a quick demo.
Support Java virtual threads
Java 19 brings the first preview of virtual threads to the Java platform; This is the primary deliverable of Project Loom. Virtual threads are designed to significantly boost the scalability of concurrent Java programming while making little change to the current API. In our September release, we have enabled the support for virtual threads in our Java debugger. Note that you will need to install JDK 19 to use this feature. Here’s a screenshot of our debugger in action.
For more details about virtual threads, you can read the official blog post here.
Code Editing Improvements
Code action: Lombok & Delombok
Since we introduced the support for Lombok in July, we have been getting lots of feature requests! One of the popular asks is to provide convenient Lombok operations when user clicks on the Code Action lightbulb (Quick Fix), and we have added this feature into our latest version. The annotations we currently support are:
Not only you can use this shortcut to “Lombok” your code, you can also “DeLombok” the annotations you don’t want anymore by unpicking some of them. Here’s a demo.
In addition, we want to mention again that our extensions now have built-in support for Lombok and this is also mentioned on Project Lombok’s official homepage!
Support @Nullable and @Nonnull annotations
Lastly, we have enhanced our code analysis to support @Nullable and @Nonnull annotations. @Nullable and @Nonnull annotation let the developer and compiler know if it is fine to allow null for a variable, parameter or return value.
If we detect certain contracts are being violated, we will show the warnings in the problems section and also highlight the them in the editor area for you. Here’s a quick demo of this feature in action.
Currently, we support the @NonNull and @Nullable annotations from the following packages
If you wish to include or exclude certain annotations from the code analysis, you can configure them in the settings.json under “java.compile.compileAnalysis.nonnull” and “java.compile.compileAnalysis.nullable“. Here’s a screenshot.
Install Extension Pack for Java
To use all features mentioned above, please download and install Extension Pack for Java on Visual Studio Code.
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.
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
Here is a list of links that are helpful to learn Java on Visual Studio Code.
Learn more about Java on Visual Studio Code.