Skip to content

Commit 1db0792

Browse files
Godinmarchof
authored andcommitted
module-info.class should be excluded from analysis (bazel-contrib#859)
1 parent 795c8f9 commit 1db0792

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

org.jacoco.core.test/src/org/jacoco/core/analysis/AnalyzerTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ public void setup() {
7676
analyzer = new Analyzer(executionData, new EmptyStructureVisitor());
7777
}
7878

79+
@Test
80+
public void should_ignore_module_info() throws Exception {
81+
final ClassWriter cw = new ClassWriter(0);
82+
cw.visit(Opcodes.V9, Opcodes.ACC_MODULE, "module-info", null, null,
83+
null);
84+
cw.visitModule("module", 0, null).visitEnd();
85+
cw.visitEnd();
86+
final byte[] bytes = cw.toByteArray();
87+
88+
analyzer.analyzeClass(bytes, "");
89+
90+
assertTrue(classes.isEmpty());
91+
}
92+
7993
@Test
8094
public void should_ignore_synthetic_classes() throws Exception {
8195
final ClassWriter cw = new ClassWriter(0);

org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public void visitEnd() {
104104
private void analyzeClass(final byte[] source) {
105105
final long classId = CRC64.classId(source);
106106
final ClassReader reader = InstrSupport.classReaderFor(source);
107+
if ((reader.getAccess() & Opcodes.ACC_MODULE) != 0) {
108+
return;
109+
}
107110
if ((reader.getAccess() & Opcodes.ACC_SYNTHETIC) != 0) {
108111
return;
109112
}

org.jacoco.doc/docroot/doc/changes.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ <h3>Fixed bugs</h3>
3535
<li>Fixed incorrect update of frames caused by bug in ASM library in case of
3636
arrays with more than 7 dimensions
3737
(GitHub <a href="https://github.com/jacoco/jacoco/issues/839">#839</a>).</li>
38+
<li>Fixed regression, which was introduced in 0.8.3 -
39+
<code>module-info.class</code> should be excluded from analysis to not cause
40+
<code>IllegalStateException</code>
41+
(GitHub <a href="https://github.com/jacoco/jacoco/issues/859">#859</a>).</li>
3842
</ul>
3943

4044
<h3>API Changes</h3>

0 commit comments

Comments
 (0)