lombok.jar file description
lombok.jar Free Edition is a Java™ utility that can be used to help developers eliminate Java verbosity, especially for simple Java objects (POJOs)
How to use lombok.jar
eclipse / myeclipse manual installation of lombok
1. Copy lombok.jar to the folder directory where myeclipse.ini / eclipse.ini is located
2. Open eclipse.ini / myeclipse.ini, insert the following two lines at the end and save:
-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar
3. Restart eclipse / myeclipse
Principle analysis
Next, we will analyze the principle of how lombok works, taking Oracle's javac compilation tool as an example.
Since Java 6, javac supports "JSR 269 Pluggable Annotation Processing API" specification, as long as the program implements the API, it can be called when javac is running.
For example, there is now a program A that implements "JSR 269 API". Then the specific process when using javac to compile the source code is as follows:
1)javac analyzes the source code and generates an abstract syntax tree (AST)
2) During operation, program A that implements "JSR 269 API" is called
3) At this time, program A can complete its own logic, including modifying the abstract syntax tree (AST) obtained in the first step
4) javac uses a modified abstract syntax tree (AST) to generate bytecode files
Lombok is essentially a program that implements the "JSR 269 API". In the process of using javac, the specific process of its effect is as follows:
1)javac analyzes the source code and generates an abstract syntax tree (AST)
2) During the running process, the lombok program that implements "JSR 269 API" is called
3) At this time, lombok processes the AST obtained in the first step, finds the syntax tree (AST) corresponding to the class where the @Data annotation is located, then modifies the syntax tree (AST), and adds the corresponding tree nodes defined by the getter and setter methods.
4)javac uses a modified Abstract Syntax Tree (AST) to generate bytecode files.
lombok.jar compilation tool
1) From "3. Principle Analysis", it can be seen that Oracle javac directly supports lombok
2) The java compilation tool used by Maven, a commonly used project management tool, comes from the configured third-party tool. If we configure this third-party tool to be Oracle If javac is used, then Maven will directly support lombok.
3) If the compilation tool configured by Intellij Idea is Oracle javac, it will directly support lombok.
4) What is used in Eclipse is not the compilation tool Oracle javac, but the self-implemented Eclipse Compiler for Java (ECJ). To make ECJ support lombok, you need to set it up. Specifically, add the following two lines of settings to the eclipse.ini file in the Eclipse program directory:
-javaagent:[path where lombok.jar is located]
-Xbootclasspath/a:[the path where lombok.jar is located]
lombok.jar update log
1. The pace of optimization never stops!
2. More little surprises are waiting for you to discover~
Huajun editor recommends:
lombok.jar is a very good programming tool software. I secretly tell you that I also use this software, and I don’t tell others about it! Powerful, green and safe. Huajun Software Park also provides you withFast table software,AlphaEbot action editing software,He Xiaoxiang programming client,Easy GUI,Little turtle LOGO languageWaiting for you to download.
it works
it works
it works