Say you have this code:

```
public <T> T deserialize(String input, Class<T> type) {
 return somethingThatRetunsAnInstanceOfT();
}

```

But, if the method accepted Type instead of Class, which is needed for proper JSON deserialization of generics, it would look like this:

```
public <T> T deserialize(String input, Type type) {
 return (T) somethingThatRetunsAnInstanceOfT();
}

```

Is there a way to avoid this ugly unchecked cast?