类型安全:对象中未经检查的强制转换
2022-08-31 22:23:58
我尝试将对象强制转换为我的 Action 类,但它导致警告:
Type safety: Unchecked cast from Object to Action<ClientInterface>
Action<ClientInterface> action = null;
try {
Object o = c.newInstance();
if (o instanceof Action<?>) {
action = (Action<ClientInterface>) o;
} else {
// TODO 2 Auto-generated catch block
throw new InstantiationException();
}
[...]
感谢您的任何帮助