github / github/codeql

Java: Extractor succeeds for `codeql test run` despite `module-info.java` not being supported by `-source` version

未关闭
#5,594 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Java question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

### Version
CodeQL CLI v2.5.0

### Description
Similar to #5476

It appears when `codeql test run` encounters a `module-info.java` file, but the `-source` version is lower than 9 (e.g. 8 which is currently the default of the extractor), the extractor aborts but the extraction is considered successful, even if other source files had compilation errors as well.

The `log.log` file contains:
```
[2021-04-03 03:17:48] [ERROR] Exception running the extractor with arguments: --javacOptions -source 8 --strict-javac-errors --encoding UTF-8 --files module-info.java Test.java
[2021-04-03 03:17:48] [ERROR] Exception:
java.lang.AssertionError: null
at javac_extend.com.sun.tools.javac.util.Assert.error(Assert.java:155)
at javac_extend.com.sun.tools.javac.util.Assert.checkNonNull(Assert.java:62)
at javac_extend.com.sun.tools.javac.comp.Enter.moduleEnv(Enter.java:251)
at javac_extend.com.sun.tools.javac.comp.Enter.visitModuleDef(Enter.java:543)
at javac_extend.com.sun.tools.javac.tree.JCTree$JCModuleDecl.accept(JCTree.java:2858)
at javac_extend.com.sun.tools.javac.comp.Enter.classEnter(Enter.java:286)
at javac_extend.com.sun.tools.javac.comp.Enter.classEnter(Enter.java:301)
at javac_extend.com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:323)
at javac_extend.com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:541)
at javac_extend.com.sun.tools.javac.comp.Enter.classEnter(Enter.java:286)
at javac_extend.com.sun.tools.javac.comp.Enter.classEnter(Enter.java:301)
at javac_extend.com.sun.tools.javac.comp.Enter.complete(Enter.java:577)
at javac_extend.com.sun.tools.javac.comp.Enter.main(Enter.java:561)
at javac_extend.com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1069)
at com.semmle.extractor.java.JavaExtractor.runExtractor(JavaExtractor.java:283)
at com.semmle.extractor.java.JavaExtractor.main(JavaExtractor.java:485)

```

Expected would be that when a `module-info.java` file is encountered, but the source Java version does not support it, the extraction should fail.

### Reproduction steps
1. Create a `module-info.java` file:
```java
module test {
}
```
2. Create a test query file `Test.ql`:
```ql
import java

from CompilationUnit c
where c.fromSource()
select c
```
3. Create an empty `Test.expected` file
4. Run `codeql test run --keep-databases`
:x: The test passes

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。