News for hackers. Stuff that matters.
Re:Java’s Cultural Problem by pjmlp on Monday September 19, 2022 @07:43AM (#32897020)
The poster child of AOP, I guess that isn't magic.
Re:Java’s Cultural Problem by krzyk on Monday September 19, 2022 @07:45AM (#32897033)
AOP is magic, you don't know what, where and how.

AOP should end at `@Override`, all the rest turns Java into some kind of DSL which makes it unreadable (similar to what some people do to Scala, because it is too easy to make it into a DSL).

Poster child of AOP is logging, you log stuff, don't change the code (e.g. adding validation).

Re:Java’s Cultural Problem by kaba0 on Monday September 19, 2022 @08:25AM (#32897375)
You can’t change code either in Java — annotation processors are explicitly unable to do that — Spring’s magic works through loading new classes up that either implement the same static interface you use, or extending the class, and injecting this new proxy instead.

In short, if you want to log certain methods at enter and exit time with AOP (not manually adding it everywhere), you just create a proxy object and do a logEnter(); targetedObj.method(); logExit();

That’s why some people dislike Lombok as that actually changes byte code at compile time.

Re:Java’s Cultural Problem by samus on Monday September 19, 2022 @08:40AM (#32897544)
The bytecode format is well-documented. If Lombok would just augment these, then there would be no major problem with it. But it actually does something worse: it uses reflection and other tricks to extend the Abstract Syntax Tree, which is purely an implementation detail of the Java compiler. And it must do the same with every tool that touches Java Sources.