Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
Because my project is still using JDK8, I have to use older version 9.1.0 of Spoon.
When setting auto import to true, the import static statement in the source file is missing from the spoon generated sources in some circumstances.
I can reproduce the issue if I define a class with public static field and refer it in another class using static import.
Source code you are trying to analyze/transform
package com.elvis;
public class StaticClassModel {
public static final String STATIC_FIELD = "static field";
}
package com.elvis;
import static com.elvis.StaticClassModel.*;
public class StaticTest {
public void doSomeTest() {
System.out.println(STATIC_FIELD);
}
}
Source code for your Spoon processing
using spoon-maven-plugin
Actual output
package com.elvis;
public class StaticTest {
public void doSomeTest() {
System.out.println(STATIC_FIELD);
}
}
Expected output
package com.elvis;
import static com.elvis.StaticClassModel.*;
public class StaticTest {
public void doSomeTest() {
System.out.println(STATIC_FIELD);
}
}
Describe the bug
Because my project is still using JDK8, I have to use older version 9.1.0 of Spoon. When setting auto import to true, the import static statement in the source file is missing from the spoon generated sources in some circumstances. I can reproduce the issue if I define a class with public static field and refer it in another class using static import.
Source code you are trying to analyze/transform
Source code for your Spoon processing
Actual output
Expected output
Spoon Version
9.1.0
JVM Version
1.8
What operating system are you using?
MacOS 15.1