[Bug]: Spoon 9.1.0, auto import is not working properly with import static
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
### 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
```Java
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
```Java
using spoon-maven-plugin
```
### Actual output
```Java
package com.elvis;
public class StaticTest {
public void doSomeTest() {
System.out.println(STATIC_FIELD);
}
}
```
### Expected output
```Java
package com.elvis;
import static com.elvis.StaticClassModel.*;
public class StaticTest {
public void doSomeTest() {
System.out.println(STATIC_FIELD);
}
}
```
### Spoon Version
9.1.0
### JVM Version
1.8
### What operating system are you using?
MacOS 15.1
Contributor guide
Assessment
This issue has not been assessed yet.