Skip to content

Java source/target version 11 not recognized #625

@shawmanz32na

Description

@shawmanz32na

We're starting development on a new project and are targeting the upcoming Java 11 release. However, although our stub project compiles just fine in Maven, VS Code isn't able to provide intellisense, reports incorrect syntax errors, and fails to launch the project.

When the maven-compiler-plugin's source and target attributes are set from 11 down to 10, however, all the issues go away.

I suspect that whatever is interpreting the Java source/target version doesn't know to look for 11, sees a value it doesn't recognize, and then falls back to targeting the default source/target version (1.5?).

Below, I've attached my Maven POM and the stub class file that won't compile.

Environment
  • Operating System: Windows 10 Pro (10.0.17134 Build 17134)
  • JDK version:
java version "11" 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11+28)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)
  • Visual Studio Code version:
Version: 1.26.1
Commit: 493869ee8e8a846b0855873886fc79d480d342de
Date: 2018-08-16T18:38:57.434Z
Electron: 2.0.5
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
  • Java extension version: 0.29.0
Steps To Reproduce
  1. Create a stub Maven project with the compiler source and target set to Java 11
  2. Use a lambda when printing "Hello World!" in the main method

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.github.shawmanz32na</groupId>
    <artifactId>java-11-support-spike</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

src/main/java/com/github/shawmanz32na/java11supportspike/App.java

package com.github.shawmanz32na.java11supportspike;

import java.util.stream.Collectors;
import java.util.stream.Stream;

public final class App {

    public static void main(String[] args) {
        System.out.println(Stream.of("Hello", "World!").collect(Collectors.joining(" ")));
    }
}
Current Result
  • Intellisense reports errors on Java syntax from 1.8+
  • Debugging the application from VS Code fails to launch with compilation errors
Expected Result
  • Business as usual
Additional Informations

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions