public class jdeserialize
extends java.lang.Object
content
Modifier and Type | Field and Description |
---|---|
static int |
CODEWIDTH |
private java.util.ArrayList<content> |
content |
private int |
curhandle |
private boolean |
debugEnabled |
private java.util.ArrayList<java.util.Map<java.lang.Integer,content>> |
handlemaps |
private java.util.HashMap<java.lang.Integer,content> |
handles |
static java.lang.String |
INDENT |
static java.lang.String[] |
keywords |
static java.util.HashSet<java.lang.String> |
keywordSet |
static java.lang.String |
linesep |
static long |
serialVersionUID |
Constructor and Description |
---|
jdeserialize(byte[] input)
Reads in an entire ObjectOutputStream output on the given stream, filing
this object's content and handle maps with data about the objects in the stream.
|
Modifier and Type | Method and Description |
---|---|
void |
connectMemberClasses()
Connects member classes according to the rules specified by the JDK 1.1 Inner
Classes Specification.
|
void |
debug(java.lang.String message) |
static void |
debugerr(java.lang.String message) |
static java.lang.String |
decodeClassName(java.lang.String fdesc,
boolean convertSlashes)
Decodes a class name according to the field-descriptor format in the jvm spec,
section 4.3.2.
|
static void |
dump_ClassDesc(int indentlevel,
classdesc cd,
java.io.PrintStream ps,
boolean fixname) |
static void |
dump_Instance(int indentlevel,
instance inst,
java.io.PrintStream ps) |
void |
dump(Getopt go) |
static java.lang.String |
fixClassName(java.lang.String name)
"Fix" the given name by transforming illegal characters, such that the end result
is a legal Java identifier that is not a keyword.
|
java.util.List<content> |
getContent()
Retrieves the list of content objects that were written to the stream.
|
java.util.List<java.util.Map<java.lang.Integer,content>> |
getHandleMaps()
Return a list of Maps containing every object with a handle.
|
classdesc |
handle_classDesc(byte tc,
java.io.DataInputStream dis,
boolean mustBeNew) |
classdesc |
handle_newClassDesc(byte tc,
java.io.DataInputStream dis) |
static java.lang.String |
hex(long value) |
static java.lang.String |
hexnoprefix(long value) |
static java.lang.String |
hexnoprefix(long value,
int len) |
static java.lang.String |
indent(int level) |
private int |
newHandle() |
arraycoll |
read_arrayValues(java.lang.String str,
java.io.DataInputStream dis) |
blockdata |
read_blockdata(byte tc,
java.io.DataInputStream dis) |
java.util.List<content> |
read_classAnnotation(java.io.DataInputStream dis) |
void |
read_Classdata(java.io.DataInputStream dis,
instance inst) |
classdesc |
read_classDesc(java.io.DataInputStream dis) |
content |
read_Content(byte tc,
java.io.DataInputStream dis,
boolean blockdata)
Read the next object corresponding to the spec grammar rule "content", and return
an object of type content.
|
content |
read_Exception(java.io.DataInputStream dis)
Read the content of a thrown exception object.
|
java.lang.Object |
read_FieldValue(fieldtype f,
java.io.DataInputStream dis) |
arrayobj |
read_newArray(java.io.DataInputStream dis) |
classobj |
read_newClass(java.io.DataInputStream dis) |
classdesc |
read_newClassDesc(java.io.DataInputStream dis) |
enumobj |
read_newEnum(java.io.DataInputStream dis) |
instance |
read_newObject(java.io.DataInputStream dis) |
stringobj |
read_newString(byte tc,
java.io.DataInputStream dis) |
content |
read_prevObject(java.io.DataInputStream dis) |
void |
reset() |
static java.lang.String |
resolveJavaType(fieldtype type,
java.lang.String classname,
boolean convertSlashes,
boolean fixname) |
void |
setHandle(int handle,
content c) |
static java.lang.String |
unicodeEscape(java.lang.String str)
Suitably escapes non-printable-ASCII characters (and doublequotes) for use
in a Java string literal.
|
public static final long serialVersionUID
public static final java.lang.String INDENT
public static final int CODEWIDTH
public static final java.lang.String linesep
public static final java.lang.String[] keywords
public static java.util.HashSet<java.lang.String> keywordSet
private java.util.HashMap<java.lang.Integer,content> handles
private java.util.ArrayList<java.util.Map<java.lang.Integer,content>> handlemaps
private java.util.ArrayList<content> content
private int curhandle
private boolean debugEnabled
public jdeserialize(byte[] input) throws java.io.IOException
Reads in an entire ObjectOutputStream output on the given stream, filing this object's content and handle maps with data about the objects in the stream.
If shouldConnect is true, then jdeserialize will attempt to identify member classes by their names according to the details laid out in the Inner Classes Specification. If it finds one, it will set the classdesc's flag indicating that it is an member class, and it will create a reference in its enclosing class.
is
- an open InputStream on a serialized stream of datashouldConnect
- true if jdeserialize should attempt to identify and connect
member classes with their enclosing classes
Also see the connectMemberClassesmethod for more information on the member-class-detection algorithm.
java.io.IOException
public java.util.List<content> getContent()
Retrieves the list of content objects that were written to the stream. Each item generally corresponds to an invocation of an ObjectOutputStream writeXXX() method. A notable exception is the class exceptionstate, which represents an embedded exception that was caught during serialization.
See the various implementors of content to get information about what data is available.
Entries in the list may be null, because it's perfectly legitimate to write a null reference to the stream.
content
,
exceptionstate
public java.util.List<java.util.Map<java.lang.Integer,content>> getHandleMaps()
Return a list of Maps containing every object with a handle. The keys are integers -- the handles themselves -- and the values are instances of type content.
Although there is only one map active at a given point, a stream may have multiple logical maps: when a reset happens (indicated by TC_RESET), the current map is cleared.
See the spec for details on handles.
public static java.lang.String unicodeEscape(java.lang.String str)
str
- string to escapepublic static java.lang.String indent(int level)
public void read_Classdata(java.io.DataInputStream dis, instance inst) throws java.io.IOException
java.io.IOException
public java.lang.Object read_FieldValue(fieldtype f, java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
private int newHandle()
public static java.lang.String resolveJavaType(fieldtype type, java.lang.String classname, boolean convertSlashes, boolean fixname) throws java.io.IOException
java.io.IOException
public java.util.List<content> read_classAnnotation(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public static void dump_Instance(int indentlevel, instance inst, java.io.PrintStream ps)
public static java.lang.String fixClassName(java.lang.String name)
name
- the name to be transformedpublic static void dump_ClassDesc(int indentlevel, classdesc cd, java.io.PrintStream ps, boolean fixname) throws java.io.IOException
java.io.IOException
public void setHandle(int handle, content c) throws java.io.IOException
java.io.IOException
public void reset()
public content read_Exception(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public classdesc read_classDesc(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public classdesc read_newClassDesc(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public content read_prevObject(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public classdesc handle_newClassDesc(byte tc, java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public classdesc handle_classDesc(byte tc, java.io.DataInputStream dis, boolean mustBeNew) throws java.io.IOException
java.io.IOException
public arrayobj read_newArray(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public arraycoll read_arrayValues(java.lang.String str, java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public classobj read_newClass(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public enumobj read_newEnum(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public stringobj read_newString(byte tc, java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public blockdata read_blockdata(byte tc, java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public instance read_newObject(java.io.DataInputStream dis) throws java.io.IOException
java.io.IOException
public content read_Content(byte tc, java.io.DataInputStream dis, boolean blockdata) throws java.io.IOException
Read the next object corresponding to the spec grammar rule "content", and return an object of type content.
Usually, there is a 1:1 mapping of content items and returned instances. The one case where this isn't true is when an exception is embedded inside another object. When this is encountered, only the serialized exception object is returned; it's up to the caller to backtrack in order to gather any data from the object that was being serialized when the exception was thrown.
tc
- the last byte read from the stream; it must be one of the TC_* values
within ObjectStreamConstants.*dis
- the DataInputStream to read fromblockdata
- whether or not to read TC_BLOCKDATA (this is the difference
between spec rules "object" and "content").java.io.IOException
- when a validity or I/O error occurs while readingpublic void dump(Getopt go) throws java.io.IOException
java.io.IOException
public void connectMemberClasses() throws java.io.IOException
Connects member classes according to the rules specified by the JDK 1.1 Inner Classes Specification.
Inner classes: for each class C containing an object reference member R named this$N, do: if the name of C matches the pattern O$I AND the name O matches the name of an existing type T AND T is the exact type referred to by R, then: don't display the declaration of R in normal dumping, consider C to be an inner class of O named I Static member classes (after): for each class C matching the pattern O$I, where O is the name of a class in the same package AND C is not an inner class according to the above algorithm: consider C to be an inner class of O named I
This functions fills in the isInnerClass value in classdesc, the isInnerClassReference value in field, the isLocalInnerClass value in classdesc, and the isStaticMemberClass value in classdesc where necessary.
A word on static classes: serializing a static member class S doesn't inherently require serialization of its parent class P. Unlike inner classes, S doesn't retain an instance of P, and therefore P's class description doesn't need to be written. In these cases, if parent classes can be found, their static member classes will be connected; but if they can't be found, the names will not be changed and no ValidityException will be thrown.
ValidityException
- if the found values don't correspond to specjava.io.IOException
public static java.lang.String decodeClassName(java.lang.String fdesc, boolean convertSlashes) throws ValidityException
fdesc
- name in field-descriptor format (Lfoo/bar/baz;)convertSlashes
- true iff slashes should be replaced with periods (true for
"real" field-descriptor format; false for names in classdesc)ValidityException
- if the name isn't validpublic static java.lang.String hexnoprefix(long value)
public static java.lang.String hexnoprefix(long value, int len)
public static java.lang.String hex(long value)
public static void debugerr(java.lang.String message)
public void debug(java.lang.String message)