Skip to content

Add support for running Java 21 "Unnamed classes and Instance main method" #1444

Description

@fbricon

vscode-java now provides support for Java 21 preview feature Unnamed classes and Instance main method, however, we're missing the Run/Debug codelens on the main() method

Environment
  • Operating System: MacOS 14.3 (23D56)
  • JDK version: 21.0.1 temurin
  • Visual Studio Code version: 1.86.2
  • Java extension version: 1.28.1
  • Java Debugger extension version: 0.56.2024020601 pre-release
Steps To Reproduce
  1. Set Java 21 as the default runtime
  2. Create a hello.java file
  3. Paste this code:
String greeting = "Hello, World!";

void main() {
    System.out.println(greeting);
}
Current Result

No Run/Debug codelenses
Screenshot 2024-02-21 at 10 49 05

Expected Result

Should be able to Run/Debug the class via codelenses either at the top of the file or over the main() method

Additional Informations

Activity

  1. testforstephen commented on Mar 6, 2024

    @testforstephen
    Contributor

    When trying Java 21 Unnamed classes and Instance main method with the JDT language server, the instance main method works as expected. However, the unnamed classes fail to compile. See the issue eclipse-jdtls/eclipse.jdt.ls#3089.

    Fred Bricon (@fbricon) Do we finish the full support for the unnamed classes in jdt language server?

  2. testforstephen commented on Mar 25, 2024

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions