github / github/codeql

Shadowing happens when overriding method

Abierto
#15,525 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Java question
Lenguaje dominante
CodeQL
Estrellas
10.1k
Forks
2.1k
Merge medio
2 d 15 h
PR fusionados (30 d)
141

Descripción

Consider the following example:

##### MyCallable.qll
```codeql
import java

class CallableByErasure extends Callable {
override predicate hasQualifiedName(string package, string type, string name) {
this.isDeclaredIn(package, type) and this.hasName(name)
}

predicate isDeclaredIn(string package, string type) {
this.getDeclaringType().getErasure().(RefType).hasQualifiedName(package, type)
}
}

```
##### Query.ql
```codeql
import java
// import MyCallable

from Call c
where c.getCallee().hasQualifiedName("java.util", "Set", "iterator")
select c

```

The query correctly finds one instance (see test case below).
If I uncomment `import MyCallable` however, then the query does not return anything. Is this expected behaviour? How do I prevent this from happening?

This is the test case I used:
```java
import java.util.HashSet;
import java.util.Set;

class GenericsClass {
public void foo() {
Set set = new HashSet();
set.iterator();
}
}
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.