1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package java.io;
19
20/**
21 * A helper interface with constants used by the serialization implementation.
22 */
23public abstract interface ObjectStreamConstants {
24
25    /**
26     * The stream header's magic number.
27     */
28    public static final short STREAM_MAGIC = (short) 0xaced;
29
30    /**
31     * The stream header's version number.
32     */
33    public static final short STREAM_VERSION = 5;
34
35    // These are tags to indicate the stream contents
36
37    /**
38     * The minimum tag value.
39     */
40    public static final byte TC_BASE = 0x70;
41
42    /**
43     * Tag to mark a {@code null} object reference.
44     */
45    public static final byte TC_NULL = (byte) 0x70;
46
47    /**
48     * Tag to mark a reference to an object that has already been written to the
49     * stream.
50     */
51    public static final byte TC_REFERENCE = (byte) 0x71;
52
53    /**
54     * Tag to mark a new class descriptor.
55     */
56    public static final byte TC_CLASSDESC = (byte) 0x72;
57
58    /**
59     * Tag to mark a new object.
60     */
61    public static final byte TC_OBJECT = (byte) 0x73;
62
63    /**
64     * Tag to mark a new string.
65     */
66    public static final byte TC_STRING = (byte) 0x74;
67
68    /**
69     * Tag to mark a new array.
70     */
71    public static final byte TC_ARRAY = (byte) 0x75;
72
73    /**
74     * Tag to mark a reference to a class.
75     */
76    public static final byte TC_CLASS = (byte) 0x76;
77
78    /**
79     * Tag to mark a block of optional data. The byte following this tag
80     * indicates the size of the block.
81     */
82    public static final byte TC_BLOCKDATA = (byte) 0x77;
83
84    /**
85     * Tag to mark the end of block data blocks for an object.
86     */
87    public static final byte TC_ENDBLOCKDATA = (byte) 0x78;
88
89    /**
90     * Tag to mark a stream reset.
91     */
92    public static final byte TC_RESET = (byte) 0x79;
93
94    /**
95     * Tag to mark a long block of data. The long following this tag
96     * indicates the size of the block.
97     */
98    public static final byte TC_BLOCKDATALONG = (byte) 0x7A;
99
100    /**
101     * Tag to mark an exception.
102     */
103    public static final byte TC_EXCEPTION = (byte) 0x7B;
104
105    /**
106     * Tag to mark a long string.
107     */
108    public static final byte TC_LONGSTRING = (byte) 0x7C;
109
110    /**
111     * Tag to mark a new proxy class descriptor.
112     */
113    public static final byte TC_PROXYCLASSDESC = (byte) 0x7D;
114
115    /**
116     * The maximum tag value.
117     */
118    public static final byte TC_MAX = 0x7E;
119
120    /**
121     * Handle for the first object that gets serialized.
122     */
123    public static final int baseWireHandle = 0x007e0000;
124
125    /**
126     * Stream protocol version 1.
127     */
128    public static final int PROTOCOL_VERSION_1 = 1;
129
130    /**
131     * Stream protocol version 2.
132     */
133    public static final int PROTOCOL_VERSION_2 = 2;
134
135    /**
136     * Permission constant to enable subclassing of ObjectInputStream and
137     * ObjectOutputStream.
138     */
139    public static final SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION = new SerializablePermission(
140            "enableSubclassImplementation");
141
142    /**
143     * Permission constant to enable object substitution during serialization
144     * and deserialization.
145     */
146    public static final SerializablePermission SUBSTITUTION_PERMISSION = new SerializablePermission(
147            "enableSubstitution");
148
149    // Flags that indicate if the object was serializable, externalizable
150    // and had a writeObject method when dumped.
151    /**
152     * Bit mask for the {@code flag} field in {@link ObjectStreamClass}. Indicates
153     * that a {@link Serializable} class has its own {@code writeObject} method.
154     */
155    public static final byte SC_WRITE_METHOD = 0x01; // If SC_SERIALIZABLE
156
157    /**
158     * Bit mask for the {@code flag} field in {@link ObjectStreamClass}. Indicates
159     * that a class implements {@link Serializable} but not {@link Externalizable}.
160     */
161    public static final byte SC_SERIALIZABLE = 0x02;
162
163    /**
164     * Bit mask for the {@code flag} field in {@link ObjectStreamClass}. Indicates
165     * that a class implements {@link Externalizable}.
166     */
167    public static final byte SC_EXTERNALIZABLE = 0x04;
168
169    /**
170     * Bit mask for the {@code flag} field in {@link ObjectStreamClass}. Indicates
171     * that an externalizable class is written in block data mode.
172     */
173    public static final byte SC_BLOCK_DATA = 0x08; // If SC_EXTERNALIZABLE
174
175    /**
176     * Tag to mark a new enum.
177     */
178    public static final byte TC_ENUM = 0x7E;
179
180    /**
181     * Bit mask for the {@code flag} field in {@link ObjectStreamClass}. Indicates
182     * that a class is an enum type.
183     */
184    public static final byte SC_ENUM = 0x10;
185}
186