github / github/codeql

Java: Some generic classes have two `StaticInitializer`

オープン
#5,730 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
question
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

### 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`).

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。