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