jdk/src/share/classes/javax/management/MBeanFeatureInfo.java
author rriggs
Tue, 12 Nov 2013 14:03:28 -0500
changeset 21656 d4c777ccb1db
parent 20174 360791181f66
child 23010 6dadb192ad81
permissions -rw-r--r--
8028014: Doclint warning/error cleanup in javax.management Summary: Improve generated html by fixing doclint warnings Reviewed-by: sla, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2006, 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 javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.StreamCorruptedException;
20174
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 14911
diff changeset
    33
import java.util.Objects;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p>Provides general information for an MBean descriptor object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * The feature described can be an attribute, an operation, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * parameter, or a notification.  Instances of this class are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * immutable.  Subclasses may be mutable but this is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * recommended.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public class MBeanFeatureInfo implements Serializable, DescriptorRead {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /* Serial version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static final long serialVersionUID = 3952882688968447265L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * The name of the feature.  It is recommended that subclasses call
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * {@link #getName} rather than reading this field, and that they
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * not change it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @serial The name of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * The human-readable description of the feature.  It is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * recommended that subclasses call {@link #getDescription} rather
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * than reading this field, and that they not change it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @serial The human-readable description of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected String description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @serial The Descriptor for this MBeanFeatureInfo.  This field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * can be null, which is equivalent to an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private transient Descriptor descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Constructs an <CODE>MBeanFeatureInfo</CODE> object.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * constructor is equivalent to {@code MBeanFeatureInfo(name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * description, (Descriptor) null}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param name The name of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @param description A human readable description of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public MBeanFeatureInfo(String name, String description) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        this(name, description, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Constructs an <CODE>MBeanFeatureInfo</CODE> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param name The name of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param description A human readable description of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param descriptor The descriptor for the feature.  This may be null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * which is equivalent to an empty descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public MBeanFeatureInfo(String name, String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                            Descriptor descriptor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        this.description = description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        this.descriptor = descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Returns the name of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @return the name of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Returns the human-readable description of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @return the human-readable description of the feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public String getDescription() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        return description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Returns the descriptor for the feature.  Changing the returned value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * will have no affect on the original descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @return a descriptor that is either immutable or a copy of the original.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public Descriptor getDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        return (Descriptor) ImmutableDescriptor.nonNullDescriptor(descriptor).clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Compare this MBeanFeatureInfo to another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @param o the object to compare to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return true if and only if <code>o</code> is an MBeanFeatureInfo such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * that its {@link #getName()}, {@link #getDescription()}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * {@link #getDescriptor()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * values are equal (not necessarily identical) to those of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * MBeanFeatureInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        if (o == this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if (!(o instanceof MBeanFeatureInfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        MBeanFeatureInfo p = (MBeanFeatureInfo) o;
20174
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 14911
diff changeset
   151
        return (Objects.equals(p.getName(), getName()) &&
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 14911
diff changeset
   152
                Objects.equals(p.getDescription(), getDescription()) &&
360791181f66 8023954: MBean*Info.equals: throw NPE
sjiang
parents: 14911
diff changeset
   153
                Objects.equals(p.getDescriptor(), getDescriptor()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return getName().hashCode() ^ getDescription().hashCode() ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
               getDescriptor().hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * Serializes an {@link MBeanFeatureInfo} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @serialData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * For compatibility reasons, an object of this class is serialized as follows.
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 20174
diff changeset
   165
     * <p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * is called first to serialize the object except the field {@code descriptor}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * which is declared as transient. The field {@code descriptor} is serialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *     <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *     <li>If {@code descriptor} is an instance of the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *        {@link ImmutableDescriptor}, the method {@link ObjectOutputStream#write
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *        write(int val)} is called to write a byte with the value {@code 1},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *        then the method {@link ObjectOutputStream#writeObject writeObject(Object obj)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *        is called twice to serialize the field names and the field values of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *        {@code descriptor}, respectively as a {@code String[]} and an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *        {@code Object[]};</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *     <li>Otherwise, the method {@link ObjectOutputStream#write write(int val)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * is called to write a byte with the value {@code 0}, then the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * {@link ObjectOutputStream#writeObject writeObject(Object obj)} is called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * to serialize directly the field {@code descriptor}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *     </ul>
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 20174
diff changeset
   183
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    private void writeObject(ObjectOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        if (descriptor != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            descriptor.getClass() == ImmutableDescriptor.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            out.write(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            final String[] names = descriptor.getFieldNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            out.writeObject(names);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            out.writeObject(descriptor.getFieldValues(names));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            out.write(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            out.writeObject(descriptor);
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * Deserializes an {@link MBeanFeatureInfo} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @serialData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * For compatibility reasons, an object of this class is deserialized as follows.
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 20174
diff changeset
   209
     * <p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * The method {@link ObjectInputStream#defaultReadObject defaultReadObject()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * is called first to deserialize the object except the field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * {@code descriptor}, which is not serialized in the default way. Then the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * {@link ObjectInputStream#read read()} is called to read a byte, the field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * {@code descriptor} is deserialized according to the value of the byte value:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *    <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *    <li>1. The method {@link ObjectInputStream#readObject readObject()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *       is called twice to obtain the field names (a {@code String[]}) and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *       the field values (a {@code Object[]}) of the {@code descriptor}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *       The two obtained values then are used to construct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *       an {@link ImmutableDescriptor} instance for the field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *       {@code descriptor};</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *    <li>0. The value for the field {@code descriptor} is obtained directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *       by calling the method {@link ObjectInputStream#readObject readObject()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *       If the obtained value is null, the field {@code descriptor} is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *       {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR};</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *    <li>-1. This means that there is no byte to read and that the object is from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *       an earlier version of the JMX API. The field {@code descriptor} is set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *       to {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR}</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *    <li>Any other value. A {@link StreamCorruptedException} is thrown.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *    </ul>
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 20174
diff changeset
   231
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        switch (in.read()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            final String[] names = (String[])in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
14911
404c8c3c91ee 6783290: MBeanInfo/MBeanFeatureInfo has inconsistent readObject/writeObject
dsamersoff
parents: 5506
diff changeset
   243
            final Object[] values = (Object[]) in.readObject();
404c8c3c91ee 6783290: MBeanInfo/MBeanFeatureInfo has inconsistent readObject/writeObject
dsamersoff
parents: 5506
diff changeset
   244
            descriptor = (names.length == 0) ?
404c8c3c91ee 6783290: MBeanInfo/MBeanFeatureInfo has inconsistent readObject/writeObject
dsamersoff
parents: 5506
diff changeset
   245
                ImmutableDescriptor.EMPTY_DESCRIPTOR :
404c8c3c91ee 6783290: MBeanInfo/MBeanFeatureInfo has inconsistent readObject/writeObject
dsamersoff
parents: 5506
diff changeset
   246
                new ImmutableDescriptor(names, values);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            descriptor = (Descriptor)in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            if (descriptor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        case -1: // from an earlier version of the JMX API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            throw new StreamCorruptedException("Got unexpected byte.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
}