src/java.base/share/classes/java/io/ObjectStreamField.java
changeset 58288 48e480e56aad
parent 47216 71c04702a3d5
equal deleted inserted replaced
58287:a7f16447085e 58288:48e480e56aad
     1 /*
     1 /*
     2  * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    58     /** offset of field value in enclosing field group */
    58     /** offset of field value in enclosing field group */
    59     private int offset;
    59     private int offset;
    60 
    60 
    61     /**
    61     /**
    62      * Create a Serializable field with the specified type.  This field should
    62      * Create a Serializable field with the specified type.  This field should
    63      * be documented with a <code>serialField</code> tag.
    63      * be documented with a {@code serialField} tag.
    64      *
    64      *
    65      * @param   name the name of the serializable field
    65      * @param   name the name of the serializable field
    66      * @param   type the <code>Class</code> object of the serializable field
    66      * @param   type the {@code Class} object of the serializable field
    67      */
    67      */
    68     public ObjectStreamField(String name, Class<?> type) {
    68     public ObjectStreamField(String name, Class<?> type) {
    69         this(name, type, false);
    69         this(name, type, false);
    70     }
    70     }
    71 
    71 
   195     }
   195     }
   196 
   196 
   197     /**
   197     /**
   198      * Get the name of this field.
   198      * Get the name of this field.
   199      *
   199      *
   200      * @return  a <code>String</code> representing the name of the serializable
   200      * @return  a {@code String} representing the name of the serializable
   201      *          field
   201      *          field
   202      */
   202      */
   203     public String getName() {
   203     public String getName() {
   204         return name;
   204         return name;
   205     }
   205     }
   206 
   206 
   207     /**
   207     /**
   208      * Get the type of the field.  If the type is non-primitive and this
   208      * Get the type of the field.  If the type is non-primitive and this
   209      * <code>ObjectStreamField</code> was obtained from a deserialized {@link
   209      * {@code ObjectStreamField} was obtained from a deserialized {@link
   210      * ObjectStreamClass} instance, then <code>Object.class</code> is returned.
   210      * ObjectStreamClass} instance, then {@code Object.class} is returned.
   211      * Otherwise, the <code>Class</code> object for the type of the field is
   211      * Otherwise, the {@code Class} object for the type of the field is
   212      * returned.
   212      * returned.
   213      *
   213      *
   214      * @return  a <code>Class</code> object representing the type of the
   214      * @return  a {@code Class} object representing the type of the
   215      *          serializable field
   215      *          serializable field
   216      */
   216      */
   217     @CallerSensitive
   217     @CallerSensitive
   218     public Class<?> getType() {
   218     public Class<?> getType() {
   219         if (System.getSecurityManager() != null) {
   219         if (System.getSecurityManager() != null) {
   301     public boolean isUnshared() {
   301     public boolean isUnshared() {
   302         return unshared;
   302         return unshared;
   303     }
   303     }
   304 
   304 
   305     /**
   305     /**
   306      * Compare this field with another <code>ObjectStreamField</code>.  Return
   306      * Compare this field with another {@code ObjectStreamField}.  Return
   307      * -1 if this is smaller, 0 if equal, 1 if greater.  Types that are
   307      * -1 if this is smaller, 0 if equal, 1 if greater.  Types that are
   308      * primitives are "smaller" than object types.  If equal, the field names
   308      * primitives are "smaller" than object types.  If equal, the field names
   309      * are compared.
   309      * are compared.
   310      */
   310      */
   311     // REMIND: deprecate?
   311     // REMIND: deprecate?