Real type is not always set properly in Java

Not every time a real type of a class is set using getClass method. It is better to rely on getting class from a field than getting from this reference. Sometimes real class type is held in this$0 synthetic field.