github / github/codeql

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

Aperta
#5,594 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Java question
Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 15h
PR unite (30g)
141

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.