COMP204-08B Assignment 3

A Reflection exercise


Your task is to implement a program, that reads in the serialized first object found in a binary file (whose name is the first command line argument).

Assuming that some binary file a3_arrayList10.ser contains the serialized version of an ArrayList with ten Integer entries 0 to 9, then the output of a sample solution should look like (more or less) like below, because the first method in ArrayList which has the correct signature is "get(int offset)".

> java A3 a3_arrayList10.ser

Class = java.util.ArrayList
SuperClass = java.util.AbstractList
Method = public java.lang.Object java.util.ArrayList.get(int)
return value for 0 = 0
Min = 0
return value for min = 0
Max = 9
return value for max = 9

Assuming that some binary file a3_rectangle.ser contains the serialized version of a Rectangle, which does not have any such method, then a sample solution should look like (more or less):
> java A3 a3_rectangle.ser 

Class = java.awt.Rectangle
SuperClass = java.awt.geom.Rectangle2D

What to submit:

One java file containing all you code.
Document your code well.
Use the javadoc @author tag to give your name and ID!

As always, assessment will be based on the following criteria:

  1. Functionality
  2. Reasonable clarity and style of programming.
  3. Reasonable documentation;

Here are a few hints:

  1. study the slides on reflection
  2. the largest integer is Integer.MAX_VALUE
  3. if Integer.MAX_VALUE is not valid, use binary search between 0 and Integer.MAX_VALUE to find the maximum valid integer. Similar for the minimum.