Skip to content

ClassUtils.forName() does not support multi-dimensional arrays [SPR-6057] #10726

@spring-projects-issues

Description

@spring-projects-issues

Manuel Dominguez Sarmiento opened SPR-6057 and commented

We've attempted to optimize serialization overhead on remoting by stripping ObjectStreamClass objects and replacing them with simple class name by overriding writeClassDescriptor() on ObjectOutputStreams, and using ClassUtils.forName() when overriding readClassDescriptor() on ObjectInputStreams. Out first attempt actually used Class.forName() but of course this did not support primitives nor arrays.

For a brief instant we thought we had this fixed by using ClassUtils.forName(), however we've found that multi-dimensional arrays are not correctly handled. For instanct, short[][] is internally represented as [[S, while String[][][] is represented as [[[java.lang.String;

We resolved this by relying instead on Apache Commons - their ClassUtils.getClass() implementation works correctly even in these cases. This is not a problem for our project since Commons was already a widely used dependency, but other projects would benefit from Spring having this fixed. Multi-dimensional arrays are particularly prominent in graphics and scientific applications.


Affects: 2.5.6

Referenced from: commits a03ca86

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions