aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/targets/SyntheticTarget.java
blob: efede92d106e465769784dbb9d3fd36b590c6290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*******************************************************************************
 * Copyright (c) 2009, 2019 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.java5.targets;

/**
 * This test target results in synthetic methods.
 */
public class SyntheticTarget { // assertEmpty()

	private static int counter; // assertEmpty()

	/**
	 * {@link org.jacoco.core.test.validation.java5.targets.ConstructorsTarget
	 * Default constructor will refer to a line of class definition}, so that we
	 * define constructor explicitly in order to verify that we filter all other
	 * constructions here that might refer to line of class definition.
	 */
	private SyntheticTarget() {
	}

	static class Inner extends SyntheticTarget { // assertEmpty()

		Inner() {
		}

		/**
		 * Access to private field of outer class causes creation of synthetic
		 * methods in it. In case of javac those methods refer to the line of
		 * outer class definition, in case of ECJ - to the line of field.
		 */
		private static void inc() {
			counter = counter + 2;
		}

		/**
		 * Difference of return type with overridden method causes creation of
		 * synthetic bridge method in this class. In case of javac this method
		 * refers to the line of inner class definition, in case of EJC - to the
		 * first line of file.
		 */
		@Override
		public String get() {
			return null;
		}
	}

	public Object get() {
		return null;
	}

	public static void main(String[] args) {
		Inner.inc();
	}

}