JDK-5045358 : Open MBeans cannot reference primitive data types or arrays thereof
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-05-11
  • Updated: 2017-05-16
  • Resolved: 2005-05-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b37Fixed
Related Reports
Relates :  
Relates :  
Description
The set of types that can be referenced by an Open MBean is by design
limited.  It includes the primitive wrapper types such as java.lang.Integer
and java.lang.Boolean.  However, it does not include the primitive types
such as int and boolean.  When the type is just Integer or Boolean there
is no great difference to a client, because reflection treats this the
same as int or boolean anyway.  But when it is Integer[] or Boolean[] it
is inconvenient and inefficient.

The suggested change is to define new constants in the SimpleType class
called PRIMITIVE_INT, PRIMITIVE_BOOLEAN, etc, to complement the existing
constants INTEGER, BOOLEAN, etc.

The serial form of these classes will set a new serializable boolean field
"primitive" to true and will have a type name that is the corresponding
wrapper class, e.g. java.lang.Integer for int.  This will mean that interoperation with JMX API implementations that predate this change will be possible.  Such implementations will ignore this field, so they will see a
java.lang.Integer instead of an int.  This will potentially cause problems
for int[] etc (seen as Integer[]) but not for plain int.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
01-09-2004

PUBLIC COMMENTS Open MBeans can reference java.lang.Integer but not plain int, etc.
01-09-2004

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
27-08-2004