Home | History | Annotate | Download | only in art
      1 /*
      2  * Copyright (C) 2011 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 package art;
     18 
     19 public class Test1919 {
     20   public static final boolean PRINT_ALL_THREADS = false;
     21 
     22   public static void run() {
     23     for (Event e : getEvents()) {
     24       if (PRINT_ALL_THREADS ||
     25           e.thr.equals(Thread.currentThread()) ||
     26           e.thr.getName().equals("JVMTI_THREAD-Test1919")) {
     27         System.out.println(e.name + ": " + e.thr.getName());
     28       }
     29     }
     30   }
     31 
     32   static class Event {
     33     public final String name;
     34     public final Thread thr;
     35     public Event(String name, Thread thr) {
     36       this.name = name;
     37       this.thr = thr;
     38     }
     39   }
     40 
     41   public static Event[] getEvents() {
     42     String[] ns = getEventNames();
     43     Thread[] ts = getEventThreads();
     44     Event[] es = new Event[Math.min(ns.length, ts.length)];
     45     for (int i = 0; i < es.length; i++) {
     46       es[i] = new Event(ns[i], ts[i]);
     47     }
     48     return es;
     49   }
     50 
     51   public static native String[] getEventNames();
     52   public static native Thread[] getEventThreads();
     53 }
     54