/* * Copyright (C) 2017 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. */ package art; import java.lang.reflect.Executable; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Base64; import java.util.EnumSet; import java.util.concurrent.CountDownLatch; import java.util.function.Consumer; import static art.SuspendEvents.setupTest; import static art.SuspendEvents.setupSuspendBreakpointFor; import static art.SuspendEvents.clearSuspendBreakpointFor; import static art.SuspendEvents.setupSuspendSingleStepAt; import static art.SuspendEvents.setupFieldSuspendFor; import static art.SuspendEvents.setupSuspendMethodEvent; import static art.SuspendEvents.setupSuspendExceptionEvent; import static art.SuspendEvents.setupSuspendPopFrameEvent; import static art.SuspendEvents.EVENT_TYPE_CLASS_LOAD; import static art.SuspendEvents.EVENT_TYPE_CLASS_PREPARE; import static art.SuspendEvents.setupSuspendClassEvent; public class Test1953 { private static boolean IS_ART = System.getProperty("java.vm.name").equals("Dalvik"); public final boolean canRunClassLoadTests; public static void doNothing() {} public interface TestRunnable extends Runnable { public int getBaseCallCount(); public Method getCalledMethod() throws Exception; public default Method getCallingMethod() throws Exception { return this.getClass().getMethod("run"); }; } public static interface TestSuspender { public void setup(Thread thr); public void waitForSuspend(Thread thr); public void cleanup(Thread thr); } public static interface ThreadRunnable { public void run(Thread thr); } public static TestSuspender makeSuspend(final ThreadRunnable setup, final ThreadRunnable clean) { return new TestSuspender() { public void setup(Thread thr) { setup.run(thr); } public void waitForSuspend(Thread thr) { SuspendEvents.waitForSuspendHit(thr); } public void cleanup(Thread thr) { clean.run(thr); } }; } public void runTestOn(TestRunnable testObj, ThreadRunnable su, ThreadRunnable cl) throws Exception { runTestOn(testObj, makeSuspend(su, cl)); } private static void SafePrintStackTrace(StackTraceElement st[]) { for (StackTraceElement e : st) { System.out.println("\t" + e.getClassName() + "." + e.getMethodName() + "(" + (e.isNativeMethod() ? "Native Method" : e.getFileName()) + ")"); if (e.getClassName().equals("art.Test1953") && e.getMethodName().equals("runTests")) { System.out.println("\t