1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package lockedregioncodeinjection; 15 16 public class TestTarget { 17 public static int boostCount = 0; 18 public static int unboostCount = 0; 19 public static int invokeCount = 0; 20 public static boolean nextUnboostThrows = false; 21 boost()22 public static void boost() { 23 boostCount++; 24 } 25 unboost()26 public static void unboost() { 27 if (nextUnboostThrows) { 28 nextUnboostThrows = false; 29 throw new RuntimeException(); 30 } 31 unboostCount++; 32 } 33 invoke()34 public static void invoke() { 35 invokeCount++; 36 } 37 resetCount()38 public static void resetCount() { 39 boostCount = 0; 40 unboostCount = 0; 41 invokeCount = 0; 42 } 43 synchronizedCall()44 public synchronized void synchronizedCall() { 45 invoke(); 46 } 47 synchronizedCallReturnInt()48 public synchronized int synchronizedCallReturnInt() { 49 invoke(); 50 return 0; 51 } 52 synchronizedCallReturnObject()53 public synchronized Object synchronizedCallReturnObject() { 54 invoke(); 55 return this; 56 } 57 synchronizedThrowsOnUnboost()58 public void synchronizedThrowsOnUnboost() { 59 nextUnboostThrows = true; 60 synchronized(this) { 61 invoke(); 62 } 63 } 64 } 65