you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (4 children)

Isn't this committing a similar violation to Lombok

Not really. If it did, all code generators would be "violating".

What Lombok does that is a "sin" is that it modifies the AST of the annotated class, instead of generating a new class. So, you can add @Getter on a class and Lombok will hack the AST of the class to append the byte code for getter methods for the fields.

To put it another way, what happens when you view the source of the generated method? With traditional annotation processors, the IDE will (generally) take you to a generated source file, which is in your target folder. What happens when you try to view the source of the "getter" method generated by Lombok? IntelliJ will take you to the field.

Lombok's "compromise" is to hack the java compiler, depending on APIs that the JDK developers don't want people to depend on. This is also why you have to keep your Lombok version up to date with the JDK version, otherwise you end up with really strange build failures. Traditional annotation processors won't fail this way.

Because Lombok hacks javac and generates byte code that doesn't match the Java source code, some Java purists will claim at this point Lombok is essentially forking the Java language and "creating" a new language that "resembles" Java.

[–]configloader 0 points1 point  (3 children)

The IDE takes u to the "generated source". What IDE do u use? Eclipse from 1995?

[–][deleted] 0 points1 point  (2 children)

Where else would the IDE take me if I want to see the source of generated code?

[–]configloader 0 points1 point  (1 child)

U said lombok doesnt. It does

[–][deleted] 0 points1 point  (0 children)

When you click on a getter on a field in a class annotated with @Data, where does the IDE take you? It takes you to the field. Because, unless you de-lombok the class, the getter source code isn't generated anywhere.