I am reviewing some code. Inside that code there a constructor for an event listener, similar to the following code:
public class MyClass implements ActionListener {
SomeOtherClass m_oc;
public MyClass(SomeOtherClass oc) {
if (null == oc) {
throw new IllegalArgumentException("oc cannot be null");
}
m_oc = oc;
m_oc.getClass();
}
@Override
public void actionPerformed(ActionEvent e) {
do_stuff();
}
private void do_stuff() {
/* some more code here, but this code never uses m_oc */
}
}
Now, my questions is: Why would who wrote this code call m_oc.getClass()
?
That object (m_oc
), which is an instance of SomeOtherClass
is not used any where in the code apart from that location in the constructor.