我有这段代码:
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
public class ClientLookup<T extends Remote> {
private T sharedObject;
public void lookup(String adress) throws MalformedURLException, RemoteException, NotBoundException {
sharedObject = (T) Naming.lookup(adress);
}
public T getSharedObject() {
return sharedObject;
}
}
Run Code Online (Sandbox Code Playgroud)
带有" (T)Naming.lookup(地址) "的部分给我一个警告:" 类型安全:未经检查从远程转为T "
我不想使用" @SuppressWarnings("unchecked") ",我只是想知道为什么当" T扩展远程 " 时它会显示警告并修复它(对于干净的代码)
Thnaks.