Handle casting to classes which extend jdoc