r/java • u/FrankCodeWriter • Oct 17 '26
Killing Reflection at Build Time: Avro, Codename One and Java Code Generation (Foojay Podcast #103)
https://www.youtube.com/watch?v=smHzWWNOyMUIn this episode of the Foojay Podcast, Dmitry Moskalyuk and Shai Almog compare how they cut runtime reflection out of very different projects.
Dmitry runs a backend model layer that takes JSON, XML, YAML and TOML and converts it all to Avro. His choice between Jackson and kotlinx.serialization came down to where the reflection cost actually hides. Shai works on the Codename One code generation pipeline, which aims for no reflection, no service loader and no Class.forName.
Topics include Jackson Blackbird versus kotlinx.serialization, the missing unknown-fields feature that sent one team back to Jackson, generated code (Lombok, Manifold, jOOQ), what Records and Project Leyden change, and build time cost versus runtime cost.
Available in your favorite podcast app and on YouTube:
YouTube: https://www.youtube.com/watch?v=smHzWWNOyMU
Disclosure: I host the Foojay Podcast.
View all comments
Show parent comment
3
u/shai_almog Oct 18 '26
That is true. It went through hell and is probably on the other side. To be clear, the server powering our cloud currently uses Jackson and I sleep well at night. We'll replace it with our own backend mostly for dogfooding, not because of any problem with Jackson.
The problem is in the whole picture. Log4j had a small nothingburger feature that everyone forgot even existed. AI will enable deep transitive vulnerabilities that can leverage things we might not expect. It can also be used to plant very subtle vulnerabilities that can be chained together for deep hidden supply chain attacks.
Reflection, classloading, serialization etc. are all very powerful tools and powerful tools can be used by an attacker. The questions are:
I think the answer for 1 is: usually not in production. But in some cases you do, e.g. if you need deep observability etc. I would argue that if you don't need them they are probably not the right tool as there are better approaches.
A big pain for me is the runtime failures that you get when using reflection (specifically in Spring). Give me a compilation failure over a runtime or startup issue any day.
The answer for 2 is more complex:
a. It's a risk. Not an immediate one, but a potential one.
b. There's a cost in performance if you care about startup speed etc. Not in runtime if these are used correctly and with a JIT.
c. They break obfuscation so things like client side development just doesn't work great.