fixes a NPE which occured if the class of the invoked method isn't in the specified environment.