Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Spoon 9.1.0, auto import is not working properly with import static #6057

Open
ElvisLiaooo opened this issue Nov 4, 2024 · 0 comments
Labels

Comments

@ElvisLiaooo
Copy link

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

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);
    }
}

Spoon Version

9.1.0

JVM Version

1.8

What operating system are you using?

MacOS 15.1

@ElvisLiaooo ElvisLiaooo added the bug label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant