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  *    Marc R. Hoffmann - initial API and implementation
     10  *
     11  *******************************************************************************/
     12 package org.jacoco.core.test.validation.targets;
     13 
     14 import static org.jacoco.core.test.validation.targets.Stubs.nop;
     15 
     16 /**
     17  * This target uses synchronized blocks which compile to try/catch statements.
     18  */
     19 public class Target12 {
     20 
     21 	static void simple() {
     22 		Object lock1 = new Object();
     23 		synchronized (lock1) {
     24 			nop();
     25 		}
     26 	}
     27 
     28 	static void nested() {
     29 		Object lock1 = new Object();
     30 		synchronized (lock1) {
     31 			nop();
     32 			Object lock2 = new Object();
     33 			synchronized (lock2) {
     34 				nop();
     35 			}
     36 			nop();
     37 		}
     38 
     39 	}
     40 
     41 	public static void main(String[] args) {
     42 		simple();
     43 		nested();
     44 	}
     45 
     46 }
     47