src/java.rmi/share/classes/java/rmi/server/ObjID.java
author rriggs
Wed, 02 Oct 2019 13:57:03 -0400
changeset 58446 5c83830390ba
parent 53120 de9fd809bb47
permissions -rw-r--r--
8231663: Incorrect GPL header in some RMI/SQL package-info.java files Reviewed-by: bpb, iris, lancea
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) 1996, 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
package java.rmi.server;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.DataInput;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.DataOutput;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.ObjectInput;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.ObjectOutput;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.AccessController;
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 5506
diff changeset
    34
import java.security.PrivilegedAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.security.SecureRandom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.concurrent.atomic.AtomicLong;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * An <code>ObjID</code> is used to identify a remote object exported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * to an RMI runtime.  When a remote object is exported, it is assigned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * an object identifier either implicitly or explicitly, depending on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * the API used to export.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <p>The {@link #ObjID()} constructor can be used to generate a unique
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * object identifier.  Such an <code>ObjID</code> is unique over time
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * with respect to the host it is generated on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * The {@link #ObjID(int)} constructor can be used to create a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * "well-known" object identifier.  The scope of a well-known
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <code>ObjID</code> depends on the RMI runtime it is exported to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>An <code>ObjID</code> instance contains an object number (of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code>long</code>) and an address space identifier (of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * {@link UID}).  In a unique <code>ObjID</code>, the address space
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * identifier is unique with respect to a given host over time.  In a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * well-known <code>ObjID</code>, the address space identifier is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * equivalent to one returned by invoking the {@link UID#UID(short)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * constructor with the value zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
53120
de9fd809bb47 8214567: Use {@systemProperty} for definitions of system properties
rpatil
parents: 47216
diff changeset
    60
 * <p>If the system property {@systemProperty java.rmi.server.randomIDs}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * is defined to equal the string <code>"true"</code> (case insensitive),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * then the {@link #ObjID()} constructor will use a cryptographically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * strong random number generator to choose the object number of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * returned <code>ObjID</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @author      Ann Wollrath
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @author      Peter Jones
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23333
diff changeset
    68
 * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
public final class ObjID implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /** Object number for well-known <code>ObjID</code> of the registry. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static final int REGISTRY_ID = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /** Object number for well-known <code>ObjID</code> of the activator. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public static final int ACTIVATOR_ID = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Object number for well-known <code>ObjID</code> of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * the distributed garbage collector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public static final int DGC_ID = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /** indicate compatibility with JDK 1.1.x version of class */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private static final long serialVersionUID = -6386392263968365220L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private static final AtomicLong nextObjNum = new AtomicLong(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private static final UID mySpace = new UID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static final SecureRandom secureRandom = new SecureRandom();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @serial object number
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see #hashCode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    private final long objNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @serial address space identifier (unique to host over time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private final UID space;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Generates a unique object identifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <p>If the system property <code>java.rmi.server.randomIDs</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * is defined to equal the string <code>"true"</code> (case insensitive),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * then this constructor will use a cryptographically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * strong random number generator to choose the object number of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * returned <code>ObjID</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public ObjID() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
         * If generating random object numbers, create a new UID to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
         * ensure uniqueness; otherwise, use a shared UID because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
         * sequential object numbers already ensure uniqueness.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (useRandomIDs()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            space = new UID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            objNum = secureRandom.nextLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            space = mySpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            objNum = nextObjNum.getAndIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * Creates a "well-known" object identifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * <p>An <code>ObjID</code> created via this constructor will not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * clash with any <code>ObjID</code>s generated via the no-arg
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param   objNum object number for well-known object identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public ObjID(int objNum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        space = new UID((short) 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        this.objNum = objNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Constructs an object identifier given data read from a stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    private ObjID(long objNum, UID space) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        this.objNum = objNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        this.space = space;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Marshals a binary representation of this <code>ObjID</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * an <code>ObjectOutput</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * <p>Specifically, this method first invokes the given stream's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * {@link ObjectOutput#writeLong(long)} method with this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * identifier's object number, and then it writes its address
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * space identifier by invoking its {@link UID#write(DataOutput)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * method with the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @param   out the <code>ObjectOutput</code> instance to write
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * this <code>ObjID</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @throws  IOException if an I/O error occurs while performing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * this operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    public void write(ObjectOutput out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        out.writeLong(objNum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        space.write(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Constructs and returns a new <code>ObjID</code> instance by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * unmarshalling a binary representation from an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * <code>ObjectInput</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <p>Specifically, this method first invokes the given stream's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * {@link ObjectInput#readLong()} method to read an object number,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * then it invokes {@link UID#read(DataInput)} with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * stream to read an address space identifier, and then it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * creates and returns a new <code>ObjID</code> instance that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * contains the object number and address space identifier that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * were read from the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @param   in the <code>ObjectInput</code> instance to read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <code>ObjID</code> from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @return  unmarshalled <code>ObjID</code> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @throws  IOException if an I/O error occurs while performing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * this operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public static ObjID read(ObjectInput in) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        long num = in.readLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        UID space = UID.read(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        return new ObjID(num, space);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * Returns the hash code value for this object identifier, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * object number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @return  the hash code value for this object identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return (int) objNum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Compares the specified object with this <code>ObjID</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * equality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * This method returns <code>true</code> if and only if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * specified object is an <code>ObjID</code> instance with the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * object number and address space identifier as this one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @param   obj the object to compare this <code>ObjID</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @return  <code>true</code> if the given object is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * this one, and <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        if (obj instanceof ObjID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            ObjID id = (ObjID) obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            return objNum == id.objNum && space.equals(id.space);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Returns a string representation of this object identifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @return  a string representation of this object identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * The address space identifier is only included in the string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * representation if it does not denote the local address space
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * (or if the randomIDs property was set).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        return "[" + (space.equals(mySpace) ? "" : space + ", ") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            objNum + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    private static boolean useRandomIDs() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        String value = AccessController.doPrivileged(
23333
b0af2c7c8c91 8035808: Eliminate dependency to GetPropertyAction and other sun.security.action convenient classes
mchung
parents: 5506
diff changeset
   245
            (PrivilegedAction<String>) () -> System.getProperty("java.rmi.server.randomIDs"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return value == null ? true : Boolean.parseBoolean(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}