EVALUATION
Requires API change so cannot be changed before Mustang.
###@###.### 2004-05-11
Changing SimpleType so it supports primitive types is probably not the best approach. All we are really interested in is *arrays* of primitive types. There is no difference between int and Integer when they are the type of an attribute, parameter, or return value. An int will be wrapped as an Integer anyway since everything is happening through reflection. On the other hand, there *is* a difference between int[] and Integer[]. int[] is considerably more efficient in space and time, but is not currently expressible as an OpenType. So the idea would be to extend ArrayType rather than SimpleType such that you can describe int[] etc with it. For example, we could add a factory method to ArrayType:
public static ArrayType primitiveArray(Class<?> arrayClass)
or, in its generified form (see 4847959):
public static ArrayType<T> primitiveArray(Class<T> arrayClass)
Thus, you could obtain an instance of the appropriate Open Type for int[]
using ArrayType.primitiveArray(int[].class).
ArrayType.getElementOpenType() would return SimpleType.INTEGER, so it would
look very like an Integer[], but there would be an additional method
public boolean isPrimitiveArray()
which would return true for one but not the other. This would be reflected
in the serial form by a new field
private boolean primitive;
Previous versions of the API would lack this field so would deserialize
an int[] as an Integer[]. This will often work, for example if arrays
are ready using java.lang.reflect.Array, but will occasionally cause
ClassCastExceptions. This only applies to "generic" (model-neutral)
clients, since models that use int[] as an Open Type are necessarily
new and existing model-specific clients cannot know those new models.
###@###.### 2004-08-27
|