I assume you are talking about the real problem of the difference between the runtime type (which includes the classloader) and the compile time type (which does not).
If so, I'm afraid I don't have any fixes at the language level. If I had a time machine, we could go back and stop the decision of making the classloader part of the type, so that the compile time type and the runtime type were the same. But making that change now would break too much existing code, to say nothing of all of the "clever" uses of classloaders that peoples have invented. Most of these are disgusting hacks (my technical term), but some are also useful.
As a craftsperson/programmer, you can avoid a lot of the problem cases by declaring all of your arguments and return values as interfaces rather than classes. Since interfaces are not scoped by classloader, you don't run into the same problem. This is yet another reason to have all of your declarations done with interfaces. I know that there are some people who think that I'm an interface bigot, but only because the use of interfaces lets you avoid to many problems.
At this point in
Java's life, it is very hard to fix problems by changing the language, since almost everything is depended upon by a large number of running programs and systems. But we can find idioms that keep the problems from getting worse. Not as good as a real fix, but better than nothing.