1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2011 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Worker package art; 18*795d594fSAndroid Build Coastguard Worker 19*795d594fSAndroid Build Coastguard Worker public class Test901 { run()20*795d594fSAndroid Build Coastguard Worker public static void run() { 21*795d594fSAndroid Build Coastguard Worker System.out.println("Hello, world!"); 22*795d594fSAndroid Build Coastguard Worker 23*795d594fSAndroid Build Coastguard Worker if (checkLivePhase()) { 24*795d594fSAndroid Build Coastguard Worker System.out.println("Agent in live phase."); 25*795d594fSAndroid Build Coastguard Worker } 26*795d594fSAndroid Build Coastguard Worker if (checkUnattached()) { 27*795d594fSAndroid Build Coastguard Worker System.out.println("Received expected error for unattached JVMTI calls"); 28*795d594fSAndroid Build Coastguard Worker } 29*795d594fSAndroid Build Coastguard Worker 30*795d594fSAndroid Build Coastguard Worker set(0); // OTHER 31*795d594fSAndroid Build Coastguard Worker set(1); // GC 32*795d594fSAndroid Build Coastguard Worker set(2); // CLASS 33*795d594fSAndroid Build Coastguard Worker set(4); // JNI 34*795d594fSAndroid Build Coastguard Worker set(8); // Error. 35*795d594fSAndroid Build Coastguard Worker 36*795d594fSAndroid Build Coastguard Worker testErrorNames(); 37*795d594fSAndroid Build Coastguard Worker } 38*795d594fSAndroid Build Coastguard Worker set(int i)39*795d594fSAndroid Build Coastguard Worker private static void set(int i) { 40*795d594fSAndroid Build Coastguard Worker System.out.println(i); 41*795d594fSAndroid Build Coastguard Worker try { 42*795d594fSAndroid Build Coastguard Worker setVerboseFlag(i, true); 43*795d594fSAndroid Build Coastguard Worker setVerboseFlag(i, false); 44*795d594fSAndroid Build Coastguard Worker } catch (RuntimeException e) { 45*795d594fSAndroid Build Coastguard Worker System.out.println(e.getMessage()); 46*795d594fSAndroid Build Coastguard Worker } 47*795d594fSAndroid Build Coastguard Worker } 48*795d594fSAndroid Build Coastguard Worker testErrorNames()49*795d594fSAndroid Build Coastguard Worker private static void testErrorNames() { 50*795d594fSAndroid Build Coastguard Worker int consecutiveErrors = 0; 51*795d594fSAndroid Build Coastguard Worker String lastError = null; 52*795d594fSAndroid Build Coastguard Worker for (int i = -1; i <= 117; i++) { 53*795d594fSAndroid Build Coastguard Worker String errorName = null; 54*795d594fSAndroid Build Coastguard Worker String error = null; 55*795d594fSAndroid Build Coastguard Worker try { 56*795d594fSAndroid Build Coastguard Worker errorName = getErrorName(i); 57*795d594fSAndroid Build Coastguard Worker } catch (RuntimeException e) { 58*795d594fSAndroid Build Coastguard Worker error = e.getMessage(); 59*795d594fSAndroid Build Coastguard Worker } 60*795d594fSAndroid Build Coastguard Worker 61*795d594fSAndroid Build Coastguard Worker if (lastError != null && 62*795d594fSAndroid Build Coastguard Worker (errorName != null || (error != null && !lastError.equals(error)))) { 63*795d594fSAndroid Build Coastguard Worker System.out.println(consecutiveErrors + " times " + lastError); 64*795d594fSAndroid Build Coastguard Worker lastError = null; 65*795d594fSAndroid Build Coastguard Worker consecutiveErrors = 0; 66*795d594fSAndroid Build Coastguard Worker } 67*795d594fSAndroid Build Coastguard Worker 68*795d594fSAndroid Build Coastguard Worker if (errorName != null) { 69*795d594fSAndroid Build Coastguard Worker System.out.println(i + " = " + errorName); 70*795d594fSAndroid Build Coastguard Worker } else { 71*795d594fSAndroid Build Coastguard Worker lastError = error; 72*795d594fSAndroid Build Coastguard Worker consecutiveErrors++; 73*795d594fSAndroid Build Coastguard Worker } 74*795d594fSAndroid Build Coastguard Worker } 75*795d594fSAndroid Build Coastguard Worker if (consecutiveErrors > 0) { 76*795d594fSAndroid Build Coastguard Worker System.out.println(consecutiveErrors + " times " + lastError); 77*795d594fSAndroid Build Coastguard Worker } 78*795d594fSAndroid Build Coastguard Worker } 79*795d594fSAndroid Build Coastguard Worker checkLivePhase()80*795d594fSAndroid Build Coastguard Worker private static native boolean checkLivePhase(); setVerboseFlag(int flag, boolean value)81*795d594fSAndroid Build Coastguard Worker private static native void setVerboseFlag(int flag, boolean value); checkUnattached()82*795d594fSAndroid Build Coastguard Worker private static native boolean checkUnattached(); getErrorName(int error)83*795d594fSAndroid Build Coastguard Worker private static native String getErrorName(int error); 84*795d594fSAndroid Build Coastguard Worker } 85