blob: e7085c17347e6625ea894fea6cbf72b81aaf8c55 [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
Mathieu Chartierbb816d62016-09-07 10:17:46 -070021 static class ResolveString {
22 static String s = "ResolvedString";
23 }
24
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010025 static class StaticFieldClass {
26 public static int intField;
27 static {
28 intField = 5;
29 }
30 }
31
Sebastien Hertz1c80bec2015-02-03 11:58:06 +010032 static class FinalizableAbortClass {
33 public static AbortHelperClass finalizableObject;
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010034 static {
Sebastien Hertz1c80bec2015-02-03 11:58:06 +010035 finalizableObject = new AbortHelperClass();
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010036 }
37 }
38
Sebastien Hertz1c80bec2015-02-03 11:58:06 +010039 static class NativeCallAbortClass {
40 static {
41 AbortHelperClass.nativeMethod();
42 }
43 }
44
45 static class SynchronizedNativeCallAbortClass {
46 static {
47 synchronized (SynchronizedNativeCallAbortClass.class) {
48 AbortHelperClass.nativeMethod();
49 }
50 }
51 }
52
53 static class CatchNativeCallAbortClass {
54 static {
55 try {
56 AbortHelperClass.nativeMethod();
57 } catch (Throwable e) {
58 // ignore exception.
59 }
60 }
61 }
62
63 static class MultipleNativeCallAbortClass {
64 static {
65 // Call native method but catch the transaction exception.
66 try {
67 AbortHelperClass.nativeMethod();
68 } catch (Throwable e) {
69 // ignore exception.
70 }
71
72 // Call another native method.
73 AbortHelperClass.nativeMethod2();
74 }
75 }
76
77 // Helper class to abort transaction: finalizable class with natve methods.
78 static class AbortHelperClass {
79 public void finalize() throws Throwable {
80 super.finalize();
81 }
82 public static native void nativeMethod();
83 public static native void nativeMethod2();
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010084 }
85}