• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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 
17 #include <pthread.h>
18 
19 #include <cstdio>
20 #include <iostream>
21 #include <vector>
22 
23 #include "android-base/logging.h"
24 #include "jni.h"
25 #include "jvmti.h"
26 
27 #include "scoped_local_ref.h"
28 #include "scoped_primitive_array.h"
29 
30 // Test infrastructure
31 #include "jvmti_helper.h"
32 #include "test_env.h"
33 
34 namespace art {
35 namespace Test1932MonitorEventsMisc {
36 
Java_art_Test1932_doNativeLockPrint(JNIEnv * env,jclass klass,jobject lock)37 extern "C" JNIEXPORT void JNICALL Java_art_Test1932_doNativeLockPrint(JNIEnv* env,
38                                                                       jclass klass,
39                                                                       jobject lock) {
40                                                                       // jobject atomic_boolean) {
41   // ScopedLocalRef<jclass> atomic_klass(env, env->FindClass("java/util/concurrent/AtomicBoolean"));
42   // if (env->ExceptionCheck()) {
43   //   return;
44   // }
45   // jmethodID atomic_set = env->GetMethodID(atomic_klass.get(), "set", "(z)V");
46   jmethodID print_state = env->GetStaticMethodID(
47       klass, "printLockState", "(Lart/Monitors$NamedLock;Ljava/lang/Object;I)V");
48   if (env->ExceptionCheck()) {
49     return;
50   }
51   jint res = env->MonitorEnter(lock);
52   ScopedLocalRef<jobject> exc(env, env->ExceptionOccurred());
53   env->ExceptionClear();
54   env->CallStaticVoidMethod(klass, print_state, lock, exc.get(), res);
55   env->MonitorExit(lock);
56 }
57 
58 }  // namespace Test1932MonitorEventsMisc
59 }  // namespace art
60