我试图获取响应中收到的Class类型,突然我收到此异常:
java.lang.ClassCastException: com.myweb.process.api.util.MyProcessModel
cannot be cast to com.myweb.process.api.util.MyProcessModel
这怎么可能?
这与类路径有关吗?
我正在运行的代码是:
List<Object> responses = context.getResponses();
for (Object response : responses) {
if (response instanceof MyProcessModel) {
MyProcessModel model = (MyProcessModel) response;
// Process...
}
}
首先,instanceof
始终为false
,如果我尝试强制转换该值,则会出现上述异常。