Skip to content

Support JEP 511 import module of Java 25 #1077

Description

@kaidohallik

Prettier-Java 2.10.4

Input:

import module java.base; // JEP 511, final in Java 25

public class Main {

  public static void main(String[] args) {
    List<String> messages = List.of("Hello", "World");
    System.out.println(messages);
  }
}

Output:

import java.base; // JEP 511, final in Java 25

public class Main {

  public static void main(String[] args) {
    List<String> messages = List.of("Hello", "World");
    System.out.println(messages);
  }
}

Expected behavior:

Output should be the same as Input.

Java code in Input runs successfully when using JDK 25 and prints to console:

[Hello, World]

Java code in Output doesn't run when using JDK 25, because module keyword was removed, exception is:

Main.java:1: error: cannot find symbol
import java.base; // JEP 511, final in Java 25
           ^
  symbol:   class base
  location: package java
Main.java:6: error: cannot find symbol
    List<String> messages = List.of("Hello", "World");
    ^
  symbol:   class List
  location: class Main
Main.java:6: error: cannot find symbol
    List<String> messages = List.of("Hello", "World");
                            ^
  symbol:   variable List
  location: class Main
3 errors
error: compilation failed

This refers to JEP 511: Module Import Declarations, which is finalized in Java 25.

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions