/*
 * Copyright (C) 2023 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.
 */

import java.lang.reflect.Method;

class Main {
  public static void main(String[] args) throws Exception {
    System.loadLibrary(args[0]);
    Class<?> cls = Class.forName("TestCase");
    ensureJitBaselineCompiled(cls, "withBranch");
    Method m = cls.getDeclaredMethod("withBranch", boolean.class);
    m.invoke(null, true);
    m.invoke(null, true);
    m.invoke(null, false);
    ensureJitCompiled(cls, "withBranch");
  }

  public static native void ensureJitBaselineCompiled(Class<?> cls, String methodName);
  public static native void ensureJitCompiled(Class<?> cls, String methodName);
}
