jdk/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
author emcmanus
Wed, 21 Oct 2009 17:33:18 +0200
changeset 4156 acaa49a2768a
parent 1699 3611e5fd6da5
child 5506 202f599c92aa
permissions -rw-r--r--
6851617: Remove JSR 255 (JMX API 2.0) from JDK 7 Summary: See http://weblogs.java.net/blog/2009/06/16/jsr-255-jmx-api-20-postponed Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 687
diff changeset
     2
 * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jmx.mbeanserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.InvalidObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.lang.reflect.Type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.management.Descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.management.MBeanException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.management.openmbean.OpenDataException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.management.openmbean.OpenType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
final class ConvertingMethod {
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1699
diff changeset
    38
    static ConvertingMethod from(Method m) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        try {
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1699
diff changeset
    40
            return new ConvertingMethod(m);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        } catch (OpenDataException ode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
            final String msg = "Method " + m.getDeclaringClass().getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
                "." + m.getName() + " has parameter or return type that " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                "cannot be translated into an open type";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
            throw new IllegalArgumentException(msg, ode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    Method getMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        return method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    Descriptor getDescriptor() {
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1699
diff changeset
    54
        return Introspector.descriptorForElement(method);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    Type getGenericReturnType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        return method.getGenericReturnType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    Type[] getGenericParameterTypes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        return method.getGenericParameterTypes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        return method.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 715
diff changeset
    69
    OpenType<?> getOpenReturnType() {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    70
        return returnMapping.getOpenType();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 715
diff changeset
    73
    OpenType<?>[] getOpenParameterTypes() {
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 715
diff changeset
    74
        final OpenType<?>[] types = new OpenType<?>[paramMappings.length];
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    75
        for (int i = 0; i < paramMappings.length; i++)
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    76
            types[i] = paramMappings[i].getOpenType();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        return types;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /* Check that this method will be callable when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * open types to Java types, for example when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * an MXBean wrapper to the underlying resource.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * The parameters will be converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Java types, so they must be "reconstructible".  The return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * value will be converted to an Open Type, so if it is convertible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * at all there is no further check needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    88
    void checkCallFromOpen() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    90
            for (MXBeanMapping paramConverter : paramMappings)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                paramConverter.checkReconstructible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            throw new IllegalArgumentException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /* Check that this method will be callable when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Java types to open types, for example when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * an MXBean proxy to the open types that it will be mapped to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * The return type will be converted back to a Java type, so it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * must be "reconstructible".  The parameters will be converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * open types, so if it is convertible at all there is no further
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * check needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   105
    void checkCallToOpen() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   107
            returnMapping.checkReconstructible();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            throw new IllegalArgumentException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    String[] getOpenSignature() {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   114
        if (paramMappings.length == 0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            return noStrings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   117
        String[] sig = new String[paramMappings.length];
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   118
        for (int i = 0; i < paramMappings.length; i++)
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   119
            sig[i] = paramMappings[i].getOpenClass().getName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        return sig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    final Object toOpenReturnValue(MXBeanLookup lookup, Object ret)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            throws OpenDataException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   125
        return returnMapping.toOpenValue(ret);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    final Object fromOpenReturnValue(MXBeanLookup lookup, Object ret)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            throws InvalidObjectException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   130
        return returnMapping.fromOpenValue(ret);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    final Object[] toOpenParameters(MXBeanLookup lookup, Object[] params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            throws OpenDataException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (paramConversionIsIdentity || params == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            return params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        final Object[] oparams = new Object[params.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        for (int i = 0; i < params.length; i++)
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   139
            oparams[i] = paramMappings[i].toOpenValue(params[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        return oparams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   143
    final Object[] fromOpenParameters(Object[] params)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            throws InvalidObjectException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        if (paramConversionIsIdentity || params == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            return params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        final Object[] jparams = new Object[params.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        for (int i = 0; i < params.length; i++)
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   149
            jparams[i] = paramMappings[i].fromOpenValue(params[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        return jparams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    final Object toOpenParameter(MXBeanLookup lookup,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                 Object param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                                 int paramNo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        throws OpenDataException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   157
        return paramMappings[paramNo].toOpenValue(param);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    final Object fromOpenParameter(MXBeanLookup lookup,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                                   Object param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                                   int paramNo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        throws InvalidObjectException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   164
        return paramMappings[paramNo].fromOpenValue(param);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    Object invokeWithOpenReturn(MXBeanLookup lookup,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                Object obj, Object[] params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            throws MBeanException, IllegalAccessException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                   InvocationTargetException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   171
        MXBeanLookup old = MXBeanLookup.getLookup();
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   172
        try {
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   173
            MXBeanLookup.setLookup(lookup);
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   174
            return invokeWithOpenReturn(obj, params);
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   175
        } finally {
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   176
            MXBeanLookup.setLookup(old);
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   177
        }
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   178
    }
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   179
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   180
    private Object invokeWithOpenReturn(Object obj, Object[] params)
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   181
            throws MBeanException, IllegalAccessException,
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   182
                   InvocationTargetException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        final Object[] javaParams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   185
            javaParams = fromOpenParameters(params);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            // probably can't happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            final String msg = methodName() + ": cannot convert parameters " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                "from open values: " + e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            throw new MBeanException(e, msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        final Object javaReturn = method.invoke(obj, javaParams);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   194
            return returnMapping.toOpenValue(javaReturn);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            // probably can't happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            final String msg = methodName() + ": cannot convert return " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                "value to open value: " + e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            throw new MBeanException(e, msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    private String methodName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return method.getDeclaringClass() + "." + method.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1699
diff changeset
   207
    private ConvertingMethod(Method m) throws OpenDataException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        this.method = m;
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1699
diff changeset
   209
        MXBeanMappingFactory mappingFactory = MXBeanMappingFactory.DEFAULT;
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   210
        returnMapping =
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   211
                mappingFactory.mappingForType(m.getGenericReturnType(), mappingFactory);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        Type[] params = m.getGenericParameterTypes();
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   213
        paramMappings = new MXBeanMapping[params.length];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        boolean identity = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        for (int i = 0; i < params.length; i++) {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   216
            paramMappings[i] = mappingFactory.mappingForType(params[i], mappingFactory);
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   217
            identity &= DefaultMXBeanMappingFactory.isIdentity(paramMappings[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        paramConversionIsIdentity = identity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private static final String[] noStrings = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    private final Method method;
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   225
    private final MXBeanMapping returnMapping;
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   226
    private final MXBeanMapping[] paramMappings;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    private final boolean paramConversionIsIdentity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
}