can’t cast to implemented interface

This can happen if two different classloaders load a class named AutocompleteResult.

These two classes are then treated as entirely different classes, even if they have the same package and name (and even implementation/fields/methods).

A common cause for this is if you use some kind of plugin system and both your base classes and the plugin classes provide the same class.

To check for this issue print the value returned by Class.getClassLoader() on both offending classes (i.e. the class of the interface implemented by Device and the result of AutocompleteResult.class).

Leave a Comment