github / github/codeql

Java: Some generic classes have two `StaticInitializer`

Ouverte
#5,730 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
question
Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 15 h
PR mergées (30 j)
141

Description

### Version
CodeQL CLI 2.5.1

### Description
It appears that in some situations generic classes have two `StaticInitializer` elements, a regular one with source information initializing static fields and another one where `StaticInitializer.getBody()` has no result and which has no source location.

I was not able to pinpoint what exactly is causing it. Trying to create a database using `javac` for a single source file does not seem to trigger it.

### Example
CodeQL query:
```ql
import java

from ClassOrInterface c, StaticInitializer s
where
c.fromSource()
and s = c.getAMethod()
and count(c.getAMethod().(StaticInitializer)) > 1
select c, s
```
[Query Console link](https://lgtm.com/query/2605405991256877475/)

This can also be reproduced locally by using autobuilder to build the Gson project (at least Gson commit `1215841e46f1e90d964d335acbc0d8c9aad43590`).

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.