aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco
diff options
context:
space:
mode:
authorEvgeny Mandrikov <Godin@users.noreply.github.com>2016-06-24 11:23:49 +0200
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2016-06-24 11:23:49 +0200
commit70565308277973dfd8b61c7545c03bc4fb1fd725 (patch)
treee508ff56157e83405d1ced6f6b8b59358a2e329c /org.jacoco.core.test/src/org/jacoco
parentaa4fda878a04d0d9ef46d57814e9f6af49fc6020 (diff)
downloadjacoco-70565308277973dfd8b61c7545c03bc4fb1fd725.tar.gz
Fix instrumentation of interfaces with default methods (#428)
Without this change instrumented classes can't pass consistency checks for a constant pool and cause IncompatibleClassChangeError starting with OpenJDK 9 EA b122 (see https://bugs.openjdk.java.net/browse/JDK-8145148).
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactoryTest.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactoryTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactoryTest.java
index e244b822..c8da6d6d 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactoryTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeArrayStrategyFactoryTest.java
@@ -12,7 +12,9 @@
package org.jacoco.core.internal.instr;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.jacoco.core.runtime.IExecutionDataAccessorGenerator;
import org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator;
@@ -92,9 +94,13 @@ public class ProbeArrayStrategyFactoryTest {
@Test
public void testClass8() {
- test(Opcodes.V1_8, 0, false, true);
+ final IProbeArrayStrategy strategy = test(Opcodes.V1_8, 0, false, true);
assertDataField(InstrSupport.DATAFIELD_ACC);
assertInitMethod(true);
+
+ final ClassVisitorMock cv = new ClassVisitorMock();
+ strategy.storeInstance(cv.visitMethod(0, null, null, null, null), 0);
+ assertFalse(cv.interfaceMethod);
}
@Test
@@ -120,9 +126,14 @@ public class ProbeArrayStrategyFactoryTest {
@Test
public void testInterface8() {
- test(Opcodes.V1_8, Opcodes.ACC_INTERFACE, false, true);
+ final IProbeArrayStrategy strategy = test(Opcodes.V1_8,
+ Opcodes.ACC_INTERFACE, false, true);
assertDataField(InstrSupport.DATAFIELD_INTF_ACC);
assertInitMethod(true);
+
+ final ClassVisitorMock cv = new ClassVisitorMock();
+ strategy.storeInstance(cv.visitMethod(0, null, null, null, null), 0);
+ assertTrue(cv.interfaceMethod);
}
@Test
@@ -177,6 +188,7 @@ public class ProbeArrayStrategyFactoryTest {
private String methodName;
private boolean frames;
+ private boolean interfaceMethod;
ClassVisitorMock() {
super(Opcodes.ASM5);
@@ -203,6 +215,12 @@ public class ProbeArrayStrategyFactoryTest {
int nStack, Object[] stack) {
frames = true;
}
+
+ @Override
+ public void visitMethodInsn(int opcode, String owner,
+ String name, String desc, boolean itf) {
+ interfaceMethod = itf;
+ }
};
}
}