aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test.validation.java8
diff options
context:
space:
mode:
authorEvgeny Mandrikov <Godin@users.noreply.github.com>2018-07-21 22:47:34 +0200
committerGitHub <noreply@github.com>2018-07-21 22:47:34 +0200
commit88e67b3f121121161f29f15ab8c45e6fc7ecd6d4 (patch)
tree0eb5e7cc76a8cf440f3011daadbbd8a23a6acca1 /org.jacoco.core.test.validation.java8
parent753d6532d56892d037ff7958ea30c9bc27f6e8e4 (diff)
downloadjacoco-88e67b3f121121161f29f15ab8c45e6fc7ecd6d4.tar.gz
Extract "validation" tests into separate modules (#711)
Diffstat (limited to 'org.jacoco.core.test.validation.java8')
-rw-r--r--org.jacoco.core.test.validation.java8/.classpath20
-rw-r--r--org.jacoco.core.test.validation.java8/.project30
-rw-r--r--org.jacoco.core.test.validation.java8/pom.xml37
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/AnnotationOnLocalVariableTest.java35
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/BadCycleInterfaceTest.java49
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/BootstrapMethodReferenceTest.java126
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/InterfaceDefaultMethodsTest.java34
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/InterfaceOnlyDefaultMethodsTest.java33
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/LambdaExpressionsTest.java36
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/LambdaInInterfaceTest.java40
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/AnnotationOnLocalVariableTarget.java40
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/BadCycleInterface.java48
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/InterfaceDefaultMethodsTarget.java42
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/InterfaceOnlyDefaultMethodsTarget.java40
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/LambdaExpressionsTarget.java35
-rw-r--r--org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/LambdaInInterfaceTarget.java25
16 files changed, 670 insertions, 0 deletions
diff --git a/org.jacoco.core.test.validation.java8/.classpath b/org.jacoco.core.test.validation.java8/.classpath
new file mode 100644
index 00000000..9f0c38ba
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/.classpath
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/classes" path="src">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.jacoco.core.test.validation.java8/.project b/org.jacoco.core.test.validation.java8/.project
new file mode 100644
index 00000000..deab0f76
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/.project
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jacoco.core.test.validation.java8</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>.settings</name>
+ <type>2</type>
+ <locationURI>PARENT-1-PROJECT_LOC/org.jacoco.core.test/.settings</locationURI>
+ </link>
+ </linkedResources>
+</projectDescription>
diff --git a/org.jacoco.core.test.validation.java8/pom.xml b/org.jacoco.core.test.validation.java8/pom.xml
new file mode 100644
index 00000000..b682ab88
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jacoco</groupId>
+ <artifactId>org.jacoco.core.test.validation</artifactId>
+ <version>0.8.2-SNAPSHOT</version>
+ <relativePath>../org.jacoco.core.test.validation</relativePath>
+ </parent>
+
+ <artifactId>org.jacoco.core.test.validation.java8</artifactId>
+
+ <name>JaCoCo :: Test :: Core :: Validation Java 8</name>
+
+ <properties>
+ <bytecode.version>8</bytecode.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>org.jacoco.core.test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/AnnotationOnLocalVariableTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/AnnotationOnLocalVariableTest.java
new file mode 100644
index 00000000..64e8fafa
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/AnnotationOnLocalVariableTest.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:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.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/BadCycleInterfaceTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/BadCycleInterfaceTest.java
new file mode 100644
index 00000000..a8ab6727
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/BadCycleInterfaceTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.targets.BadCycleInterface;
+import org.junit.Test;
+
+/**
+ * Test of "bad cycles" with interfaces.
+ */
+public class BadCycleInterfaceTest extends ValidationTestBase {
+
+ public BadCycleInterfaceTest() throws Exception {
+ super(BadCycleInterface.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/BootstrapMethodReferenceTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/BootstrapMethodReferenceTest.java
new file mode 100644
index 00000000..dc20f0af
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/BootstrapMethodReferenceTest.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * 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;
+
+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 final IRuntime runtime = new SystemPropertiesRuntime();
+ private final Instrumenter instrumenter = new Instrumenter(runtime);
+
+ @Before
+ public void setup() throws Exception {
+ 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 {
+ return (Integer) new TargetLoader().add(className, bytes)
+ .getMethod("run").invoke(null);
+ }
+
+ /**
+ * 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);
+ }
+
+ @SuppressWarnings("unused")
+ 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)));
+ }
+
+ @SuppressWarnings("unused")
+ public static int callTarget() {
+ return 42;
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/InterfaceDefaultMethodsTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/InterfaceDefaultMethodsTest.java
new file mode 100644
index 00000000..4611d782
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/InterfaceDefaultMethodsTest.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:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.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/InterfaceOnlyDefaultMethodsTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/InterfaceOnlyDefaultMethodsTest.java
new file mode 100644
index 00000000..bbb7f0ed
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/InterfaceOnlyDefaultMethodsTest.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.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/LambdaExpressionsTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/LambdaExpressionsTest.java
new file mode 100644
index 00000000..f1344991
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/LambdaExpressionsTest.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:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.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/LambdaInInterfaceTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/LambdaInInterfaceTest.java
new file mode 100644
index 00000000..759a78fc
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/LambdaInInterfaceTest.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:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.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/targets/AnnotationOnLocalVariableTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/AnnotationOnLocalVariableTarget.java
new file mode 100644
index 00000000..3417c098
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/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.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/targets/BadCycleInterface.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/BadCycleInterface.java
new file mode 100644
index 00000000..d7e7a746
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/BadCycleInterface.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.targets;
+
+public class BadCycleInterface {
+
+ 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/targets/InterfaceDefaultMethodsTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/InterfaceDefaultMethodsTarget.java
new file mode 100644
index 00000000..2e952995
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/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.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/targets/InterfaceOnlyDefaultMethodsTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/InterfaceOnlyDefaultMethodsTarget.java
new file mode 100644
index 00000000..5fa48fb8
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/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.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/targets/LambdaExpressionsTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/LambdaExpressionsTarget.java
new file mode 100644
index 00000000..bcb65b60
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/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.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/targets/LambdaInInterfaceTarget.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/targets/LambdaInInterfaceTarget.java
new file mode 100644
index 00000000..23edc6dd
--- /dev/null
+++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/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.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$
+ };
+
+}