blob: 6a4f5ef773aa511a18a17bddf19078b1f2668312 [file] [log] [blame]
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class Transaction {
static class EmptyStatic {
}
static class ResolveString {
static String s = "ResolvedString";
}
static class StaticFieldClass {
public static int intField;
static {
intField = 5;
}
}
static class FinalizableAbortClass {
public static AbortHelperClass finalizableObject;
static {
finalizableObject = new AbortHelperClass();
}
}
static class NativeCallAbortClass {
static {
AbortHelperClass.nativeMethod();
}
}
static class SynchronizedNativeCallAbortClass {
static {
synchronized (SynchronizedNativeCallAbortClass.class) {
AbortHelperClass.nativeMethod();
}
}
}
static class CatchNativeCallAbortClass {
static {
try {
AbortHelperClass.nativeMethod();
} catch (Throwable e) {
// ignore exception.
}
}
}
static class MultipleNativeCallAbortClass {
static {
// Call native method but catch the transaction exception.
try {
AbortHelperClass.nativeMethod();
} catch (Throwable e) {
// ignore exception.
}
// Call another native method.
AbortHelperClass.nativeMethod2();
}
}
static class CatchClassForNameAbortClass {
static {
try {
Class.forName("non.existent.TestClass");
} catch (Throwable e) {
// ignore exception.
}
}
}
static class CatchClassForNameAbortClassTwice {
static {
try {
Class.forName("non.existent.TestClass");
} catch (Throwable e) {
// ignore exception.
}
try {
Class.forName("non.existent.TestClass");
} catch (Throwable e) {
// ignore exception.
}
}
}
// Helper class to abort transaction: finalizable class with natve methods.
static class AbortHelperClass {
public void finalize() throws Throwable {
super.finalize();
}
public static native void nativeMethod();
public static native void nativeMethod2();
}
}