001 /*
002 * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.io;
027
028 /**
029 * Constants written into the Object Serialization Stream.
030 *
031 * @author unascribed
032 * @version 1.42, 05/05/07
033 * @since JDK 1.1
034 */
035 public interface ObjectStreamConstants {
036
037 /**
038 * Magic number that is written to the stream header.
039 */
040 final static short STREAM_MAGIC = (short) 0xaced;
041
042 /**
043 * Version number that is written to the stream header.
044 */
045 final static short STREAM_VERSION = 5;
046
047 /* Each item in the stream is preceded by a tag
048 */
049
050 /**
051 * First tag value.
052 */
053 final static byte TC_BASE = 0x70;
054
055 /**
056 * Null object reference.
057 */
058 final static byte TC_NULL = (byte) 0x70;
059
060 /**
061 * Reference to an object already written into the stream.
062 */
063 final static byte TC_REFERENCE = (byte) 0x71;
064
065 /**
066 * new Class Descriptor.
067 */
068 final static byte TC_CLASSDESC = (byte) 0x72;
069
070 /**
071 * new Object.
072 */
073 final static byte TC_OBJECT = (byte) 0x73;
074
075 /**
076 * new String.
077 */
078 final static byte TC_STRING = (byte) 0x74;
079
080 /**
081 * new Array.
082 */
083 final static byte TC_ARRAY = (byte) 0x75;
084
085 /**
086 * Reference to Class.
087 */
088 final static byte TC_CLASS = (byte) 0x76;
089
090 /**
091 * Block of optional data. Byte following tag indicates number
092 * of bytes in this block data.
093 */
094 final static byte TC_BLOCKDATA = (byte) 0x77;
095
096 /**
097 * End of optional block data blocks for an object.
098 */
099 final static byte TC_ENDBLOCKDATA = (byte) 0x78;
100
101 /**
102 * Reset stream context. All handles written into stream are reset.
103 */
104 final static byte TC_RESET = (byte) 0x79;
105
106 /**
107 * long Block data. The long following the tag indicates the
108 * number of bytes in this block data.
109 */
110 final static byte TC_BLOCKDATALONG = (byte) 0x7A;
111
112 /**
113 * Exception during write.
114 */
115 final static byte TC_EXCEPTION = (byte) 0x7B;
116
117 /**
118 * Long string.
119 */
120 final static byte TC_LONGSTRING = (byte) 0x7C;
121
122 /**
123 * new Proxy Class Descriptor.
124 */
125 final static byte TC_PROXYCLASSDESC = (byte) 0x7D;
126
127 /**
128 * new Enum constant.
129 * @since 1.5
130 */
131 final static byte TC_ENUM = (byte) 0x7E;
132
133 /**
134 * Last tag value.
135 */
136 final static byte TC_MAX = (byte) 0x7E;
137
138 /**
139 * First wire handle to be assigned.
140 */
141 final static int baseWireHandle = 0x7e0000;
142
143 /******************************************************/
144 /* Bit masks for ObjectStreamClass flag.*/
145
146 /**
147 * Bit mask for ObjectStreamClass flag. Indicates a Serializable class
148 * defines its own writeObject method.
149 */
150 final static byte SC_WRITE_METHOD = 0x01;
151
152 /**
153 * Bit mask for ObjectStreamClass flag. Indicates Externalizable data
154 * written in Block Data mode.
155 * Added for PROTOCOL_VERSION_2.
156 *
157 * @see #PROTOCOL_VERSION_2
158 * @since 1.2
159 */
160 final static byte SC_BLOCK_DATA = 0x08;
161
162 /**
163 * Bit mask for ObjectStreamClass flag. Indicates class is Serializable.
164 */
165 final static byte SC_SERIALIZABLE = 0x02;
166
167 /**
168 * Bit mask for ObjectStreamClass flag. Indicates class is Externalizable.
169 */
170 final static byte SC_EXTERNALIZABLE = 0x04;
171
172 /**
173 * Bit mask for ObjectStreamClass flag. Indicates class is an enum type.
174 * @since 1.5
175 */
176 final static byte SC_ENUM = 0x10;
177
178 /* *******************************************************************/
179 /* Security permissions */
180
181 /**
182 * Enable substitution of one object for another during
183 * serialization/deserialization.
184 *
185 * @see java.io.ObjectOutputStream#enableReplaceObject(boolean)
186 * @see java.io.ObjectInputStream#enableResolveObject(boolean)
187 * @since 1.2
188 */
189 final static SerializablePermission SUBSTITUTION_PERMISSION = new SerializablePermission(
190 "enableSubstitution");
191
192 /**
193 * Enable overriding of readObject and writeObject.
194 *
195 * @see java.io.ObjectOutputStream#writeObjectOverride(Object)
196 * @see java.io.ObjectInputStream#readObjectOverride()
197 * @since 1.2
198 */
199 final static SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION = new SerializablePermission(
200 "enableSubclassImplementation");
201 /**
202 * A Stream Protocol Version. <p>
203 *
204 * All externalizable data is written in JDK 1.1 external data
205 * format after calling this method. This version is needed to write
206 * streams containing Externalizable data that can be read by
207 * pre-JDK 1.1.6 JVMs.
208 *
209 * @see java.io.ObjectOutputStream#useProtocolVersion(int)
210 * @since 1.2
211 */
212 public final static int PROTOCOL_VERSION_1 = 1;
213
214 /**
215 * A Stream Protocol Version. <p>
216 *
217 * This protocol is written by JVM 1.2.
218 *
219 * Externalizable data is written in block data mode and is
220 * terminated with TC_ENDBLOCKDATA. Externalizable classdescriptor
221 * flags has SC_BLOCK_DATA enabled. JVM 1.1.6 and greater can
222 * read this format change.
223 *
224 * Enables writing a nonSerializable class descriptor into the
225 * stream. The serialVersionUID of a nonSerializable class is
226 * set to 0L.
227 *
228 * @see java.io.ObjectOutputStream#useProtocolVersion(int)
229 * @see #SC_BLOCK_DATA
230 * @since 1.2
231 */
232 public final static int PROTOCOL_VERSION_2 = 2;
233 }
|