Skip to content

Commit

Permalink
module-info.class should be excluded from analysis (bazelbuild#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin authored and marchof committed Mar 16, 2019
1 parent 795c8f9 commit 1db0792
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ public void setup() {
analyzer = new Analyzer(executionData, new EmptyStructureVisitor());
}

@Test
public void should_ignore_module_info() throws Exception {
final ClassWriter cw = new ClassWriter(0);
cw.visit(Opcodes.V9, Opcodes.ACC_MODULE, "module-info", null, null,
null);
cw.visitModule("module", 0, null).visitEnd();
cw.visitEnd();
final byte[] bytes = cw.toByteArray();

analyzer.analyzeClass(bytes, "");

assertTrue(classes.isEmpty());
}

@Test
public void should_ignore_synthetic_classes() throws Exception {
final ClassWriter cw = new ClassWriter(0);
Expand Down
3 changes: 3 additions & 0 deletions org.jacoco.core/src/org/jacoco/core/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public void visitEnd() {
private void analyzeClass(final byte[] source) {
final long classId = CRC64.classId(source);
final ClassReader reader = InstrSupport.classReaderFor(source);
if ((reader.getAccess() & Opcodes.ACC_MODULE) != 0) {
return;
}
if ((reader.getAccess() & Opcodes.ACC_SYNTHETIC) != 0) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ <h3>Fixed bugs</h3>
<li>Fixed incorrect update of frames caused by bug in ASM library in case of
arrays with more than 7 dimensions
(GitHub <a href="https://github.com/jacoco/jacoco/issues/839">#839</a>).</li>
<li>Fixed regression, which was introduced in 0.8.3 -
<code>module-info.class</code> should be excluded from analysis to not cause
<code>IllegalStateException</code>
(GitHub <a href="https://github.com/jacoco/jacoco/issues/859">#859</a>).</li>
</ul>

<h3>API Changes</h3>
Expand Down

0 comments on commit 1db0792

Please sign in to comment.