[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: TypeInfo.newArrayInstance problems
adrian@jboss.org
do-not-reply at jboss.com
Fri Oct 12 11:11:48 EDT 2007
For the plain Object you'd need to change your code to use something like the reflect api:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Array.html#get(java.lang.Object,%20int)
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Array.html#get(java.lang.Object,%20int)
The latter method automatically autoboxes the primitives.
| import java.lang.reflect.Array;
|
| ...
|
| Object array;
| try
| {
| array = type.newArrayInstanceObject(arrayValue.getLength());
| }
| catch (Throwable t)
| {
| throw new UndeclaredThrowableException(t);
| }
| for (int j = 0; j < Array.getLength(array); j++)
| {
| Object element = arrayValue.getValue(i);
| if (element instanceof MetaValue)
| {
| TypeInfo elementType = configuration.getTypeInfo(element.getClass());
| element = unwrap((MetaValue)element, elementType);
| }
| Array.set(array, j, element);
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4094647#4094647
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4094647
More information about the jboss-dev-forums
mailing list