Unable to compile calling Lombok extension method in Lambda using Maven with Java8

I have a problem with the following code:

public class A {
    public String someMethod() {
        return "some";
    }
}

public class AExtension {
    public static void extensionMethod(A a, String s) {
        System.out.println(a.someMethod() + s);
    }
}

@ExtensionMethod({ AExtension.class })
public class ExtensionMethodExample {

    public void test(List<String> someList) {
        A a = new A();
        someList.stream().forEach(x -> a.extensionMethod(x)); 
    }
}

And when compiling this code with Maven, I get:

[ERROR] [...]ExtensionMethodExample.java:[12,49] cannot find symbol
    symbol:   method extensionMethod(java.lang.String)
    location: variable a of type [...].A

The error occurs only when compiling using Maven, and while working in Eclipse everything works fine.

Some of my settings:

maven-compiler-plugin: 3.5.1
lombok: 1.16.10 (I also tried 1.16.2)

Update: Of course, a call using a Lambda expression.

+4
source share

Source: https://habr.com/ru/post/1657390/


All Articles