blob: 2542de7f27ed5da5eea92305449734e4db4be502 [file] [log] [blame]
Andreas Gampe03ec9302015-08-27 17:41:47 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import java.lang.reflect.InvocationTargetException;
18import java.lang.reflect.Method;
19import java.lang.reflect.Modifier;
20
21/*
22 * Test case for conditionally using one of two synchronized objects.
23 *
24 * This code cannot be verified at the moment, as the join point merges a register with two
25 * different lock options. Do not put it into Main to avoid the whole class being run in the
26 * interpreter.
27 */
28public class TwoPath {
29
30 /**
31 * Conditionally uses one of the synchronized objects.
32 */
33 public static void twoPath(Object obj1, Object obj2, int x) {
34 Object localObj;
35
36 synchronized (obj1) {
37 synchronized(obj2) {
38 if (x == 0) {
39 localObj = obj2;
40 } else {
41 localObj = obj1;
42 }
43 }
44 }
45
46 doNothing(localObj);
47 }
48
49 private static void doNothing(Object o) {
50 }
51}