4 ms·
There is metaprogramming support in Java, but it's not as inviting and friendly as hygienic macros or Ruby patching. The obvious example is reflection, with whi
by cess11 1y ago
There is metaprogramming support in Java, but it's not as inviting and friendly as hygienic macros or Ruby patching. The obvious example is reflection, with which you can do a lot of bizarre things, some of which are useful sometimes. Another is annotations, which is heavily used by libraries in a way similar to how macros are used in certain Lisp like languages.
https://www.baeldung.com/java-reflection https://www.baeldung.com/java-reflection
https://www.baeldung.com/java-annotation-processing-builder https://www.baeldung.com/java-annotation-processing-builder
Then you've got the byte code itself, and there be dragons: <https://aphyr.com/posts/341-hexing-the-technical-interview https://aphyr.com/posts/341-hexing-the-technical-interview>
While you rarely see byte code shenanigans in Java code bases, it's how some other languages on the JVM achieve things like runtime metaprogramming.