jdk/src/jdk.management/share/classes/com/sun/management/GcInfo.java
author sjiang
Fri, 17 Apr 2015 09:40:02 +0200
changeset 30355 e37c7eba132f
parent 25859 jdk/src/java.management/share/classes/com/sun/management/GcInfo.java@3317bb8137f4
child 30365 551470085a1d
permissions -rw-r--r--
8042901: Allow com.sun.management to be in a different module to java.lang.management Reviewed-by: mchung, dfuchs, erikj, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
30355
e37c7eba132f 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 25859
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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.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 javax.management.openmbean.CompositeData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.management.openmbean.CompositeDataView;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.management.openmbean.CompositeType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Map;
30355
e37c7eba132f 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 25859
diff changeset
    36
import com.sun.management.internal.GcInfoCompositeData;
e37c7eba132f 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 25859
diff changeset
    37
import com.sun.management.internal.GcInfoBuilder;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Garbage collection information.  It contains the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * information for one garbage collection as well as GC-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * attributes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *   <li>Start time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *   <li>End time</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *   <li>Duration</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *   <li>Memory usage before the collection starts</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *   <li>Memory usage after the collection ends</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <tt>GcInfo</tt> is a {@link CompositeData CompositeData}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * The GC-specific attributes can be obtained via the CompositeData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * interface.  This is a historical relic, and other classes should
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * not copy this pattern.  Use {@link CompositeDataView} instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <h4>MXBean Mapping</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <tt>GcInfo</tt> is mapped to a {@link CompositeData CompositeData}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * with attributes as specified in the {@link #from from} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @author  Mandy Chung
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 */
20742
4ae78e8060d6 8008662: Add @jdk.Exported to JDK-specific/exported APIs
alanb
parents: 5506
diff changeset
    66
@jdk.Exported
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
public class GcInfo implements CompositeData, CompositeDataView {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private final long index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private final long startTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private final long endTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private final Map<String, MemoryUsage> usageBeforeGc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private final Map<String, MemoryUsage> usageAfterGc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private final Object[] extAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private final CompositeData cdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private final GcInfoBuilder builder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private GcInfo(GcInfoBuilder builder,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                   long index, long startTime, long endTime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                   MemoryUsage[] muBeforeGc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                   MemoryUsage[] muAfterGc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                   Object[] extAttributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this.builder       = builder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        this.index         = index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        this.startTime     = startTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        this.endTime       = endTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        String[] poolNames = builder.getPoolNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        this.usageBeforeGc = new HashMap<String, MemoryUsage>(poolNames.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        this.usageAfterGc = new HashMap<String, MemoryUsage>(poolNames.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        for (int i = 0; i < poolNames.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            this.usageBeforeGc.put(poolNames[i],  muBeforeGc[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            this.usageAfterGc.put(poolNames[i],  muAfterGc[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        this.extAttributes = extAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        this.cdata = new GcInfoCompositeData(this, builder, extAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private GcInfo(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        GcInfoCompositeData.validateCompositeData(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this.index         = GcInfoCompositeData.getId(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        this.startTime     = GcInfoCompositeData.getStartTime(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this.endTime       = GcInfoCompositeData.getEndTime(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        this.usageBeforeGc = GcInfoCompositeData.getMemoryUsageBeforeGc(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        this.usageAfterGc  = GcInfoCompositeData.getMemoryUsageAfterGc(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        this.extAttributes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        this.builder       = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        this.cdata         = cd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Returns the identifier of this garbage collection which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * the number of collections that this collector has done.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @return the identifier of this garbage collection which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * the number of collections that this collector has done.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public long getId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        return index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Returns the start time of this GC in milliseconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * since the Java virtual machine was started.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @return the start time of this GC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public long getStartTime() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        return startTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Returns the end time of this GC in milliseconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * since the Java virtual machine was started.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @return the end time of this GC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public long getEndTime() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        return endTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Returns the elapsed time of this GC in milliseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @return the elapsed time of this GC in milliseconds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public long getDuration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        return endTime - startTime;
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
     * Returns the memory usage of all memory pools
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * at the beginning of this GC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * This method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * a <tt>Map</tt> of the name of a memory pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * to the memory usage of the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * memory pool before GC starts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @return a <tt>Map</tt> of memory pool names to the memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * usage of a memory pool before GC starts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public Map<String, MemoryUsage> getMemoryUsageBeforeGc() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        return Collections.unmodifiableMap(usageBeforeGc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Returns the memory usage of all memory pools
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * at the end of this GC.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * This method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * a <tt>Map</tt> of the name of a memory pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * to the memory usage of the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * memory pool when GC finishes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @return a <tt>Map</tt> of memory pool names to the memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * usage of a memory pool when GC finishes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public Map<String, MemoryUsage> getMemoryUsageAfterGc() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        return Collections.unmodifiableMap(usageAfterGc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Returns a <tt>GcInfo</tt> object represented by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * given <tt>CompositeData</tt>. The given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <tt>CompositeData</tt> must contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * all the following attributes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <table border>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *   <th align=left>Attribute Name</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *   <th align=left>Type</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *   <td>index</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *   <td><tt>java.lang.Long</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *   <td>startTime</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *   <td><tt>java.lang.Long</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *   <td>endTime</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *   <td><tt>java.lang.Long</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *   <td>memoryUsageBeforeGc</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *   <td><tt>javax.management.openmbean.TabularData</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *   <td>memoryUsageAfterGc</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *   <td><tt>javax.management.openmbean.TabularData</tt></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @throws IllegalArgumentException if <tt>cd</tt> does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *   represent a <tt>GcInfo</tt> object with the attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *   described above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @return a <tt>GcInfo</tt> object represented by <tt>cd</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * if <tt>cd</tt> is not <tt>null</tt>; <tt>null</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public static GcInfo from(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        if (cd == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        if (cd instanceof GcInfoCompositeData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            return ((GcInfoCompositeData) cd).getGcInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            return new GcInfo(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    // Implementation of the CompositeData interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public boolean containsKey(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return cdata.containsKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public boolean containsValue(Object value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        return cdata.containsValue(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return cdata.equals(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public Object get(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return cdata.get(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public Object[] getAll(String[] keys) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return cdata.getAll(keys);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public CompositeType getCompositeType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        return cdata.getCompositeType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return cdata.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        return cdata.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
25798
0b2f54e47bc4 8054050: Fix stay raw and unchecked lint warnings in core libs
darcy
parents: 23010
diff changeset
   269
    public Collection<?> values() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        return cdata.values();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <p>Return the {@code CompositeData} representation of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * {@code GcInfo}, including any GC-specific attributes.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * returned value will have at least all the attributes described
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * in the {@link #from(CompositeData) from} method, plus optionally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * other attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @param ct the {@code CompositeType} that the caller expects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * This parameter is ignored and can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @return the {@code CompositeData} representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    public CompositeData toCompositeData(CompositeType ct) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        return cdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
}