Java: how to write an annotation adding a default constructor to a class

The question is already in the title, and this is a less specific version of the question that I asked earlier :

How do you write an annotation in java that adds a default constructor to a class?

+3
source share
2 answers

There is a project that is already doing this: http://projectlombok.org/

Technically, you need to connect to the Java compiler. Compiling Java code is done in stages: first, all sources are collected. Then the parser creates the AST. The code generation phase then turns the AST into a byte code.

, AST , . AST, .

: http://notatube.blogspot.com/2010/11/project-lombok-trick-explained.html

, Lombok AST, .

+3

All Articles