MCPcopy Create free account
hub / github.com/ReadyTalk/avian / ObjectInputStream

Class ObjectInputStream

classpath/java/io/ObjectInputStream.java:46–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44import java.lang.reflect.Modifier;
45
46public class ObjectInputStream extends InputStream implements DataInput {
47 private final static int HANDLE_OFFSET = 0x7e0000;
48
49 private final InputStream in;
50 private final ArrayList references;
51
52 public ObjectInputStream(InputStream in) throws IOException {
53 this.in = in;
54 short signature = (short)rawShort();
55 if (signature != STREAM_MAGIC) {
56 throw new IOException("Unrecognized signature: 0x"
57 + Integer.toHexString(signature));
58 }
59 int version = rawShort();
60 if (version != STREAM_VERSION) {
61 throw new IOException("Unsupported version: " + version);
62 }
63 references = new ArrayList();
64 }
65
66 public int read() throws IOException {
67 return in.read();
68 }
69
70 private int rawByte() throws IOException {
71 int c = read();
72 if (c < 0) {
73 throw new EOFException();
74 }
75 return c;
76 }
77
78 private int rawShort() throws IOException {
79 return (rawByte() << 8) | rawByte();
80 }
81
82 private int rawInt() throws IOException {
83 return (rawShort() << 16) | rawShort();
84 }
85
86 private long rawLong() throws IOException {
87 return ((rawInt() & 0xffffffffl) << 32) | rawInt();
88 }
89
90 private String rawString() throws IOException {
91 int length = rawShort();
92 byte[] array = new byte[length];
93 readFully(array);
94 return new String(array);
95 }
96
97 public int read(byte[] b, int offset, int length) throws IOException {
98 return in.read(b, offset, length);
99 }
100
101 public void readFully(byte[] b) throws IOException {
102 readFully(b, 0, b.length);
103 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected