equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
35 |
35 |
36 BrokenObjectInputStream(InputStream in) throws IOException { |
36 BrokenObjectInputStream(InputStream in) throws IOException { |
37 super(in); |
37 super(in); |
38 } |
38 } |
39 |
39 |
40 protected Class resolveClass(ObjectStreamClass desc) |
40 protected Class<?> resolveClass(ObjectStreamClass desc) |
41 throws IOException, ClassNotFoundException |
41 throws ClassNotFoundException |
42 { |
42 { |
43 throw new ClassNotFoundException(message); |
43 throw new ClassNotFoundException(message); |
44 } |
44 } |
45 } |
45 } |
46 |
46 |
51 ByteArrayInputStream bin; |
51 ByteArrayInputStream bin; |
52 BrokenObjectInputStream oin; |
52 BrokenObjectInputStream oin; |
53 Object obj; |
53 Object obj; |
54 |
54 |
55 // write and read an object |
55 // write and read an object |
56 obj = new Integer(5); |
56 obj = 5; |
57 bout = new ByteArrayOutputStream(); |
57 bout = new ByteArrayOutputStream(); |
58 oout = new ObjectOutputStream(bout); |
58 oout = new ObjectOutputStream(bout); |
59 oout.writeObject(obj); |
59 oout.writeObject(obj); |
60 bin = new ByteArrayInputStream(bout.toByteArray()); |
60 bin = new ByteArrayInputStream(bout.toByteArray()); |
61 oin = new BrokenObjectInputStream(bin); |
61 oin = new BrokenObjectInputStream(bin); |
65 if (! BrokenObjectInputStream.message.equals(e.getMessage())) |
65 if (! BrokenObjectInputStream.message.equals(e.getMessage())) |
66 throw new Error("Original exception not preserved"); |
66 throw new Error("Original exception not preserved"); |
67 } |
67 } |
68 |
68 |
69 // write and read an array of objects |
69 // write and read an array of objects |
70 obj = new Integer[] { new Integer(5) }; |
70 obj = new Integer[] { 5 }; |
71 bout = new ByteArrayOutputStream(); |
71 bout = new ByteArrayOutputStream(); |
72 oout = new ObjectOutputStream(bout); |
72 oout = new ObjectOutputStream(bout); |
73 oout.writeObject(obj); |
73 oout.writeObject(obj); |
74 bin = new ByteArrayInputStream(bout.toByteArray()); |
74 bin = new ByteArrayInputStream(bout.toByteArray()); |
75 oin = new BrokenObjectInputStream(bin); |
75 oin = new BrokenObjectInputStream(bin); |