Class SerialCopy
A plain ObjectInputStream resolves every class through the nearest user-defined loader on the stack, which for a copy made inside LINE is the loader of jline.jar. A lambda or anonymous class defined in user code loaded by a child loader (the JDK single-file source launcher, a notebook kernel, an IDE runner, MATLAB's dynamic class path) is invisible to that loader, so copying a model that carried such a handle (e.g. a class-dependence function) failed with "cannot assign instance of java.lang.invoke.SerializedLambda". The writer here records the loader of every class it describes, including the capturing class of a serialized lambda, and the reader tries them in turn after the default resolution, then the thread context loader. Copyright (c) 2012-2026, Imperial College London All rights reserved.
-
Method Summary
-
Method Details
-
deepCopy
Returns a deep copy ofobj.- Type Parameters:
T- its type- Parameters:
obj- a serializable object graph- Returns:
- an independent copy
- Throws:
IOException- if some reachable object is not serializableClassNotFoundException- if a class of the graph cannot be resolved on read
-