Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Aug 31, 2009 · 1 comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Rob Harrop commented

Manuel,

This is fixed in trunk now. You can see the ClassUtilsTests.testForName() to see the scenarios we are testing.

Rob

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant