1 /* |
1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 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. |
100 } |
100 } |
101 |
101 |
102 /* When any class is written, add a "magic" string |
102 /* When any class is written, add a "magic" string |
103 * that must be verified by the TestInputStream. |
103 * that must be verified by the TestInputStream. |
104 */ |
104 */ |
105 protected void annotateClass(Class cl) throws IOException { |
105 protected void annotateClass(Class<?> cl) throws IOException { |
106 this.writeUTF("magic"); |
106 this.writeUTF("magic"); |
107 } |
107 } |
108 |
108 |
109 /* For each object of type PrintStream, substitute |
109 /* For each object of type PrintStream, substitute |
110 * a StdStream handle object that encodes which |
110 * a StdStream handle object that encodes which |
111 * of the standard print streams is being written. |
111 * of the standard print streams is being written. |
112 * Other objects are written as themselves. |
112 * Other objects are written as themselves. |
113 */ |
113 */ |
114 protected Object replaceObject(Object obj) |
114 protected Object replaceObject(Object obj) |
115 throws IOException |
|
116 { |
115 { |
117 /* For PrintStreams, like stdout and stderr, encode */ |
116 /* For PrintStreams, like stdout and stderr, encode */ |
118 if (obj instanceof PrintStream) { |
117 if (obj instanceof PrintStream) { |
119 return new StdStream((PrintStream)obj); |
118 return new StdStream((PrintStream)obj); |
120 } |
119 } |
167 |
166 |
168 /* A holder class to map between standard print streams (stdout, stderr) |
167 /* A holder class to map between standard print streams (stdout, stderr) |
169 * and a small integer. |
168 * and a small integer. |
170 */ |
169 */ |
171 class StdStream implements java.io.Serializable { |
170 class StdStream implements java.io.Serializable { |
|
171 private static final long serialVersionUID = 1L; |
172 private int stream = 0; |
172 private int stream = 0; |
173 |
173 |
174 public StdStream(PrintStream s) { |
174 public StdStream(PrintStream s) { |
175 if (s == System.out) { |
175 if (s == System.out) { |
176 stream = 1; |
176 stream = 1; |