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