|
| 1 | +# What's new in Visual Studio Code Java? |
| 2 | + |
| 3 | +*April 2019* |
| 4 | + |
| 5 | +Welcome to the April 2019 release of Java Extension Pack. This document aims to recap the features, bug fixes around Java language support in between releases. Here are some of the key highlights: |
| 6 | + |
| 7 | +- [Java 12](#java-12-supported) suppported |
| 8 | +- [More Source Actions](#more-source-actions) added to Java language server |
| 9 | +- [Logical Structure](#display-logical-structure-of-collections) of collections displayed by debugger |
| 10 | +- [Debugging Maven Goals](#debug-maven-goals) made easy |
| 11 | +- [JDK Acquisition Guide](#jdk-acquisition-guide) to guide you download and install Java Development Kit |
| 12 | + |
| 13 | +The release notes are arranged in the following sections related to VS Code Java focus areas. Here are some further updates: |
| 14 | + |
| 15 | +- [Code Editing](#code-editing) |
| 16 | +- [Debugging](#debugging) |
| 17 | +- [Maven](#maven) |
| 18 | +- [Troubleshooting](#troubleshooting) |
| 19 | + |
| 20 | +## Code Editing |
| 21 | + |
| 22 | +### Java 12 Supported |
| 23 | + |
| 24 | +Java 12 is supported now. To use the experimental language features like the new `switch` statement, add the following settings to `pom.xml`: |
| 25 | + |
| 26 | +```xml |
| 27 | +<build> |
| 28 | + <plugins> |
| 29 | + <plugin> |
| 30 | + <groupId>org.apache.maven.plugins</groupId> |
| 31 | + <artifactId>maven-compiler-plugin</artifactId> |
| 32 | + <version>3.8.0</version> |
| 33 | + <configuration> |
| 34 | + <source>12</source> |
| 35 | + <compilerArgs>--enable-preview</compilerArgs> |
| 36 | + </configuration> |
| 37 | + </plugin> |
| 38 | + </plugins> |
| 39 | +</build> |
| 40 | +``` |
| 41 | + |
| 42 | +### Better Performance |
| 43 | + |
| 44 | +With the latest release of [Language Server for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java), the performance of dealing with larger amount of source files is improved. When you have many open files in your editor, the language server is more responsive. |
| 45 | + |
| 46 | +### More Source Actions |
| 47 | + |
| 48 | +#### Resolve Ambiguous Imports |
| 49 | + |
| 50 | +To deal with ambiguous imports, you now have a dropdown list to pick the right one. The code line with the unresolved type is also presented to you to help you decide. |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +#### Override/Implement Methods |
| 55 | + |
| 56 | +With the new source action, all the cadidates are presented to you with a checklist. Then you can decide what to override or implement. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +#### Generate `hashCode()` & `equals()` |
| 61 | + |
| 62 | +Now `hashCode()` & `equals()` can be generated with default implementations. All the non-static member variables are listed, and you can customize the generated code using the check list. |
| 63 | + |
| 64 | +There are two options for you to customize the generated code: |
| 65 | + |
| 66 | +- If you use Java 7+, you can set `java.codeGeneration.hashCodeEquals.useJava7Objects` to `true` to generate shorter code which calls `Objects.hash` and `Objects.equals`. |
| 67 | +- You can also set `java.codeGeneration.hashCodeEquals.useInstanceof` to `true` to use `instanceOf` operator to check the object types instead of calling `Object.getClass()`. |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +#### Generate `toString()` |
| 72 | + |
| 73 | +`toString()` can also be generated with the new source action. Customization is also possible with the check list of all the member variables. |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +#### Convert to Static Imports |
| 78 | + |
| 79 | +Last but not least, you can now convert static functions calls to static imports. |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | +### Folding Range |
| 84 | + |
| 85 | +Folding range allows you to fold or unfold code snippet to better view the source code. |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +## Debugging |
| 90 | + |
| 91 | +### Display Logical Structure of Collections |
| 92 | + |
| 93 | +The debugger is now showing the logical structure of lists and maps, instead of the physical layout of the collections. |
| 94 | + |
| 95 | +If you prefer the physical layout view, you can go back by setting `java.debug.settings.showLogicalStructure` to `false`. |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +### Highlight Exceptions in Editor |
| 100 | + |
| 101 | +Exceptions are now highlighted with extra info in the editor window. Before that, you need to hover on the exception to see details. Now the most important info is presented to you right at where it occurs. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +### Go to Definition by Clicking Stack Trace in Debug Console |
| 106 | + |
| 107 | +When there's an exception, you can click on the stack trace to see the definition of the function calls. |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +## Maven |
| 112 | + |
| 113 | +Maven extensions released some interesting features and improvements to improve the productivity. |
| 114 | + |
| 115 | +### Debug Maven Goals |
| 116 | + |
| 117 | +To debug Maven goals, just right click on a goal and start debugging. The Maven extension will call the Java debugger with the right parameters. This is handy and super time-saving. |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +### New Command to Add a Dependency |
| 122 | + |
| 123 | +Maven extension released a new command `Maven: Add a Dependency` (or `maven.project.addDependency`) to help add a new dependency to `pom.xml`. The process is interactive. |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | +## Troubleshooting |
| 128 | + |
| 129 | +### JDK Acquisition Guide |
| 130 | + |
| 131 | +If you are experiencing the problem of setting up the JDK, we've got you covered. The JDK Acquisition Guide follows the same logic used by the Java language server to check for a JDK installation on your machine. When the check fails, the guide will automatically show and recommend a JDK distribution that is compatible with your OS and CPU architecture. |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | +## Thank You |
| 136 | + |
| 137 | +Here are more changes and bug fixes. Kudos to all the contributors! |
| 138 | + |
| 139 | +- [@snjeza](https://github.com/snjeza) |
| 140 | + - [Langauge Server] Download java sources lazily [eclipse/eclipse.jdt.ls#979](https://github.com/eclipse/eclipse.jdt.ls/issues/979) |
| 141 | + - [Langauge Server] Optimize compilation unit computations [eclipse/eclipse.jdt.ls#980](https://github.com/eclipse/eclipse.jdt.ls/issues/980) |
| 142 | + - [Langauge Server] Optimize server initialization [eclipse/eclipse.jdt.ls#981](https://github.com/eclipse/eclipse.jdt.ls/issues/981) |
| 143 | +- [@testforstephen](https://github.com/testforstephen) |
| 144 | + - [Debugger] Debug console does not autocomplete when a .class file is open [Microsoft/vscode-java-debug#535](https://github.com/Microsoft/vscode-java-debug/issues/535) |
| 145 | +- [@jdneo](https://github.com/jdneo) |
| 146 | + - [Test Runner] Output encoding issue of the Test Runner [Microsoft/vscode-java-test#632](https://github.com/Microsoft/vscode-java-test/issues/632) |
| 147 | + - [Test Runner] Stop honor the deprecated 'launch.test.json' [Microsoft/vscode-java-test#650](https://github.com/Microsoft/vscode-java-test/issues/650) |
| 148 | + - [Test Runner] Properly resolve classpath for invisible projects [Microsoft/vscode-java-test#348](https://github.com/Microsoft/vscode-java-test/issues/348#issuecomment-480687978) |
| 149 | + |
| 150 | +## Happy Coding! |
0 commit comments