Skip to content

The --enable-preview flag is not added to JVM run args when using code-lens to run application #2865

Description

@GavinRay97

[provide a description of the issue]

Environment
  • Operating System: Windows 11
  • JDK version: 21.ea-build-3
  • Visual Studio Code version:
Version: 1.75.0-insider (user setup)
Commit: 727d2d32aea02baf7d13fa38787e8ed64dd858d0
Date: 2023-01-06T05:21:40.528Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.22623
Sandboxed: Yes
  • Java extension version: v1.14.2023010903 pre-release
Steps To Reproduce

Using the below Maven POM with JDK 21 downloaded from SDKMAN does not work.
To test it, you can try a public static void main() which uses something like

ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>example-maven</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.enablePreview>true</maven.compiler.enablePreview>
        <maven.compiler.release>21</maven.compiler.release>
        <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
        <java.21.home>/home/user/.sdkman/candidates/java/21.ea.3-open</java.21.home>
    </properties>

     <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <compilerVersion>${maven.compiler.target}</compilerVersion>
                <source>${maven.compiler.target}</source>
                <target>${maven.compiler.target}</target>
                <fork>true</fork>
                <executable>${java.21.home}/bin/javac</executable>
                <compilerArgs>--enable-preview</compilerArgs>
            </configuration>
        </plugin>
    </plugins>

</project>

[Please attach a sample project reproducing the error]
Please attach logs

Current Result
[user@MSI example-panama-maven]$  cd /home/user/projects/example-panama-maven ; /usr/bin/env /home/user/.sdkman/candidates/java/21.ea.3-open/bin/java @/tmp/cp_c529gxncpu60gywck8qcv0hql.argfile org.example.Main 
java.lang.UnsupportedOperationException: Preview Features not enabled, need to run with --enable-preview
        at java.base/jdk.internal.misc.PreviewFeatures.ensureEnabled(PreviewFeatures.java:49)
        at java.base/java.lang.Thread.ofVirtual(Thread.java:859)
        at java.base/java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor(Executors.java:274)
        at org.example.AsynchronousSocketClient.main(Main.java:158)
        at org.example.Main.lambda$1(Main.java:246)
        at java.base/java.lang.Thread.run(Thread.java:1623)
Expected Result
Additional Informations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions