jackson-databind
jackson-databind copied to clipboard
Add `MapperFeature`s for disabling Field, Method, Creator introspection for JDK classes (and backing extension point)
(note: addresses #4907 in part)
Since introspection of core JDK types (java., sun., com.sun.) and extended JDK types (javax.) can be problematic for platforms like Graal (or maybe even in future JDKs), it seems useful to be able to block some or all of it.
At the same time, a small number of JDK types (like java.lang.StackTraceElement) require introspection by JDK, we cannot simply block all such introspection (or would need to do extensive allow-listing).
So, let's introduce 6 new MapperFeatures to allow/disallow introspection of:
- Fields
- Methods (setters, getters)
- Creators (constructors, factory methods)
over
- Core JDK types
- Extended JDK types
and default so that only Field introspection is disabled by default.
This needs to go in 2.20 being API extension.
EDIT: in addition to new features, there should be new extension point that is used for features, but that can be overridden for fully-custom logic -- something like ReflectionAccessManager (etc), with default implementation that operates on features, configurable on ObjectMapper via Builder.