13aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel/* 23aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * Copyright (C) 2014 The Android Open Source Project 33aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * 43aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * Licensed under the Apache License, Version 2.0 (the "License"); 53aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * you may not use this file except in compliance with the License. 63aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * You may obtain a copy of the License at 73aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * 83aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * http://www.apache.org/licenses/LICENSE-2.0 93aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * 103aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * Unless required by applicable law or agreed to in writing, software 113aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * distributed under the License is distributed on an "AS IS" BASIS, 123aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * See the License for the specific language governing permissions and 143aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * limitations under the License. 153aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel */ 163aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel 173aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Rousselpackage com.android.framework.multidexlegacytestservices; 183aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel 193aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Rousselimport java.lang.reflect.InvocationTargetException; 203aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Rousselimport java.lang.reflect.Method; 213aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel 223aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel/** 233aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * Offer an indirection to some Big0xx classes and have their initialization 243aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel * spread along a period of time. 253aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel */ 263aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Rousselpublic class ReflectIntermediateClass { 273aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel 283aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel public static int get(int from, int to, int sleepMillis) throws ClassNotFoundException, 293aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel SecurityException, NoSuchMethodException, IllegalArgumentException, 303aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel IllegalAccessException, InvocationTargetException, InstantiationException { 313aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel int value = 0; 323aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel for (int i = from; i <= to; i++) { 333aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel Class<?> bigClass = Class.forName( 343aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel "com.android.framework.multidexlegacytestservices.manymethods.Big0" + i); 353aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel Method get = bigClass.getMethod("get" + i); 363aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel value += ((Integer) get.invoke(bigClass.newInstance())).intValue(); 373aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel try { 383aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel Thread.sleep(sleepMillis); 393aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel } catch (InterruptedException e) { 403aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel e.printStackTrace(); 413aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel } 423aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel } 433aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel return value; 443aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel } 453aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel 463aac33e7262dc53d878b9c7d44c3cfd31619d128Yohann Roussel} 47