1. /*
  2. * @(#)ObjectStreamConstants.java 1.31 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.io;
  8. /**
  9. * Constants written into the Object Serialization Stream.
  10. *
  11. * @author unascribed
  12. * @version 1.31, 01/23/03
  13. * @since JDK 1.1
  14. */
  15. public interface ObjectStreamConstants {
  16. /**
  17. * Magic number that is written to the stream header.
  18. */
  19. final static short STREAM_MAGIC = (short)0xaced;
  20. /**
  21. * Version number that is written to the stream header.
  22. */
  23. final static short STREAM_VERSION = 5;
  24. /* Each item in the stream is preceded by a tag
  25. */
  26. /**
  27. * First tag value.
  28. */
  29. final static byte TC_BASE = 0x70;
  30. /**
  31. * Null object reference.
  32. */
  33. final static byte TC_NULL = (byte)0x70;
  34. /**
  35. * Reference to an object already written into the stream.
  36. */
  37. final static byte TC_REFERENCE = (byte)0x71;
  38. /**
  39. * new Class Descriptor.
  40. */
  41. final static byte TC_CLASSDESC = (byte)0x72;
  42. /**
  43. * new Object.
  44. */
  45. final static byte TC_OBJECT = (byte)0x73;
  46. /**
  47. * new String.
  48. */
  49. final static byte TC_STRING = (byte)0x74;
  50. /**
  51. * new Array.
  52. */
  53. final static byte TC_ARRAY = (byte)0x75;
  54. /**
  55. * Reference to Class.
  56. */
  57. final static byte TC_CLASS = (byte)0x76;
  58. /**
  59. * Block of optional data. Byte following tag indicates number
  60. * of bytes in this block data.
  61. */
  62. final static byte TC_BLOCKDATA = (byte)0x77;
  63. /**
  64. * End of optional block data blocks for an object.
  65. */
  66. final static byte TC_ENDBLOCKDATA = (byte)0x78;
  67. /**
  68. * Reset stream context. All handles written into stream are reset.
  69. */
  70. final static byte TC_RESET = (byte)0x79;
  71. /**
  72. * long Block data. The long following the tag indicates the
  73. * number of bytes in this block data.
  74. */
  75. final static byte TC_BLOCKDATALONG= (byte)0x7A;
  76. /**
  77. * Exception during write.
  78. */
  79. final static byte TC_EXCEPTION = (byte)0x7B;
  80. /**
  81. * Long string.
  82. */
  83. final static byte TC_LONGSTRING = (byte)0x7C;
  84. /**
  85. * new Proxy Class Descriptor.
  86. */
  87. final static byte TC_PROXYCLASSDESC = (byte)0x7D;
  88. /**
  89. * Last tag value.
  90. */
  91. final static byte TC_MAX = (byte)0x7D;
  92. /**
  93. * First wire handle to be assigned.
  94. */
  95. final static int baseWireHandle = 0x7e0000;
  96. /******************************************************/
  97. /* Bit masks for ObjectStreamClass flag.*/
  98. /**
  99. * Bit mask for ObjectStreamClass flag. Indicates a Serializable class
  100. * defines its own writeObject method.
  101. */
  102. final static byte SC_WRITE_METHOD = 0x01;
  103. /**
  104. * Bit mask for ObejctStreamClass flag. Indicates Externalizable data
  105. * written in Block Data mode.
  106. * Added for PROTOCOL_VERSION_2.
  107. *
  108. * @see #PROTOCOL_VERSION_2
  109. * @since 1.2
  110. */
  111. final static byte SC_BLOCK_DATA = 0x08;
  112. /**
  113. * Bit mask for ObjectStreamClass flag. Indicates class is Serializable.
  114. */
  115. final static byte SC_SERIALIZABLE = 0x02;
  116. /**
  117. * Bit mask for ObjectStreamClass flag. Indicates class is Externalizable.
  118. */
  119. final static byte SC_EXTERNALIZABLE = 0x04;
  120. /* *******************************************************************/
  121. /* Security permissions */
  122. /**
  123. * Enable substitution of one object for another during
  124. * serialization/deserialization.
  125. *
  126. * @see java.io.ObjectOutputStream#enableReplaceObject(boolean)
  127. * @see java.io.ObjectInputStream#enableResolveObject(boolean)
  128. * @since 1.2
  129. */
  130. final static SerializablePermission SUBSTITUTION_PERMISSION =
  131. new SerializablePermission("enableSubstitution");
  132. /**
  133. * Enable overriding of readObject and writeObject.
  134. *
  135. * @see java.io.ObjectOutputStream#writeObjectOverride(Object)
  136. * @see java.io.ObjectInputStream#readObjectOverride()
  137. * @since 1.2
  138. */
  139. final static SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
  140. new SerializablePermission("enableSubclassImplementation");
  141. /**
  142. * A Stream Protocol Version. <p>
  143. *
  144. * All externalizable data is written in JDK 1.1 external data
  145. * format after calling this method. This version is needed to write
  146. * streams containing Externalizable data that can be read by
  147. * pre-JDK 1.1.6 JVMs.
  148. *
  149. * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  150. * @since 1.2
  151. */
  152. public final static int PROTOCOL_VERSION_1 = 1;
  153. /**
  154. * A Stream Protocol Version. <p>
  155. *
  156. * This protocol is written by JVM 1.2.
  157. *
  158. * Externalizable data is written in block data mode and is
  159. * terminated with TC_ENDBLOCKDATA. Externalizable classdescriptor
  160. * flags has SC_BLOCK_DATA enabled. JVM 1.1.6 and greater can
  161. * read this format change.
  162. *
  163. * Enables writing a nonSerializable class descriptor into the
  164. * stream. The serialVersionUID of a nonSerializable class is
  165. * set to 0L.
  166. *
  167. * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  168. * @see #SC_BLOCK_DATA
  169. * @since 1.2
  170. */
  171. public final static int PROTOCOL_VERSION_2 = 2;
  172. }