Home | History | Annotate | Download | only in targets
      1 /*******************************************************************************
      2  * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
      3  * All rights reserved. This program and the accompanying materials
      4  * are made available under the terms of the Eclipse Public License v1.0
      5  * which accompanies this distribution, and is available at
      6  * http://www.eclipse.org/legal/epl-v10.html
      7  *
      8  * Contributors:
      9  *    Evgeny Mandrikov - initial API and implementation
     10  *
     11  *******************************************************************************/
     12 package org.jacoco.core.test.filter.targets;
     13 
     14 /**
     15  * This test target is synthetic methods.
     16  */
     17 public class Synthetic { // $line-classdef$
     18 
     19 	private static int counter; // $line-field$
     20 
     21 	/**
     22 	 * {@link org.jacoco.core.test.validation.targets.Target06 Default
     23 	 * constructor will refer to a line of class definition}, so that we define
     24 	 * constructor explicitly in order to verify that we filter all other
     25 	 * constructions here that might refer to line of class definition.
     26 	 */
     27 	private Synthetic() {
     28 	}
     29 
     30 	static class Inner extends Synthetic { // $line-inner.classdef$
     31 
     32 		Inner() {
     33 		}
     34 
     35 		/**
     36 		 * Access to private field of outer class causes creation of synthetic
     37 		 * methods in it. In case of javac those methods refer to the line of
     38 		 * outer class definition, in case of ECJ - to the line of field.
     39 		 */
     40 		private static void inc() {
     41 			counter = counter + 2;
     42 		}
     43 
     44 		/**
     45 		 * Difference of return type with overridden method causes creation of
     46 		 * synthetic bridge method in this class. In case of javac this method
     47 		 * refers to the line of inner class definition, in case of EJC - to the
     48 		 * first line of file.
     49 		 */
     50 		@Override
     51 		public String get() {
     52 			return null;
     53 		}
     54 	}
     55 
     56 	public Object get() {
     57 		return null;
     58 	}
     59 
     60 	public static void main(String[] args) {
     61 		Inner.inc();
     62 	}
     63 
     64 }
     65