1. /*
  2. * @(#)ObjectStreamConstants.java 1.34 04/01/12
  3. *
  4. * Copyright 2004 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.34, 01/12/04
  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. * new Enum constant.
  90. */
  91. final static byte TC_ENUM = (byte)0x7E;
  92. /**
  93. * Last tag value.
  94. */
  95. final static byte TC_MAX = (byte)0x7E;
  96. /**
  97. * First wire handle to be assigned.
  98. */
  99. final static int baseWireHandle = 0x7e0000;
  100. /******************************************************/
  101. /* Bit masks for ObjectStreamClass flag.*/
  102. /**
  103. * Bit mask for ObjectStreamClass flag. Indicates a Serializable class
  104. * defines its own writeObject method.
  105. */
  106. final static byte SC_WRITE_METHOD = 0x01;
  107. /**
  108. * Bit mask for ObjectStreamClass flag. Indicates Externalizable data
  109. * written in Block Data mode.
  110. * Added for PROTOCOL_VERSION_2.
  111. *
  112. * @see #PROTOCOL_VERSION_2
  113. * @since 1.2
  114. */
  115. final static byte SC_BLOCK_DATA = 0x08;
  116. /**
  117. * Bit mask for ObjectStreamClass flag. Indicates class is Serializable.
  118. */
  119. final static byte SC_SERIALIZABLE = 0x02;
  120. /**
  121. * Bit mask for ObjectStreamClass flag. Indicates class is Externalizable.
  122. */
  123. final static byte SC_EXTERNALIZABLE = 0x04;
  124. /**
  125. * Bit mask for ObjectStreamClass flag. Indicates class is an enum type.
  126. */
  127. final static byte SC_ENUM = 0x10;
  128. /* *******************************************************************/
  129. /* Security permissions */
  130. /**
  131. * Enable substitution of one object for another during
  132. * serialization/deserialization.
  133. *
  134. * @see java.io.ObjectOutputStream#enableReplaceObject(boolean)
  135. * @see java.io.ObjectInputStream#enableResolveObject(boolean)
  136. * @since 1.2
  137. */
  138. final static SerializablePermission SUBSTITUTION_PERMISSION =
  139. new SerializablePermission("enableSubstitution");
  140. /**
  141. * Enable overriding of readObject and writeObject.
  142. *
  143. * @see java.io.ObjectOutputStream#writeObjectOverride(Object)
  144. * @see java.io.ObjectInputStream#readObjectOverride()
  145. * @since 1.2
  146. */
  147. final static SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
  148. new SerializablePermission("enableSubclassImplementation");
  149. /**
  150. * A Stream Protocol Version. <p>
  151. *
  152. * All externalizable data is written in JDK 1.1 external data
  153. * format after calling this method. This version is needed to write
  154. * streams containing Externalizable data that can be read by
  155. * pre-JDK 1.1.6 JVMs.
  156. *
  157. * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  158. * @since 1.2
  159. */
  160. public final static int PROTOCOL_VERSION_1 = 1;
  161. /**
  162. * A Stream Protocol Version. <p>
  163. *
  164. * This protocol is written by JVM 1.2.
  165. *
  166. * Externalizable data is written in block data mode and is
  167. * terminated with TC_ENDBLOCKDATA. Externalizable classdescriptor
  168. * flags has SC_BLOCK_DATA enabled. JVM 1.1.6 and greater can
  169. * read this format change.
  170. *
  171. * Enables writing a nonSerializable class descriptor into the
  172. * stream. The serialVersionUID of a nonSerializable class is
  173. * set to 0L.
  174. *
  175. * @see java.io.ObjectOutputStream#useProtocolVersion(int)
  176. * @see #SC_BLOCK_DATA
  177. * @since 1.2
  178. */
  179. public final static int PROTOCOL_VERSION_2 = 2;
  180. }