Closed yawkat closed 3 years ago
There isn't really much in way of general-purpose machinery, but yes, technique used is to isolate functionality that relates to new class into wrapper class, and then try to load that class, catch exception. Usually helper class implements some safe interface through which methods are dispatches (access to (de)serializer instances, directly, or to lookup methods)
Jackson-databind package com.fasterxml.jackson.databind.ext
has some of these; not sure if they are good examples but seem to work.
I've added this to 2.13 for now. I don't think backporting to 2.12 is a good idea, because the changed dependency version could break builds for some people (though explicitly using an older version and ignoring the transitive dep through jackson-datatype-eclipse-collections still works), and this feature isn't urgent enough to warrant that. Do you agree?
Merged to 3.0 as well, with some adjustments in the code to use createContextual, similar to how you ported PairInstantiator.
Agreed wrt 2.12: dependency change, added functionality does sound more like minor version change.
One quick ask: could add a reference to release-notes/VERSION-2.x
as well? And if so, maybe on https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.13 as well -- although I can do latter based on release notes.
Done in 3913800effe8f35bdb41eb14bc2155f226a9733e and e919050e4ecf976bc1b2c328e9b127c696f30abd. I don't have write access to the wiki, so probably easier if you do it than making a PR :)
Eclipse-collections added a
Triple
class in version 10 and I want to add support for it. This should be straight-forward in principle.The only issue is that because EC upgrades have some (albeit small) incompatibilities, I don't want to require a newer version, or require the presence of the new class. @cowtowncoder , what is the usual way to add a (de)serializer only if a certain class is present? My first guess would be just catching NoClassDefFoundError, but maybe there's existing machinery.