在内部类类型上使用instanceof时,"非法泛型类型的instanceof"?

per*_*rez 4 java instanceof inner-classes

我用NetBeans编写了这样的代码:

public class Grafo<V, E>
{
    class Par
    {
        int a, b;
        Par(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public boolean equals(Object ob)
        {
            if(ob instanceof Par) {
                Par p = (Par)ob;
                return this.a==p.a && this.b==p.b;
            }

            return false;
        }
    }

    //stuff...
} //end of class Grafo
Run Code Online (Sandbox Code Playgroud)

错误在内部类"Par"的方法equals()中.

NetBeans说错误是"非法泛型类型的instanceof".错误在下面的行中.

            if(ob instanceof Par) {
Run Code Online (Sandbox Code Playgroud)

错误的原因是什么?

Ste*_*n C 8

尝试 ob instanceof Grafo<?,?>.Par

我认为编译器认为ob instanceof Par涉及对泛型类型参数的运行时检查; 即它相当于ob instanceof Grafo<V,E>.Par.但是instanceof测试无法检查泛型类型参数.