Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,22 @@ public void should_filter_when_default_is_first() {
assertIgnored(new Range(switchNode.getNext(), expectedToInclusive));
}

@Test
public void should_not_filter_empty_lookup_switch() {
final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, 0,
"name", "(Ljava/lang/String;)V", null, null);
m.visitVarInsn(Opcodes.ALOAD, 1);
m.visitVarInsn(Opcodes.ASTORE, 2);
m.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/String", "hashCode",
"()I", false);
final Label defaultCase = new Label();
m.visitLookupSwitchInsn(defaultCase, null, new Label[] {});
m.visitLabel(defaultCase);
m.visitInsn(Opcodes.RETURN);

filter.filter(m, context, output);

assertIgnored();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public void match(final AbstractInsnNode start,
final Set<AbstractInsnNode> replacements = new HashSet<AbstractInsnNode>();
replacements.add(skipNonOpcodes(defaultLabel));

if (hashCodes == 0) {
return;
}

for (int i = 0; i < hashCodes; i++) {
while (true) {
nextIsVar(Opcodes.ALOAD, "s");
Expand Down
3 changes: 2 additions & 1 deletion org.jacoco.doc/docroot/doc/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ <h3>Fixed bugs</h3>
that source references are actually files
(GitHub <a href="https://github.com/jacoco/jacoco/issues/941">#941</a>).</li>
<li><code>NullPointerException</code> during filtering
(GitHub <a href="https://github.com/jacoco/jacoco/issues/942">#942</a>).</li>
(GitHub <a href="https://github.com/jacoco/jacoco/issues/942">#942</a>,
<a href="https://github.com/jacoco/jacoco/issues/944">#944</a>).</li>
</ul>

<h3>Non-functional Changes</h3>
Expand Down