Write an algorithm in pseudocode to describe deserialization of the serialized form produced by the algorithm. Hint: use reflection to create a class from its name, to create a constructor from its parameter types and to create a new instance of an object from the constructor and the argument values.

What will be an ideal response?


Whenever a handle definition is read, i.e. a class_info, handle correspondence or an object, handle correspondence, store the pair by method map. When a handle is read look it up to find the corresponding class or object.
```
Object deserialize(byte [] stream) { Constructor aConstructor;
read class_name and class_handle;
if (class_information == null) aConstructor = lookup(class_handle);
else {
Class cl = Class.forName(class_name); read number (n) of instance variables Class parameterTypes[]= new Class[n]; for (int i=0 to n-1) {
read name and class_name of instance variable i parameterTypes[i] = Class.forName(class_name);
}
aConstructor = cl.getConstructor(parameterTypes);
map(aConstructor, class_handle);
}
if (next item in stream is object_handle) o = lookup(object_handle);
else {
Object args[] = new Object[n];
for (int i=0 to n-1) {
if (next item in stream is primitive) args[i] = read value else args[i] = deserialize(//rest of stream)
}
Object o = cnew.newInstance(args); read object_handle from stream map(object, object_handle)
return o;
}
}
```

Computer Science & Information Technology

You might also like to view...

The elements of an array are stored in __________ storage locations in the computer’s memory.

Fill in the blank(s) with correct word

Computer Science & Information Technology

The Auto Tab should be changed to Yes only when a text field has a(n):

A) input mask. B) tab stop. C) menu item. D) tab index.

Computer Science & Information Technology

On a typical notebook computer, the screen is in the lid and the keyboard attaches to the system unit with hinges.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A one-dimensional array's Length property is an example of a ReadOnly property.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology