Skip to content

Consider removing "optimization" of handling Class<?> from TypeFactory.fromParamType #3443

Closed
@kostislav

Description

@kostislav

I wanted to create a custom deserializer for Class<? extends Something> that would check the upper bound and throw an exception if it did not match. Easy enough, I thought, just a simple contextual deserializer.
But, the type kept coming in as a SimpleType without any generic arguments.

After some digging, I found that it is because of a special-case in TypeFactory.fromParamType that strips the generic arguments from Enum, Comparable and Class. While I agree that for the first two the type arguments aren't really useful, they sometimes would be for Class.

Please consider whether these "performance reasons" are worth the unintuitive (and possibly undocumented?) behavior.

Currently, the only way is to subclass TypeFactory to skip the special handling (but subclassing TypeFactory from another package is pretty painful thanks to its "mutant factory methods").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions