use of il.ac.bgu.cs.bp.bpjs.model.BProgramSyncSnapshot in project BPjs by bThink-BGU.
the class BProgramSyncSnapshotIO method deserialize.
public BProgramSyncSnapshot deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
try {
Context ctxt = ContextFactory.getGlobal().enterContext();
// must use interpreter mode
ctxt.setOptimizationLevel(-1);
final ScriptableObject globalScope = ctxt.initStandardObjects();
try (ScriptableInputStream sis = new ScriptableInputStream(new ByteArrayInputStream(bytes), globalScope)) {
Header header = (Header) sis.readObject();
Set<BThreadSyncSnapshot> bthreads = new HashSet<>(header.bthreadCount);
for (int i = 0; i < header.bthreadCount; i++) {
bthreads.add(readBThreadSnapshot(sis, globalScope));
}
List<BEvent> events = new ArrayList<>(header.externalEventCount);
for (int i = 0; i < header.externalEventCount; i++) {
events.add((BEvent) sis.readObject());
}
return new BProgramSyncSnapshot(bprogram, bthreads, events, header.fa);
}
} finally {
Context.exit();
}
}
Aggregations