aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2018-08-02 21:56:26 +0200
committerEvgeny Mandrikov <Godin@users.noreply.github.com>2018-08-02 21:56:26 +0200
commitb2c5ff73d24cc0c57f308f046de008568068b4c8 (patch)
treeede5f93173e1a7f9fc7fe8300b2ba94040a8a46c /org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8
parent65d1aea1bd0f85f8be9bbc5076b7191515fe5f39 (diff)
downloadplatform_external_jacoco-b2c5ff73d24cc0c57f308f046de008568068b4c8.tar.gz
platform_external_jacoco-b2c5ff73d24cc0c57f308f046de008568068b4c8.tar.bz2
platform_external_jacoco-b2c5ff73d24cc0c57f308f046de008568068b4c8.zip
Reorganize validation test packages (#716)
* Use module names as package names * Merge previously separate filter validation tests * Move non-version specific tests to org.jacoco.core.test
Diffstat (limited to 'org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8')
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/AnnotationOnLocalVariableTest.java36
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java50
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BootstrapMethodReferenceTest.java128
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java35
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceOnlyDefaultMethodsTest.java34
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java37
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java41
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/AnnotationOnLocalVariableTarget.java40
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/BadCycleInterfaceTarget.java50
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceDefaultMethodsTarget.java42
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceOnlyDefaultMethodsTarget.java40
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaExpressionsTarget.java35
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaInInterfaceTarget.java25
13 files changed, 593 insertions, 0 deletions
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/AnnotationOnLocalVariableTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/AnnotationOnLocalVariableTest.java
new file mode 100644
index 00000000..0b9a3c1d
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/AnnotationOnLocalVariableTest.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java8.targets.AnnotationOnLocalVariableTarget;
+import org.junit.Test;
+
+/**
+ * Test of ASM bug
+ * <a href="https://gitlab.ow2.org/asm/asm/issues/317815">#317815</a>
+ */
+public class AnnotationOnLocalVariableTest extends ValidationTestBase {
+
+ public AnnotationOnLocalVariableTest() {
+ super(AnnotationOnLocalVariableTarget.class);
+ }
+
+ @Test
+ public void testCoverageResult() {
+
+ assertLine("var", ICounter.FULLY_COVERED);
+
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java
new file mode 100644
index 00000000..b9f0a469
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java8.targets.BadCycleInterfaceTarget;
+import org.junit.Test;
+
+/**
+ * Test of "bad cycles" with interfaces.
+ */
+public class BadCycleInterfaceTest extends ValidationTestBase {
+
+ public BadCycleInterfaceTest() throws Exception {
+ super(BadCycleInterfaceTarget.class);
+ }
+
+ @Test
+ public void test() throws Exception {
+ if (JAVA_VERSION.isBefore("1.8.0_152")) {
+ // Incorrect interpetation of JVMS 5.5 in JDK 8 causes a default
+ // method to be called before the static initializer of an interface
+ // (see JDK-8098557 and JDK-8164302):
+ assertLine("baseclinit", ICounter.FULLY_COVERED);
+ assertLine("childdefault", ICounter.FULLY_COVERED);
+
+ assertLogEvents("baseclinit", "childdefaultmethod", "childclinit",
+ "childstaticmethod");
+ } else {
+ // This shouldn't happen with JDK 9 (see also JDK-8043275)
+ // and starting with JDK 8u152 (see JDK-8167607):
+ assertLine("baseclinit", ICounter.EMPTY);
+ assertLine("childdefault", ICounter.NOT_COVERED);
+ assertLogEvents("childclinit", "childstaticmethod");
+ }
+ assertLine("childclinit", ICounter.FULLY_COVERED);
+ assertLine("childstatic", ICounter.FULLY_COVERED);
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BootstrapMethodReferenceTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BootstrapMethodReferenceTest.java
new file mode 100644
index 00000000..69348001
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BootstrapMethodReferenceTest.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.ConstantCallSite;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.reflect.InvocationTargetException;
+
+import org.jacoco.core.instr.Instrumenter;
+import org.jacoco.core.runtime.IRuntime;
+import org.jacoco.core.runtime.RuntimeData;
+import org.jacoco.core.runtime.SystemPropertiesRuntime;
+import org.jacoco.core.test.TargetLoader;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Handle;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * Test of ASM bug
+ * <a href="https://gitlab.ow2.org/asm/asm/issues/317748">#317748</a> that
+ * caused
+ * {@code java.lang.ClassFormatError: Short length on BootstrapMethods in class file}
+ * during instrumentation.
+ */
+public class BootstrapMethodReferenceTest {
+
+ private IRuntime runtime;
+ private Instrumenter instrumenter;
+
+ @Before
+ public void setup() throws Exception {
+ runtime = new SystemPropertiesRuntime();
+ instrumenter = new Instrumenter(runtime);
+ runtime.startup(new RuntimeData());
+ }
+
+ @After
+ public void teardown() {
+ runtime.shutdown();
+ }
+
+ @Test
+ public void test() throws Exception {
+ final String className = "Example";
+
+ final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
+ cw.visit(Opcodes.V1_7, Opcodes.ACC_PUBLIC, className, null,
+ "java/lang/Object", null);
+
+ final MethodVisitor mv = cw.visitMethod(
+ Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "run", "()I", null,
+ null);
+ mv.visitCode();
+ addCauseOfResizeInstructions(mv);
+ final MethodType methodType = MethodType.methodType(CallSite.class,
+ MethodHandles.Lookup.class, String.class, MethodType.class);
+ final Handle handle = new Handle(Opcodes.H_INVOKESTATIC,
+ this.getClass().getCanonicalName().replace('.', '/'),
+ "bootstrap", methodType.toMethodDescriptorString(), false);
+ mv.visitInvokeDynamicInsn("invoke", "()I", handle);
+ mv.visitInsn(Opcodes.IRETURN);
+ mv.visitMaxs(1, 0);
+ mv.visitEnd();
+
+ cw.visitEnd();
+
+ final byte[] original = cw.toByteArray();
+ assertEquals(42, run(className, original));
+
+ final byte[] instrumented = instrumenter.instrument(original,
+ className);
+ assertEquals(42, run(className, instrumented));
+ }
+
+ private static int run(final String className, final byte[] bytes)
+ throws ClassNotFoundException, NoSuchMethodException,
+ InvocationTargetException, IllegalAccessException {
+ final Integer result = (Integer) new TargetLoader()
+ .add(className, bytes).getMethod("run").invoke(null);
+ return result.intValue();
+ }
+
+ /**
+ * Adds code that triggers usage of
+ * {@link org.objectweb.asm.MethodWriter#COMPUTE_INSERTED_FRAMES} during
+ * instrumentation.
+ */
+ private static void addCauseOfResizeInstructions(final MethodVisitor mv) {
+ mv.visitInsn(Opcodes.ICONST_0);
+ mv.visitInsn(Opcodes.ICONST_1);
+ final Label target = new Label();
+ mv.visitJumpInsn(Opcodes.IFLE, target);
+ for (int i = 0; i < Short.MAX_VALUE; i++) {
+ mv.visitInsn(Opcodes.NOP);
+ }
+ mv.visitLabel(target);
+ }
+
+ public static CallSite bootstrap(final MethodHandles.Lookup caller,
+ final String name, final MethodType type) throws Exception {
+ return new ConstantCallSite(
+ caller.findStatic(BootstrapMethodReferenceTest.class,
+ "callTarget", MethodType.methodType(int.class)));
+ }
+
+ public static int callTarget() {
+ return 42;
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java
new file mode 100644
index 00000000..4701e27f
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java8.targets.InterfaceDefaultMethodsTarget;
+import org.junit.Test;
+
+/**
+ * Tests of static initializer and default methods in interfaces.
+ */
+public class InterfaceDefaultMethodsTest extends ValidationTestBase {
+
+ public InterfaceDefaultMethodsTest() {
+ super(InterfaceDefaultMethodsTarget.class);
+ }
+
+ @Test
+ public void testCoverageResult() {
+ assertLine("clinit", ICounter.FULLY_COVERED);
+ assertLine("m1", ICounter.FULLY_COVERED);
+ assertLine("m2", ICounter.NOT_COVERED);
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceOnlyDefaultMethodsTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceOnlyDefaultMethodsTest.java
new file mode 100644
index 00000000..e0ffc723
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/InterfaceOnlyDefaultMethodsTest.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java8.targets.InterfaceOnlyDefaultMethodsTarget;
+import org.junit.Test;
+
+/**
+ * Tests of default methods in interfaces.
+ */
+public class InterfaceOnlyDefaultMethodsTest extends ValidationTestBase {
+
+ public InterfaceOnlyDefaultMethodsTest() {
+ super(InterfaceOnlyDefaultMethodsTarget.class);
+ }
+
+ @Test
+ public void testCoverageResult() {
+ assertLine("m1", ICounter.FULLY_COVERED);
+ assertLine("m2", ICounter.NOT_COVERED);
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java
new file mode 100644
index 00000000..1d97a3dc
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java8.targets.LambdaExpressionsTarget;
+import org.junit.Test;
+
+/**
+ * Tests for different lambda expressions.
+ */
+public class LambdaExpressionsTest extends ValidationTestBase {
+
+ public LambdaExpressionsTest() {
+ super(LambdaExpressionsTarget.class);
+ }
+
+ @Test
+ public void testCoverageResult() {
+
+ // Coverage of lambda bodies
+ assertLine("executedlambdabody", ICounter.FULLY_COVERED);
+ assertLine("notexecutedlambdabody", ICounter.NOT_COVERED);
+
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java
new file mode 100644
index 00000000..4d4d184f
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java8.targets.LambdaInInterfaceTarget;
+import org.junit.Test;
+
+/**
+ * Tests a constant with a lambda value in an interface.
+ */
+public class LambdaInInterfaceTest extends ValidationTestBase {
+
+ public LambdaInInterfaceTest() {
+ super(LambdaInInterfaceTarget.class);
+ }
+
+ @Override
+ protected void run(final Class<?> targetClass) throws Exception {
+ ((Runnable) targetClass.getField("RUN").get(null)).run();
+ }
+
+ @Test
+ public void testCoverageResult() {
+
+ // Coverage of lambda body
+ assertLine("lambdabody", ICounter.FULLY_COVERED);
+
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/AnnotationOnLocalVariableTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/AnnotationOnLocalVariableTarget.java
new file mode 100644
index 00000000..b2d6acbf
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/AnnotationOnLocalVariableTarget.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8.targets;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This test target contains annotation on local variable.
+ */
+public class AnnotationOnLocalVariableTarget {
+
+ @Documented
+ @Retention(RetentionPolicy.CLASS)
+ @Target(ElementType.TYPE_USE)
+ @interface NonNull {
+ }
+
+ private static Object legacy() {
+ return new Object();
+ }
+
+ public static void main(String[] args) {
+ @NonNull
+ Object o = legacy(); // $line-var$
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/BadCycleInterfaceTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/BadCycleInterfaceTarget.java
new file mode 100644
index 00000000..bac69f81
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/BadCycleInterfaceTarget.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8.targets;
+
+import org.jacoco.core.test.validation.targets.Stubs;
+
+public class BadCycleInterfaceTarget {
+
+ public interface Base {
+ static final Object BASE_CONST = new Child() {
+ {
+ Stubs.logEvent("baseclinit"); // $line-baseclinit$
+ }
+ }.childDefaultMethod();
+
+ default void baseDefaultMethod() {
+ }
+ }
+
+ public interface Child extends Base {
+ static final Object CHILD_CONST = new Object() {
+ {
+ Stubs.logEvent("childclinit"); // $line-childclinit$
+ }
+ };
+
+ default Object childDefaultMethod() {
+ Stubs.logEvent("childdefaultmethod"); // $line-childdefault$
+ return null;
+ }
+
+ static void childStaticMethod() {
+ Stubs.logEvent("childstaticmethod"); // $line-childstatic$
+ }
+ }
+
+ public static void main(String[] args) {
+ Child.childStaticMethod();
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceDefaultMethodsTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceDefaultMethodsTarget.java
new file mode 100644
index 00000000..2c8a13db
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceDefaultMethodsTarget.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8.targets;
+
+import static org.jacoco.core.test.validation.targets.Stubs.i1;
+
+/**
+ * This test target is an interface with a class initializer and default methods.
+ */
+public interface InterfaceDefaultMethodsTarget {
+
+ public static final int CONST = i1(); // $line-clinit$
+
+ default void m1() {
+ return; // $line-m1$
+ }
+
+ default void m2() {
+ return; // $line-m2$
+ }
+
+ public class Impl implements InterfaceDefaultMethodsTarget {
+
+ public Impl() {
+ m1();
+ }
+ }
+
+ public static void main(String[] args) {
+ new Impl();
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceOnlyDefaultMethodsTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceOnlyDefaultMethodsTarget.java
new file mode 100644
index 00000000..dd96e0ad
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/InterfaceOnlyDefaultMethodsTarget.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8.targets;
+
+/**
+ * This test target is an interface with only default methods.
+ */
+public interface InterfaceOnlyDefaultMethodsTarget {
+
+ // no <clinit>, only default methods:
+
+ default void m1() {
+ return; // $line-m1$
+ }
+
+ default void m2() {
+ return; // $line-m2$
+ }
+
+ public class Impl implements InterfaceOnlyDefaultMethodsTarget {
+
+ public Impl() {
+ m1();
+ }
+ }
+
+ public static void main(String[] args) {
+ new Impl();
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaExpressionsTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaExpressionsTarget.java
new file mode 100644
index 00000000..a8c7bd8b
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaExpressionsTarget.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8.targets;
+
+import static org.jacoco.core.test.validation.targets.Stubs.exec;
+import static org.jacoco.core.test.validation.targets.Stubs.noexec;
+import static org.jacoco.core.test.validation.targets.Stubs.nop;
+
+/**
+ * This test target contains different lambda expressions.
+ */
+public class LambdaExpressionsTarget {
+
+ public static void main(String[] args) {
+
+ exec(() -> {
+ nop(); // $line-executedlambdabody$
+ });
+
+ noexec(() -> {
+ nop(); // $line-notexecutedlambdabody$
+ });
+
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaInInterfaceTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaInInterfaceTarget.java
new file mode 100644
index 00000000..4a9db74b
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/targets/LambdaInInterfaceTarget.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8.targets;
+
+import static org.jacoco.core.test.validation.targets.Stubs.nop;
+
+/**
+ * This test target builds a constant with a lambda value in an interface.
+ */
+public interface LambdaInInterfaceTarget {
+
+ public static final Runnable RUN = () -> {
+ nop(); // $line-lambdabody$
+ };
+
+}