A long time ago, the Java Extension Pack of Visual Studio Code (hereafter VS Code) now supports JDK 13.
Hey! Looks like we have another release already! vscode-java 0.50.0 brings support for Java 13 (Eclipse/Maven only for the moment), diagnostic tags, finer progress report on imports, moar code actions... See https://t.co/kYv133rfTT
— VSCode Java (@VSCodeJava) October 1, 2019
Is this the best release ever or what? pic.twitter.com/Qlv1cHnK4A
When I tried JEP 355: Text Blocks (Preview), "Text Blocks is a preview feature and disabled by default. Use --enable-preview to enable I got the error.
Yes, I thought I had to add --enable-preview, but how do I specify that for VS Code? I stopped for a moment, so I looked it up.
Since the above error occurred in a project using Maven, I was able to solve it by adding the following description to Maven's Compiler Plugin regardless of VSCode.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
In addition, JDT (Java Development Tool) included in Language Support for Java of Java Extension Pack. I was able to solve it by setting eclipse.org/jdt/). Reference: https://github.com/redhat-developer/vscode-java/issues/671#issuecomment-477379761
Since the .settings folder is created in the Java project, just open the org.eclipse.jdt.core.prefs file in it and add "org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures = enabled". ..
I tried what would happen if I didn't use Maven, and I was able to run it without any errors. If you look closely, it was running with --enable-preview.
It seems to be specified by Debugger for Java in the Java Extension Pack? I wonder.
I searched for the code on Github and found it below.
https://github.com/microsoft/vscode-java-debug/blob/master/src/configurationProvider.ts#L220
// Auto add '--enable-preview' vmArgs if the java project enables COMPILER_PB_ENABLE_PREVIEW_FEATURES flag.
if (await lsPlugin.detectPreviewFlag(config.mainClass, config.projectName)) {
config.vmArgs = (config.vmArgs || "") + " --enable-preview";
}
It seemed to be controlled by the COMPILER_PB_ENABLE_PREVIEW_FEATURES flag, and the flags were: The default seems to be enabled. (Is it correct?
https://github.com/microsoft/vscode-java-debug/blob/master/src/languageServerPlugin.ts#L76
const COMPILER_PB_ENABLE_PREVIEW_FEATURES: string = "org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures";
export async function detectPreviewFlag(className: string, projectName: string): Promise<boolean> {
const expectedOptions = {
[COMPILER_PB_ENABLE_PREVIEW_FEATURES]: "enabled",
};
return checkProjectSettings(className, projectName, true, expectedOptions);
}
Lastly, as an aside, when I saw @ bitter_fox's demo at the Oracle Code One 2019 Report Meeting that I attended the other day, I thought "Oh" is Text. The blank on the first line of Blocks was determined by the closing position at the end. I tried it and it worked. It was sober but something impressive.
Recommended Posts