作者:梅爱敏_629 | 来源:互联网 | 2023-05-26 15:13
此方法的实现如下:public void validate(JCTree tree, Env env, boolean checkRaw) { Valida
此方法的实现如下:
public void validate(JCTree tree, Env env, boolean checkRaw) {
Validator vr = new Validator(env,Check.this);
vr.validateTree(tree, checkRaw, true);
}
这个方法在Attr中有两处调用,如下:

checkRaw为false表示不用检查是否为Raw类型。这样就不会出现这样的警告 ”找到原始类型: {0} 缺少泛型类{1}的类型参数“
关于Raw类型参见:https://www.cnblogs.com/extjs4/p/9209276.html
另外还有一个方法调用如上方法进行实现,代码如下:
public void validate(JCTree tree, Env env) {
validate(tree, env, true);
}
Validate a type expression. That is,check that all type arguments of a parametric type are within
their bounds. This must be done in a second phase after type attribution
since a class might have a subclass as type parameter bound. E.g:
and we can‘t treeMaker sure that the bound is already attributed because of possible cycles.
AttrVisitor method: Validate a type expression, if it is not null, catching and reporting any completion failures.
调用这个方法的地方如下截图。

还有另外的地方调用这个方法,代码如下:
/** AttrVisitor method: Validate a list of type expressions.
*/
public void validate(List extends JCTree> trees, Env env) {
for (List extends JCTree> l = trees; l.nonEmpty(); l = l.tail) {
validate(l.head, env);
}
}
这个方法调用地方的截图如下:
