ObjectStreamConstants.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* ObjectStreamConstants.java -- Interface containing constant values
  2. used in reading and writing serialized objects
  3. Copyright (C) 1998, 1999, 2003, 2006 Free Software Foundation, Inc.
  4. This file is part of GNU Classpath.
  5. GNU Classpath is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. GNU Classpath is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GNU Classpath; see the file COPYING. If not, write to the
  15. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA.
  17. Linking this library statically or dynamically with other modules is
  18. making a combined work based on this library. Thus, the terms and
  19. conditions of the GNU General Public License cover the whole
  20. combination.
  21. As a special exception, the copyright holders of this library give you
  22. permission to link this library with independent modules to produce an
  23. executable, regardless of the license terms of these independent
  24. modules, and to copy and distribute the resulting executable under
  25. terms of your choice, provided that you also meet, for each linked
  26. independent module, the terms and conditions of the license of that
  27. module. An independent module is a module which is not derived from
  28. or based on this library. If you modify this library, you may extend
  29. this exception to your version of the library, but you are not
  30. obligated to do so. If you do not wish to do so, delete this
  31. exception statement from your version. */
  32. package java.io;
  33. /**
  34. * This interface contains constants that are used in object
  35. * serialization. This interface is used by <code>ObjectOutputStream</code>,
  36. * <code>ObjectInputStream</code>, and <code>ObjectStreamClass</code>.
  37. * The values for these constants are specified by the Java library
  38. * specification.
  39. *
  40. * @since 1.1
  41. */
  42. public interface ObjectStreamConstants
  43. {
  44. /**
  45. * The serialization stream protocol version 1. This version was
  46. * the default serialization protocol before JDK 1.2.
  47. *
  48. * @see ObjectOutputStream#useProtocolVersion(int)
  49. * @since 1.2
  50. */
  51. int PROTOCOL_VERSION_1 = 1;
  52. /**
  53. * The serialization stream protocol version 2. This version is
  54. * used as the default serialization protocol since JDK 1.2.
  55. *
  56. * @see ObjectOutputStream#useProtocolVersion(int)
  57. * @since 1.2
  58. */
  59. int PROTOCOL_VERSION_2 = 2;
  60. /**
  61. * The magic number that is written as part of the stream header.
  62. */
  63. short STREAM_MAGIC = (short)0xaced;
  64. /**
  65. * The stream version number that is written as part of the stream header.
  66. * Note that this is different from the protocol version that specifies
  67. * the data format for the stream.
  68. */
  69. short STREAM_VERSION = 5;
  70. /**
  71. * Token value to designate a <code>null</code> reference in the stream.
  72. */
  73. byte TC_NULL = (byte)112; //0x70
  74. /**
  75. * Token value to designate a reference to an already serialized object.
  76. */
  77. byte TC_REFERENCE = (byte)113; //0x71
  78. /**
  79. * Token value to designate a class descriptor is next in the stream.
  80. */
  81. byte TC_CLASSDESC = (byte)114; //0x72
  82. /**
  83. * Token value to designate a new object is next in the stream.
  84. */
  85. byte TC_OBJECT = (byte)115; //0x73
  86. /**
  87. * Token value to designate a new string is next in the stream.
  88. */
  89. byte TC_STRING = (byte)116; //0x74
  90. /**
  91. * Token value to designate a new array is next in the stream.
  92. */
  93. byte TC_ARRAY = (byte)117; //0x75
  94. /**
  95. * Token reference to designate a reference to a class.
  96. */
  97. byte TC_CLASS = (byte)118; //0x76
  98. /**
  99. * Token value to designate a block of primitive data is next in the stream.
  100. * The next byte in the stream holds the size of the block (in bytes).
  101. */
  102. byte TC_BLOCKDATA = (byte)119; //0x77
  103. /**
  104. * Token value to designate the end of a block of primitve data.
  105. */
  106. byte TC_ENDBLOCKDATA = (byte)120; //0x78
  107. /**
  108. * Token value to designate a reset of the stream state.
  109. */
  110. byte TC_RESET = (byte)121; //0x79
  111. /**
  112. * Token value to designate a long block of primitive data is next in the
  113. * stream. The next long in the stream holds the size of the block
  114. * (in bytes).
  115. */
  116. byte TC_BLOCKDATALONG = (byte)122; //0x7A
  117. /**
  118. * Token value to designate an exception occured during serialization.
  119. */
  120. byte TC_EXCEPTION = (byte)123; //0x7B
  121. /**
  122. * Token value to designate a long string is next in the stream.
  123. */
  124. byte TC_LONGSTRING = (byte)124; //0x7C
  125. /**
  126. * Token value to designate a proxy class descriptor is next in the stream.
  127. */
  128. byte TC_PROXYCLASSDESC = (byte)125; //0x7D
  129. /**
  130. * Token value to designate an enum constant is next in the stream.
  131. *
  132. * @since 1.5
  133. */
  134. byte TC_ENUM = (byte)126; //0x7E
  135. /**
  136. * The first token value.
  137. */
  138. byte TC_BASE = TC_NULL;
  139. /**
  140. * The last token value.
  141. */
  142. byte TC_MAX = TC_ENUM;
  143. /**
  144. * The first handle that will be assigned to an object, for later references.
  145. */
  146. int baseWireHandle = 0x7e0000;
  147. /**
  148. * Flag used in <code>ObjectStreamClass</code> to designate that the class
  149. * defines the <code>writeObject</code> method.
  150. */
  151. byte SC_WRITE_METHOD = 0x01;
  152. /**
  153. * Flag used in <code>ObjectStreamClass</code> to designate that the class
  154. * is serializeable.
  155. */
  156. byte SC_SERIALIZABLE = 0x02;
  157. /**
  158. * Flag used in <code>ObjectStreamClass</code> to designate that the class
  159. * is externalizable.
  160. */
  161. byte SC_EXTERNALIZABLE = 0x04;
  162. /**
  163. * Flag used in <code>ObjectStreamClass</code> to designate that
  164. * externalizable data is written in block data mode.
  165. *
  166. * @since 1.2
  167. */
  168. byte SC_BLOCK_DATA = 0x08;
  169. /**
  170. * Flag used in <code>ObjectStreamClass</code> to designate that the class
  171. * is an enum constant.
  172. *
  173. * @since 1.5
  174. */
  175. byte SC_ENUM = 0x10;
  176. /**
  177. * Constant for use with a <code>SecurityManager</code> to check if
  178. * substitution of objects is allowed.
  179. */
  180. SerializablePermission SUBSTITUTION_PERMISSION
  181. = new SerializablePermission("enableSubstitution");
  182. /**
  183. * Constant for use with a <code>SecurityManager</code> to check if
  184. * overriding of the <code>writeObject</code> and <code>readObject</code>
  185. * methods is allowed.
  186. */
  187. SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION
  188. = new SerializablePermission("enableSubclassImplementation");
  189. }