Type safety: Unchecked cast from Object

Yes – this is a natural consequence of type erasure. If o is actually an instance of Action<String> that won’t be caught by the cast – you’ll only see the problem when you try to use it, passing in a ClientInterface instead of a string.

You can get rid of the warning using:

@SuppressWarnings("unchecked")

as a function annotation, but you can’t easily sort out the underlying problem 🙁

Leave a Comment