|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.ObjectInputStream.HandleTable
Unsynchronized table which tracks wire handle to object mappings, as well as ClassNotFoundExceptions associated with deserialized objects. This class implements an exception-propagation algorithm for determining which objects should have ClassNotFoundExceptions associated with them, taking into account cycles and discontinuities (e.g., skipped fields) in the object graph.
General use of the table is as follows: during deserialization, a given object is first assigned a handle by calling the assign method. This method leaves the assigned handle in an "open" state, wherein dependencies on the exception status of other handles can be registered by calling the markDependency method, or an exception can be directly associated with the handle by calling markException. When a handle is tagged with an exception, the HandleTable assumes responsibility for propagating the exception to any other objects which depend (transitively) on the exception-tagged object.
Once all exception information/dependencies for the handle have been registered, the handle should be "closed" by calling the finish method on it. The act of finishing a handle allows the exception propagation algorithm to aggressively prune dependency links, lessening the performance/memory impact of exception tracking.
Note that the exception propagation algorithm used depends on handles being assigned/finished in LIFO order; however, for simplicity as well as memory conservation, it does not enforce this constraint.
Nested Class Summary | |
private static class |
ObjectInputStream.HandleTable.HandleList
Simple growable list of (integer) handles. |
Field Summary | |
(package private) ObjectInputStream.HandleTable.HandleList[] |
deps
array mapping handle -> list of dependent handles (if any) |
(package private) Object[] |
entries
array mapping handle -> object/exception (depending on status) |
(package private) int |
lowDep
lowest unresolved dependency |
(package private) int |
size
number of handles in table |
(package private) byte[] |
status
array mapping handle -> object status |
private static byte |
STATUS_EXCEPTION
|
private static byte |
STATUS_OK
|
private static byte |
STATUS_UNKNOWN
|
Constructor Summary | |
(package private) |
ObjectInputStream.HandleTable(int initialCapacity)
Creates handle table with the given initial capacity. |
Method Summary | |
(package private) int |
assign(Object obj)
Assigns next available handle to given object, and returns assigned handle. |
(package private) void |
clear()
Resets table to its initial state. |
(package private) void |
finish(int handle)
Marks given handle as finished, meaning that no new dependencies will be marked for handle. |
private void |
grow()
Expands capacity of internal arrays. |
(package private) ClassNotFoundException |
lookupException(int handle)
Looks up and returns ClassNotFoundException associated with the given handle. |
(package private) Object |
lookupObject(int handle)
Looks up and returns object associated with the given handle. |
(package private) void |
markDependency(int dependent,
int target)
Registers a dependency (in exception status) of one handle on another. |
(package private) void |
markException(int handle,
ClassNotFoundException ex)
Associates a ClassNotFoundException (if one not already associated) with the currently active handle and propagates it to other referencing objects as appropriate. |
(package private) void |
setObject(int handle,
Object obj)
Assigns a new object to the given handle. |
(package private) int |
size()
Returns number of handles registered in table. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final byte STATUS_OK
private static final byte STATUS_UNKNOWN
private static final byte STATUS_EXCEPTION
byte[] status
Object[] entries
ObjectInputStream.HandleTable.HandleList[] deps
int lowDep
int size
Constructor Detail |
ObjectInputStream.HandleTable(int initialCapacity)
Method Detail |
int assign(Object obj)
void markDependency(int dependent, int target)
void markException(int handle, ClassNotFoundException ex)
void finish(int handle)
void setObject(int handle, Object obj)
Object lookupObject(int handle)
ClassNotFoundException lookupException(int handle)
void clear()
int size()
private void grow()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |