projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.83k stars 2.37k forks source link

Compilation fails if static imports for nested class go first #1582

Open antonlisovenko opened 6 years ago

antonlisovenko commented 6 years ago

Check the example:

import static com.xgen.svc.atm.logcollection.Some.Child.doSmth;
import lombok.extern.slf4j.Slf4j;

public class Some {
    public void foo() {
        doSmth();
    }

    @Slf4j
    public static class Child {
        public static void doSmth() {  }
    }
}

The code doesn't compile saying

"Error:(12, 6) java: cannot find symbol symbol: class Slf4j location: class com.xgen.svc.atm.logcollection.Some"

To fix it we need to swap the location of imports - make static first:

import lombok.extern.slf4j.Slf4j;
import static com.xgen.svc.atm.logcollection.Some.Child.doSmth;
Master-Killer commented 5 years ago

I have the same problem (compile error that a lombok annotation is not found), except that the ordering of imports doesn't change anything. The only solution I found is to fully qualify the lombok annotations.

NB: I tested this problem with the latest lombok version available: 1.18.6.

EricC-59 commented 1 year ago

Still present in 1.18.26 Full qualification of the annotation works around the issue

Rawi01 commented 1 year ago

I can not reproduce it using the example above. If you still have this problem please post a failing example.