Projekt

Obecné

Profil

Stáhnout (2.5 KB) Statistiky
| Větev: | Tag: | Revize:
1
package jdeserialize;
2

    
3
/**
4
 * <p>
5
 * This object contains embedded information about a serialization that failed, throwing
6
 * an exception.  It includes the actual exception object (which was serialized by the
7
 * ObjectOutputStream) and the raw bytes of the stream data that was read before the
8
 * exception was recognized.
9
 * </p>
10
 *
11
 * <p>
12
 * For the mechanics of exception serialization, see the Object Serialization
13
 * Specification.
14
 * </p>
15
 */
16
public class exceptionstate extends contentbase {
17
    /**
18
     * The serialized exception object.
19
     */
20
    public content exceptionobj;
21
    
22
    /**
23
     * <p>
24
     * An array of bytes representing the data read before the exception was encountered.
25
     * Generally, this starts with the first "tc" byte (cf. protocol spec), which is an
26
     * ObjectStreamConstants value and ends with 0x78 (the tc byte corresponding to
27
     * TC_EXCEPTION).  However, this isn't guaranteed; it may include *more* data.  
28
     * </p>
29
     *
30
     * <p>
31
     * In other words, this is the incomplete object that was being written while the
32
     * exception was caught by the ObjectOutputStream.  It is not likely to be cleanly
33
     * parseable.
34
     * </p>
35
     *
36
     * <p>
37
     * The uncertainty centers around the fact that this data is gathered by jdeserialize
38
     * using a LoggerInputStream, and the underlying DataInputStream may have read more
39
     * than is necessary.  In all tests conducted so far, the above description is
40
     * accurate.
41
     * </p>
42
     */
43
    public byte[] streamdata;
44

    
45
    /**
46
     * Consturctor.
47
     * @param exobj the serialized exception object 
48
     * @param data the array of stream bytes that led up to the exception
49
     */
50
    public exceptionstate(content exobj, byte[] data) {
51
        super(contenttype.EXCEPTIONSTATE);
52
        this.exceptionobj = exobj;
53
        this.streamdata = data;
54
        this.handle = exobj.getHandle();
55
    }
56
    public String toString() {
57
        StringBuffer sb = new StringBuffer();
58
        sb.append("[exceptionstate object " + exceptionobj.toString() + "  buflen " + streamdata.length);
59
        if(streamdata.length > 0) {
60
            for(int i = 0; i < streamdata.length; i++) {
61
                if((i % 16) == 0) {
62
                    sb.append(jdeserialize.linesep).append(String.format("%7x: ", Integer.valueOf(i)));
63
                }
64
                sb.append(" ").append(jdeserialize.hexnoprefix(streamdata[i]));
65
            }
66
            sb.append(jdeserialize.linesep);
67
        }
68
        sb.append("]");
69
        return sb.toString();
70
    }
71
}
(15-15/20)