What version of OpenRewrite are you using?
- rewrite-migrate-java: 3.34.0
- rewrite-core: 8.81.1
- rewrite-java: 8.81.1
What is the smallest, simplest way to reproduce the problem?
class Main {
public static void main(String[] args) {}
}
class MainTest {
void test() {
Main.main(new String[] {});
}
}
Run org.openrewrite.java.migrate.lang.MigrateMainMethodToInstanceMain.
What did you expect to see?
The public static void main(String[] args) method should be preserved when it is referenced directly as a static API from another source file.
What did you see instead?
The recipe changes the main method to an instance no-arg method:
class Main {
void main() {}
}
But the call site is left unchanged:
class MainTest {
void test() {
Main.main(new String[] {});
}
}
The rewritten code no longer compiles:
method main in class Main cannot be applied to given types;
required: no arguments
found: String[]
What version of OpenRewrite are you using?
What is the smallest, simplest way to reproduce the problem?
Run
org.openrewrite.java.migrate.lang.MigrateMainMethodToInstanceMain.What did you expect to see?
The
public static void main(String[] args)method should be preserved when it is referenced directly as a static API from another source file.What did you see instead?
The recipe changes the main method to an instance no-arg method:
But the call site is left unchanged:
The rewritten code no longer compiles: