JDK-6367903 : Wrong value of "originalType" field in MXBean's Descriptor
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2005-12-30
  • Updated: 2012-03-23
  • Resolved: 2006-04-11
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
6Resolved
Related Reports
Duplicate :  
Description
When dealing with parametrized types, the value of "originalType" field in MXBean's descriptor may contain extra spaces. E.g. the present moment the type

  Map<String, Byte>

is represented in descriptor as "java.util.Map<java.lang.String, java.lang.Byte>".
While the spec says:
--
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>".
--

The following code demonstrates the above-stated:
==============================================================================================
/* Main.java */

import java.util.Map;
import javax.management.Descriptor;
import javax.management.JMX;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;

public class Main {
    
    public static void main(String[] args) {
        Main instance = new Main();
        
        instance.m1();
    }
    

    void m1() {
       try {
            MBeanServer mbs = MBeanServerFactory.newMBeanServer();
            ObjectName genericObjectName = new ObjectName("test:type=MapTypeMXBean");
            
            Test tst = new Test();
            mbs.registerMBean(tst, genericObjectName);

            MBeanInfo mbi = mbs.getMBeanInfo(genericObjectName);
            MBeanAttributeInfo[] mbai = mbi.getAttributes();
            
            for (int i=0; i<mbai.length; i++) {
                if (mbai[i].getName().equals("Map")) {
                    Descriptor desc = mbai[i].getDescriptor();
                    System.out.println("originalType: " + desc.getFieldValue(JMX.ORIGINAL_TYPE_FIELD));
                }
            }

        } catch (Throwable e) {
            e.printStackTrace();
        }        
    }
    
    public interface TestMXBean {
        Map<String, Byte> getMap();
    }
    
    public static class Test implements TestMXBean {
        
        public Map<String, Byte> getMap() {
            return null;
        }
    }
}
==============================================================================================

Output:
==============================================================================================
...
run-single:
originalType: java.util.Map<java.lang.String, java.lang.Byte>
BUILD SUCCESSFUL (total time: 1 second)
==============================================================================================

Comments
EVALUATION The final decision is the spec change. See suggested fix for CR 6367912 for more details.
11-04-2006

EVALUATION The underlying problem here is that the toString() of java.lang.reflect.ParameterizedType is not specified. The Descriptor spec captures what this toString() was at one stage (or what I thought it was), but this is too fragile. The code should instead reconstruct what sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.toString() does, but without the space. (Or the spec should be changed to include the space, but we probably still want to reimplement rather than relying on unspecified behaviour.)
30-12-2005