Skip to content

ReplaceSystemOutWithIOPrint imports non-existing class java.io.IO #1115

Closed

Description

@iorjfeiofjseoirf

What version of OpenRewrite are you using?

  • OpenRewrite v8.83.0
  • Maven plugin v6.40.0
  • rewrite-migrate-java v3.35.0

What is the smallest, simplest way to reproduce the problem?

package com.helloworld;

public class Main {
  public void greet() {
    System.out.println("hello");
  }
}

What did you expect to see?

No import statement is needed for class java.lang.IO.

package com.helloworld;

public class Main {
  public void greet() {
    IO.println("hello");
  }
}

What did you see instead?

An import for a non-existing class java.io.IO.

package com.helloworld;

import java.io.IO;

import ja
public class Main {
  public void greet() {
    IO.println("hello");
  }
}

What is the full stack trace of any errors you encountered?

import java.io.iO;
              ^
  symbol: class iO
  location: package java.io

Background information

The bug was introduced with #1093 because #1091 was too short-sighted.
The class in question used to be java.io.IO in JEP 477 and JEP 495 (both preview in Java 23 and 24, respectively). However, it was moved to java.lang.IO in the finalized JEP 512 in Java 25. Quote from https://openjdk.org/jeps/512:

The new IO class for basic console I/O is now in the java.lang package rather than the java.io package. Thus it is implicitly imported by every source file.

Please revert #1093 .

Activity

  1. added
    bug
    on May 28, 2026
  2. timtebeek commented on May 28, 2026

    @timtebeek
    Member

    Thanks! @protocol7 any insights? Since you had logged #1091 originally.

  3. protocol7 commented on May 28, 2026

    @protocol7

    Thanks! @protocol7 any insights? Since you had logged #1091 originally.

    Went back and double-checked our failure, and this was indeed an incorrect report from my side, sorry about that. Turns out we had a mix of Java versions, the same code was built with both Java 21 and 25. The rewrite happened on the 25 code, and then failed on 21.

  4. timtebeek commented on May 28, 2026

    @timtebeek
    Member

    That helps explain it, thanks!

  5. added a commit that references this issue on May 28, 2026
    61e7d90
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

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions