jdk/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 687 874e25a9844a
child 1510 e747d3193ef2
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
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;
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    34
import javax.management.openmbean.MXBeanMapping;
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    35
import javax.management.openmbean.MXBeanMappingFactory;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.openmbean.OpenDataException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.management.openmbean.OpenType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
final class ConvertingMethod {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    40
    static ConvertingMethod from(Method m, MXBeanMappingFactory mappingFactory) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    42
            return new ConvertingMethod(m, mappingFactory);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        } catch (OpenDataException ode) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
            final String msg = "Method " + m.getDeclaringClass().getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
                "." + m.getName() + " has parameter or return type that " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                "cannot be translated into an open type";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            throw new IllegalArgumentException(msg, ode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    Method getMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        return method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    Descriptor getDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        return Introspector.descriptorForElement(method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    Type getGenericReturnType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        return method.getGenericReturnType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    Type[] getGenericParameterTypes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        return method.getGenericParameterTypes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        return method.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    OpenType getOpenReturnType() {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    72
        return returnMapping.getOpenType();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    OpenType[] getOpenParameterTypes() {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    76
        final OpenType[] types = new OpenType[paramMappings.length];
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    77
        for (int i = 0; i < paramMappings.length; i++)
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    78
            types[i] = paramMappings[i].getOpenType();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return types;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /* Check that this method will be callable when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * open types to Java types, for example when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * an MXBean wrapper to the underlying resource.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * The parameters will be converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Java types, so they must be "reconstructible".  The return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * value will be converted to an Open Type, so if it is convertible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * at all there is no further check needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    90
    void checkCallFromOpen() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    92
            for (MXBeanMapping paramConverter : paramMappings)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                paramConverter.checkReconstructible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            throw new IllegalArgumentException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /* Check that this method will be callable when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Java types to open types, for example when we are going from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * an MXBean proxy to the open types that it will be mapped to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * The return type will be converted back to a Java type, so it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * must be "reconstructible".  The parameters will be converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * open types, so if it is convertible at all there is no further
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * check needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   107
    void checkCallToOpen() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   109
            returnMapping.checkReconstructible();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            throw new IllegalArgumentException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    String[] getOpenSignature() {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   116
        if (paramMappings.length == 0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            return noStrings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   119
        String[] sig = new String[paramMappings.length];
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   120
        for (int i = 0; i < paramMappings.length; i++)
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   121
            sig[i] = paramMappings[i].getOpenClass().getName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return sig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    final Object toOpenReturnValue(MXBeanLookup lookup, Object ret)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            throws OpenDataException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   127
        return returnMapping.toOpenValue(ret);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    final Object fromOpenReturnValue(MXBeanLookup lookup, Object ret)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            throws InvalidObjectException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   132
        return returnMapping.fromOpenValue(ret);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    final Object[] toOpenParameters(MXBeanLookup lookup, Object[] params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            throws OpenDataException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if (paramConversionIsIdentity || params == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            return params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        final Object[] oparams = new Object[params.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        for (int i = 0; i < params.length; i++)
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   141
            oparams[i] = paramMappings[i].toOpenValue(params[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return oparams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   145
    final Object[] fromOpenParameters(Object[] params)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            throws InvalidObjectException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (paramConversionIsIdentity || params == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            return params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        final Object[] jparams = new Object[params.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        for (int i = 0; i < params.length; i++)
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   151
            jparams[i] = paramMappings[i].fromOpenValue(params[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return jparams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    final Object toOpenParameter(MXBeanLookup lookup,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                 Object param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                 int paramNo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        throws OpenDataException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   159
        return paramMappings[paramNo].toOpenValue(param);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    final Object fromOpenParameter(MXBeanLookup lookup,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                                   Object param,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                                   int paramNo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        throws InvalidObjectException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   166
        return paramMappings[paramNo].fromOpenValue(param);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    Object invokeWithOpenReturn(MXBeanLookup lookup,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                                Object obj, Object[] params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            throws MBeanException, IllegalAccessException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                   InvocationTargetException {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   173
        MXBeanLookup old = MXBeanLookup.getLookup();
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   174
        try {
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   175
            MXBeanLookup.setLookup(lookup);
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   176
            return invokeWithOpenReturn(obj, params);
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   177
        } finally {
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   178
            MXBeanLookup.setLookup(old);
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
    }
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   181
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   182
    private Object invokeWithOpenReturn(Object obj, Object[] params)
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   183
            throws MBeanException, IllegalAccessException,
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   184
                   InvocationTargetException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        final Object[] javaParams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   187
            javaParams = fromOpenParameters(params);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            // probably can't happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            final String msg = methodName() + ": cannot convert parameters " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                "from open values: " + e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            throw new MBeanException(e, msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        final Object javaReturn = method.invoke(obj, javaParams);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        try {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   196
            return returnMapping.toOpenValue(javaReturn);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            // probably can't happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            final String msg = methodName() + ": cannot convert return " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                "value to open value: " + e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            throw new MBeanException(e, msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    private String methodName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return method.getDeclaringClass() + "." + method.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   209
    private ConvertingMethod(Method m, MXBeanMappingFactory mappingFactory)
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   210
    throws OpenDataException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        this.method = m;
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   212
        returnMapping =
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   213
                mappingFactory.mappingForType(m.getGenericReturnType(), mappingFactory);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        Type[] params = m.getGenericParameterTypes();
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   215
        paramMappings = new MXBeanMapping[params.length];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        boolean identity = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        for (int i = 0; i < params.length; i++) {
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   218
            paramMappings[i] = mappingFactory.mappingForType(params[i], mappingFactory);
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   219
            identity &= DefaultMXBeanMappingFactory.isIdentity(paramMappings[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        paramConversionIsIdentity = identity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    private static final String[] noStrings = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    private final Method method;
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   227
    private final MXBeanMapping returnMapping;
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   228
    private final MXBeanMapping[] paramMappings;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    private final boolean paramConversionIsIdentity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
}