jdk/src/share/classes/sun/management/GcInfoCompositeData.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 401 ef01e0dccd63
child 4173 d01972926813
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: 401
diff changeset
     2
 * Copyright 2004-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 sun.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.management.MemoryUsage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.InvalidObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.openmbean.CompositeType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.management.openmbean.CompositeData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import javax.management.openmbean.CompositeDataSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import javax.management.openmbean.TabularData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.management.openmbean.SimpleType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.management.openmbean.OpenType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.management.openmbean.OpenDataException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import com.sun.management.GcInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * A CompositeData for GcInfo for the local management support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * This class avoids the performance penalty paid to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * construction of a CompositeData use in the local case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
public class GcInfoCompositeData extends LazyCompositeData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private final GcInfo info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private final GcInfoBuilder builder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private final Object[] gcExtItemValues;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public GcInfoCompositeData(GcInfo info,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                        GcInfoBuilder builder,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                        Object[] gcExtItemValues) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        this.info = info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        this.builder = builder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        this.gcExtItemValues = gcExtItemValues;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public GcInfo getGcInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        return info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    protected CompositeData getCompositeData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        // baseGcInfoItemNames!
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        final Object[] baseGcInfoItemValues;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            baseGcInfoItemValues = new Object[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                new Long(info.getId()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                new Long(info.getStartTime()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                new Long(info.getEndTime()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                new Long(info.getDuration()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                memoryUsageMapType.toOpenTypeData(info.getMemoryUsageBeforeGc()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                memoryUsageMapType.toOpenTypeData(info.getMemoryUsageAfterGc()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
    83
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        // Get the item values for the extension attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        final int gcExtItemCount = builder.getGcExtItemCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        if (gcExtItemCount == 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            gcExtItemValues != null && gcExtItemValues.length != 0) {
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
    90
            throw new AssertionError("Unexpected Gc Extension Item Values");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (gcExtItemCount > 0 && (gcExtItemValues == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
             gcExtItemCount != gcExtItemValues.length)) {
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
    95
            throw new AssertionError("Unmatched Gc Extension Item Values");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        Object[] values = new Object[baseGcInfoItemValues.length +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                     gcExtItemCount];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        System.arraycopy(baseGcInfoItemValues, 0, values, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                         baseGcInfoItemValues.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (gcExtItemCount > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            System.arraycopy(gcExtItemValues, 0, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                             baseGcInfoItemValues.length, gcExtItemCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            return new CompositeDataSupport(builder.getGcInfoCompositeType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                                            builder.getItemNames(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                            values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   114
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private static final String ID                     = "id";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private static final String START_TIME             = "startTime";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private static final String END_TIME               = "endTime";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    private static final String DURATION               = "duration";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private static final String MEMORY_USAGE_BEFORE_GC = "memoryUsageBeforeGc";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private static final String MEMORY_USAGE_AFTER_GC  = "memoryUsageAfterGc";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    private static final String[] baseGcInfoItemNames = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        ID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        START_TIME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        END_TIME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        DURATION,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        MEMORY_USAGE_BEFORE_GC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        MEMORY_USAGE_AFTER_GC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    private static MappedMXBeanType memoryUsageMapType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            Method m = GcInfo.class.getMethod("getMemoryUsageBeforeGc");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            memoryUsageMapType =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                MappedMXBeanType.getMappedType(m.getGenericReturnType());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        } catch (NoSuchMethodException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   144
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   147
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    static String[] getBaseGcInfoItemNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return baseGcInfoItemNames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    private static OpenType[] baseGcInfoItemTypes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    static synchronized OpenType[] getBaseGcInfoItemTypes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (baseGcInfoItemTypes == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            baseGcInfoItemTypes = new OpenType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                SimpleType.LONG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                SimpleType.LONG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                SimpleType.LONG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                SimpleType.LONG,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                memoryUsageOpenType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                memoryUsageOpenType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return baseGcInfoItemTypes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public static long getId(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return getLong(cd, ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public static long getStartTime(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return getLong(cd, START_TIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public static long getEndTime(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        return getLong(cd, END_TIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public static Map<String, MemoryUsage>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            getMemoryUsageBeforeGc(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            return cast(memoryUsageMapType.toJavaTypeData(td));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   189
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   192
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    @SuppressWarnings("unchecked")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public static Map<String, MemoryUsage> cast(Object x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return (Map<String, MemoryUsage>) x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public static Map<String, MemoryUsage>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            getMemoryUsageAfterGc(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            //return (Map<String,MemoryUsage>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return cast(memoryUsageMapType.toJavaTypeData(td));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        } catch (InvalidObjectException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   208
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            // Should never reach here
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   211
            throw new AssertionError(e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Returns true if the input CompositeData has the expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * CompositeType (i.e. contain all attributes with expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * names and types).  Otherwise, return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public static void validateCompositeData(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (cd == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            throw new NullPointerException("Null CompositeData");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (!isTypeMatched(getBaseGcInfoCompositeType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                           cd.getCompositeType())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
           throw new IllegalArgumentException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                "Unexpected composite type for GcInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    // This is only used for validation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    private static CompositeType baseGcInfoCompositeType = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    private static synchronized CompositeType getBaseGcInfoCompositeType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (baseGcInfoCompositeType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                baseGcInfoCompositeType =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                    new CompositeType("sun.management.BaseGcInfoCompositeType",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                                      "CompositeType for Base GcInfo",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                                      getBaseGcInfoItemNames(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                                      getBaseGcInfoItemNames(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                      getBaseGcInfoItemTypes());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            } catch (OpenDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                // shouldn't reach here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                throw Util.newException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return baseGcInfoCompositeType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
}