blob: 00e1fbb2c198ea23c12924303b7eeab3af30ac89 [file] [log] [blame]
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001/*
2 * Copyright (C) 2014 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
17public class Transaction {
18 static class EmptyStatic {
19 }
20
21 static class StaticFieldClass {
22 public static int intField;
23 static {
24 intField = 5;
25 }
26 }
27
Sebastien Hertz1c80bec2015-02-03 11:58:06 +010028 static class FinalizableAbortClass {
29 public static AbortHelperClass finalizableObject;
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010030 static {
Sebastien Hertz1c80bec2015-02-03 11:58:06 +010031 finalizableObject = new AbortHelperClass();
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010032 }
33 }
34
Sebastien Hertz1c80bec2015-02-03 11:58:06 +010035 static class NativeCallAbortClass {
36 static {
37 AbortHelperClass.nativeMethod();
38 }
39 }
40
41 static class SynchronizedNativeCallAbortClass {
42 static {
43 synchronized (SynchronizedNativeCallAbortClass.class) {
44 AbortHelperClass.nativeMethod();
45 }
46 }
47 }
48
49 static class CatchNativeCallAbortClass {
50 static {
51 try {
52 AbortHelperClass.nativeMethod();
53 } catch (Throwable e) {
54 // ignore exception.
55 }
56 }
57 }
58
59 static class MultipleNativeCallAbortClass {
60 static {
61 // Call native method but catch the transaction exception.
62 try {
63 AbortHelperClass.nativeMethod();
64 } catch (Throwable e) {
65 // ignore exception.
66 }
67
68 // Call another native method.
69 AbortHelperClass.nativeMethod2();
70 }
71 }
72
73 // Helper class to abort transaction: finalizable class with natve methods.
74 static class AbortHelperClass {
75 public void finalize() throws Throwable {
76 super.finalize();
77 }
78 public static native void nativeMethod();
79 public static native void nativeMethod2();
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010080 }
81}