Lombok



  • Hallo,

    Lombok ist ja nee geile Sache. get/set wird automatisch generiert. Konstruktoren sind wie magisch vorhanden.

    Aber wie funktioniert das Zusammenspiel von Lombok und Eclipse. Ich musste zuerst etwas installieren. Zusaeztlich muss ich aber auch die jar in den build Path einbinden. Also wieso musste ich vorher was installieren, aber trotzdem das Lombok jar einbinden ??? Wirft fuer mich erstmal fragen auf.

    Aber noch intressanter, wie greift Lombok in den build prozess ein. Lombok scheint Zugriff auf die intellisense Api von Eclipse zu haben. Jedenfalls tauchen alle unsichtbar generierten Methoden im intellisense auf.

    Ausserdem muss es ja dem Compiler mitteilen was er generieren muss. Deswegen gibt es wohl auch eine Compiler Schnittstelle auf die Lombok zugreift.

    Das sind mal so meine Gedanken...



  • Scheint zwar etwas älter zu sein, ist aber immer noch auf der offiziellen Seite verlinkt:

    http://jnb.ociweb.com/jnb/jnbJan2010.html#controversy schrieb:

    It's a total hack. Using non-public API. Presumptuous casting (knowing that an
    annotation processor running in javac will get an instance of JavacAnnotationProcessor,
    which is the internal implementation of AnnotationProcessor (an interface), which
    so happens to have a couple of extra methods that are used to get at the live AST).

    On eclipse, it's arguably worse (and yet more robust) - a java agent is used to inject
    code into the eclipse grammar and parser class, which is of course entirely non-public
    API and totally off limits.

    If you could do what lombok does with standard API, I would have done it that way, but
    you can't. Still, for what its worth, I developed the eclipse plugin for eclipse v3.5
    running on java 1.6, and without making any changes it worked on eclipse v3.4 running
    on java 1.5 as well, so it's not completely fragile.



  • Lombok basiert auf der Annotation Processing API, damit kann man dem Compiler alles Mögliche unterjubeln.
    https://deors.wordpress.com/2011/10/08/annotation-processors/


Anmelden zum Antworten