Java – Difficult to extend Lombok

Difficult to extend Lombok… here is a solution to the problem.

Difficult to extend Lombok

I want to create an annotation handler to extend the Java language. However, I can’t do this easily because of the SCL file. I wonder if the Lombok developers deliberately made it so difficult.

If I try to extend JavacAnnotationHandler, it can’t find it in lombok.jar because the name is JavacAnnotationHandler.SCL.Lombok. I cloned the GitHub repository, but in the resources.after and resources.before packages and Java 12 syntax, I keep getting errors with duplicate classes. I’m using lombok 1.18.8.

That’s mine.

    import lombok.javac.JavacAnnotationHandler;
    public class SingletonJavacHandler extends JavacAnnotationHandler<Singleton> {

It says “Unable to parse the symbol ‘JavacAnnotationHandler'”

Solution

SCL files are used to hide lombok implementation classes in the IDE’s autocomplete dialog box.

The resources-before and resources-after files should not be compiled. They are in the test resource because our test framework handles them.

Related Problems and Solutions