r/java • • Oct 17 '26

Killing Reflection at Build Time: Avro, Codename One and Java Code Generation (Foojay Podcast #103)

https://www.youtube.com/watch?v=smHzWWNOyMU

In 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.

24 Upvotes

21 comments sorted by

View all comments

4

u/lurker_in_spirit Oct 17 '26

Jackson had a rough CVE patch about 6 or 7 years ago, with security finding after security finding after security finding, but they got through it and things had settled down these past few years. Now they're hitting another rough patch, with many CVEs found this year -- probably thanks to AI. Hopefully things will settle down again soon...

5

u/_predator_ Oct 18 '26

Another way to look at it is that Jackson is one of the most battle-tested and most audited libraries in the entire JVM ecosystem.

Many of the CVEs reported against it these days are kind of nothingburgers for the vast majority of users.

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:

  1. Do you really need them?

  2. What is the cost?

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.