United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6367912 : The description of field "originalType" in MXBean javadoc is inconsistent with Descriptor's spec

Details
Type:
Bug
Submit Date:
2005-12-30
Status:
Resolved
Updated Date:
2012-03-23
Project Name:
JDK
Resolved Date:
2006-04-14
Component:
core-svc
OS:
generic
Sub-Component:
javax.management
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Duplicate:
Duplicate:

Sub Tasks

Description
"MBeanInfo contents for an MXBean" section in MXBean specification has the following sentence:
-- 
The Descriptor for each of these objects will also have a field originalType that is a
string representing the Java type that appeared in the MXBean interface. *For a generic
Java type, this is the string returned by toString()*. For a class or primitive type, this
is the string returned by Class.getName().
-- 
  About "For a generic Java type, this is the string returned by toString()"...
  The javadoc for javax.management.Descriptor says:

-- 
originalType:
For a non-generic type, the string value is the value returned by Class.getName(). For a
parameterized type such as Map<String,Integer> it is *a string representation of the type,
with the raw type followed by the actual type arguments in angle brackets separated by
commas without spaces*, for example "java.util.Map<java.lang.String,java.lang.Integer>".
-- 

  Consider the type: List<String>
  The originalType:  "java.util.List<java.lang.String>"
  - and this won't be returned by var.getClass().toString()

                                    

Comments
EVALUATION

We need to specify type names for "originalType", and also in the typeName for a TabularType or CompositeType that is mapped from an original type.  This should be a new section in the MXBean specification.
                                     
2006-03-15
SUGGESTED FIX

Proposed spec is the following (in doc comments for javax.management.MXBean):

---
Type Names

Sometimes the unmapped type T of a method parameter or return value in an MXBean must be represented as a string. If T is a non-generic type, this string is the value returned by Class.getName(). Otherwise it is the value of genericstring(T), defined as follows:

    * If T is a non-generic non-array type, genericstring(T) is value returned by Class.getName(), for example "int" or "java.lang.String".
    * If T is an array E[], genericstring(T) is genericstring(E) followed by "[]". For example, genericstring(int[]) is "int[]", and genericstring(List<String>[][]) is "java.util.List<java.lang.String>[][]".
    * Otherwise, T is a parameterized type such as List<String> and genericstring(T) consists of the following: the fully-qualified name of the parameterized type as returned by Class.getName(); a left angle bracket ("<"); genericstring(A) where A is the first type parameter; if there is a second type parameter B then ", " (a comma and a single space) followed by genericstring(B); a right angle bracket (">"). 

Note that if a method returns int[], this will be represented by the string "[I" returned by Class.getName(), but if a method returns List<int[]>, this will be represented by the string "java.util.List<int[]>".
---

This is simpler than a full specification for all possible java.lang.reflect.Type objects, because not all such objects can arise here.  For example, parameterized types can only have one or two parameters.
                                     
2006-03-17



Hardware and Software, Engineered to Work Together