From 1acf071c93a7a5be78ab06c15ca6f28baf9ab41a Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 20 Sep 2019 20:37:46 +0200 Subject: [PATCH 1/3] (WIP) add unit test --- .../filter/KotlinWhenStringFilterTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilterTest.java index df42803d94..4408ef3d2e 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilterTest.java @@ -105,4 +105,21 @@ public void should_filter() { assertIgnored(new Range(expectedFromInclusive, 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.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(); + } + } From ca8710c62f57850f2e5048643d39d4a9f70d6467 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 20 Sep 2019 20:40:19 +0200 Subject: [PATCH 2/3] (WIP) fix --- .../core/internal/analysis/filter/KotlinWhenStringFilter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java index fcccb55077..864473f27f 100644 --- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java +++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenStringFilter.java @@ -67,6 +67,10 @@ public void match(final AbstractInsnNode start, hashCodes = tableSwitch.labels.size(); } + if (hashCodes == 0) { + return; + } + final Set replacements = new HashSet(); replacements.add(skipNonOpcodes(defaultLabel)); From a0dfa59a65251851e84d59c8c14be7aeed8a9ce9 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Sun, 22 Sep 2019 04:38:05 +0200 Subject: [PATCH 3/3] (WIP) update changelog --- org.jacoco.doc/docroot/doc/changes.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html index 82042ad001..c1f5bf722c 100644 --- a/org.jacoco.doc/docroot/doc/changes.html +++ b/org.jacoco.doc/docroot/doc/changes.html @@ -47,6 +47,8 @@

Fixed bugs

  • To avoid failures with invalid class files report generation now checks that source references are actually files (GitHub #941).
  • +
  • NullPointerException during filtering + (GitHub #942).
  • Non-functional Changes