1 /* 2 * Copyright (C) 2007 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 dalvik.system; 18 19 import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; 20 21 import android.annotation.SystemApi; 22 import android.compat.annotation.UnsupportedAppUsage; 23 24 import java.io.FileDescriptor; 25 import java.io.IOException; 26 import java.util.HashMap; 27 import java.util.Map; 28 29 import dalvik.annotation.optimization.FastNative; 30 31 /** 32 * Provides access to some VM-specific debug features. Though this class and 33 * many of its members are public, this class is meant to be wrapped in a more 34 * friendly way for use by application developers. On the Android platform, the 35 * recommended way to access this functionality is through the class 36 * <code>android.os.Debug</code>. 37 * 38 * @hide 39 */ 40 @SystemApi(client = MODULE_LIBRARIES) 41 public final class VMDebug { 42 /** 43 * flag for startMethodTracing(), which adds the results from 44 * startAllocCounting to the trace key file. 45 * 46 * @hide 47 */ 48 @SystemApi(client = MODULE_LIBRARIES) 49 // Must match android.os.Debug.TRACE_COUNT_ALLOCS. 50 public static final int TRACE_COUNT_ALLOCS = 1; 51 52 /* constants for getAllocCount */ 53 private static final int KIND_ALLOCATED_OBJECTS = 1<<0; 54 private static final int KIND_ALLOCATED_BYTES = 1<<1; 55 private static final int KIND_FREED_OBJECTS = 1<<2; 56 private static final int KIND_FREED_BYTES = 1<<3; 57 private static final int KIND_GC_INVOCATIONS = 1<<4; 58 private static final int KIND_CLASS_INIT_COUNT = 1<<5; 59 private static final int KIND_CLASS_INIT_TIME = 1<<6; 60 private static final int KIND_EXT_ALLOCATED_OBJECTS = 1<<12; 61 private static final int KIND_EXT_ALLOCATED_BYTES = 1<<13; 62 private static final int KIND_EXT_FREED_OBJECTS = 1<<14; 63 private static final int KIND_EXT_FREED_BYTES = 1<<15; 64 65 /** 66 * Constant for {@link #getAllocCount(int)} 67 * to get the number of all allocated objects. 68 * 69 * @hide 70 */ 71 @SystemApi(client = MODULE_LIBRARIES) 72 public static final int KIND_GLOBAL_ALLOCATED_OBJECTS = 73 KIND_ALLOCATED_OBJECTS; 74 75 /** 76 * Constant for {@link #getAllocCount(int)} 77 * to get the cumulative size of all objects allocated. 78 * 79 * @hide 80 */ 81 @SystemApi(client = MODULE_LIBRARIES) 82 public static final int KIND_GLOBAL_ALLOCATED_BYTES = 83 KIND_ALLOCATED_BYTES; 84 85 /** 86 * Constant for {@link #getAllocCount(int)} 87 * to get the number of freed objects. 88 * 89 * @hide 90 */ 91 @SystemApi(client = MODULE_LIBRARIES) 92 public static final int KIND_GLOBAL_FREED_OBJECTS = 93 KIND_FREED_OBJECTS; 94 95 /** 96 * Constant for {@link #getAllocCount(int)} 97 * to get the cumulative size of all freed objects. 98 * 99 * @hide 100 */ 101 @SystemApi(client = MODULE_LIBRARIES) 102 public static final int KIND_GLOBAL_FREED_BYTES = 103 KIND_FREED_BYTES; 104 105 /** 106 * Constant for {@link #getAllocCount(int)} 107 * to get the number of times an allocation triggered a blocking GC. 108 * 109 * @hide 110 */ 111 @SystemApi(client = MODULE_LIBRARIES) 112 public static final int KIND_GLOBAL_GC_INVOCATIONS = 113 KIND_GC_INVOCATIONS; 114 115 /** 116 * Constant for {@link #getAllocCount(int)} 117 * to get the number of initialized classes. 118 * 119 * @hide 120 */ 121 @SystemApi(client = MODULE_LIBRARIES) 122 public static final int KIND_GLOBAL_CLASS_INIT_COUNT = 123 KIND_CLASS_INIT_COUNT; 124 125 /** 126 * Constant for {@link #getAllocCount(int)} 127 * to get the cumulative time spent in class initialization. 128 * 129 * @hide 130 */ 131 @SystemApi(client = MODULE_LIBRARIES) 132 public static final int KIND_GLOBAL_CLASS_INIT_TIME = 133 KIND_CLASS_INIT_TIME; 134 135 /** 136 * Constant for {@link #getAllocCount(int)} 137 * to get the number of all allocated objects for current thread. 138 * 139 * @hide 140 */ 141 @SystemApi(client = MODULE_LIBRARIES) 142 public static final int KIND_THREAD_ALLOCATED_OBJECTS = 143 KIND_ALLOCATED_OBJECTS << 16; 144 145 /** 146 * Constant for {@link #getAllocCount(int)} 147 * to get the cumulative size of all objects allocated for current thread. 148 * 149 * @hide 150 */ 151 @SystemApi(client = MODULE_LIBRARIES) 152 public static final int KIND_THREAD_ALLOCATED_BYTES = 153 KIND_ALLOCATED_BYTES << 16; 154 155 /** 156 * Constant for {@link #getAllocCount(int)} 157 * to get the number of times an allocation triggered a blocking GC for current thread. 158 * 159 * @hide 160 */ 161 @SystemApi(client = MODULE_LIBRARIES) 162 public static final int KIND_THREAD_GC_INVOCATIONS = 163 KIND_GC_INVOCATIONS << 16; 164 165 /** 166 * Constant for {@link #getAllocCount(int)} to get all possible stats. 167 * 168 * @hide 169 */ 170 @SystemApi(client = MODULE_LIBRARIES) 171 public static final int KIND_ALL_COUNTS = 0xffffffff; 172 173 /* all methods are static */ VMDebug()174 private VMDebug() {} 175 176 /** 177 * Request JDWP agent to suspend all Java Thread and send VM_START. 178 * 179 * @hide 180 */ 181 @SystemApi(client = MODULE_LIBRARIES) suspendAllAndSendVmStart()182 public static native void suspendAllAndSendVmStart(); 183 184 /** 185 * Returns the time since the last known debugger activity. 186 * 187 * @return the time in milliseconds, or -1 if the debugger is not connected 188 * 189 * @hide 190 */ 191 @SystemApi(client = MODULE_LIBRARIES) 192 @FastNative lastDebuggerActivity()193 public static native long lastDebuggerActivity(); 194 195 /** 196 * Determines if debugging is enabled in this VM. If debugging is not 197 * enabled, a debugger cannot be attached. 198 * 199 * @return true if debugging is enabled 200 * 201 * @hide 202 */ 203 @SystemApi(client = MODULE_LIBRARIES) 204 @FastNative isDebuggingEnabled()205 public static native boolean isDebuggingEnabled(); 206 207 /** 208 * Determines if a debugger is currently attached. 209 * 210 * @return true if (and only if) a debugger is connected 211 * 212 * @hide 213 */ 214 @UnsupportedAppUsage 215 @SystemApi(client = MODULE_LIBRARIES) 216 @FastNative isDebuggerConnected()217 public static native boolean isDebuggerConnected(); 218 219 /** 220 * Returns an array of strings that identify VM features. This is 221 * used by DDMS to determine what sorts of operations the VM can 222 * perform. 223 * 224 * @return array of strings identifying VM features 225 * 226 * @hide 227 */ 228 @SystemApi(client = MODULE_LIBRARIES) getVmFeatureList()229 public static native String[] getVmFeatureList(); 230 231 /** 232 * Start method tracing, specifying a file name as well as a default 233 * buffer size. See <a 234 * href="{@docRoot}guide/developing/tools/traceview.html"> Running the 235 * Traceview Debugging Program</a> for information about reading 236 * trace files. 237 * 238 * <p>You can use either a fully qualified path and 239 * name, or just a name. If only a name is specified, the file will 240 * be created under the /sdcard/ directory. If a name is not given, 241 * the default is /sdcard/dmtrace.trace.</p> 242 * 243 * @param traceFileName name to give the trace file 244 * @param bufferSize the maximum size of both files combined. If passed 245 * as {@code 0}, it defaults to 8MB. 246 * @param flags flags to control method tracing. The only one that 247 * is currently defined is {@link #TRACE_COUNT_ALLOCS}. 248 * @param samplingEnabled if true, sample profiling is enabled. Otherwise, 249 * method instrumentation is used. 250 * @param intervalUs the time between samples in microseconds when 251 * sampling is enabled. 252 * 253 * @hide 254 */ 255 @SystemApi(client = MODULE_LIBRARIES) startMethodTracing(String traceFileName, int bufferSize, int flags, boolean samplingEnabled, int intervalUs)256 public static void startMethodTracing(String traceFileName, int bufferSize, int flags, boolean samplingEnabled, int intervalUs) { 257 startMethodTracingFilename(traceFileName, checkBufferSize(bufferSize), flags, samplingEnabled, intervalUs); 258 } 259 260 /** 261 * Like {@link #startMethodTracing(String, int, int)}, but taking an already-opened 262 * {@code FileDescriptor} in which the trace is written. The file name is also 263 * supplied simply for logging. Makes a dup of the file descriptor. 264 * Streams tracing data to the file if streamingOutput is true. 265 * 266 * @param traceFileName name to give the trace file 267 * @param fd already opened {@code FileDescriptor} in which trace is written 268 * @param bufferSize the maximum size of both files combined. If passed 269 * as {@code 0}, it defaults to 8MB. 270 * @param flags flags to control method tracing. The only one that 271 * is currently defined is {@link #TRACE_COUNT_ALLOCS}. 272 * @param samplingEnabled if true, sample profiling is enabled. Otherwise, 273 * method instrumentation is used. 274 * @param intervalUs the time between samples in microseconds when 275 * sampling is enabled. 276 * @param streamingOutput streams tracing data to the duped {@code fd} file descriptor 277 * if {@code streamingOutput} is {@code true}. 278 * 279 * @hide 280 */ 281 @SystemApi(client = MODULE_LIBRARIES) startMethodTracing(String traceFileName, FileDescriptor fd, int bufferSize, int flags, boolean samplingEnabled, int intervalUs, boolean streamingOutput)282 public static void startMethodTracing(String traceFileName, FileDescriptor fd, int bufferSize, 283 int flags, boolean samplingEnabled, int intervalUs, 284 boolean streamingOutput) { 285 if (fd == null) { 286 throw new NullPointerException("fd == null"); 287 } 288 startMethodTracingFd(traceFileName, fd.getInt$(), checkBufferSize(bufferSize), flags, 289 samplingEnabled, intervalUs, streamingOutput); 290 } 291 292 /** 293 * Starts method tracing without a backing file. When {@link #stopMethodTracing()} 294 * is called, the result is sent directly to DDMS. (If DDMS is not 295 * attached when tracing ends, the profiling data will be discarded.) 296 * 297 * @param bufferSize the maximum size of both files combined. If passed 298 * as {@code 0}, it defaults to 8MB. 299 * @param flags flags to control method tracing. The only one that 300 * is currently defined is {@link #TRACE_COUNT_ALLOCS}. 301 * @param samplingEnabled if true, sample profiling is enabled. Otherwise, 302 * method instrumentation is used. 303 * @param intervalUs the time between samples in microseconds when 304 * sampling is enabled. 305 * 306 * @hide 307 */ 308 @SystemApi(client = MODULE_LIBRARIES) startMethodTracingDdms(int bufferSize, int flags, boolean samplingEnabled, int intervalUs)309 public static void startMethodTracingDdms(int bufferSize, int flags, boolean samplingEnabled, int intervalUs) { 310 startMethodTracingDdmsImpl(checkBufferSize(bufferSize), flags, samplingEnabled, intervalUs); 311 } 312 checkBufferSize(int bufferSize)313 private static int checkBufferSize(int bufferSize) { 314 if (bufferSize == 0) { 315 // Default to 8MB per the documentation. 316 bufferSize = 8 * 1024 * 1024; 317 } 318 if (bufferSize < 1024) { 319 throw new IllegalArgumentException("buffer size < 1024: " + bufferSize); 320 } 321 return bufferSize; 322 } 323 startMethodTracingDdmsImpl(int bufferSize, int flags, boolean samplingEnabled, int intervalUs)324 private static native void startMethodTracingDdmsImpl(int bufferSize, int flags, boolean samplingEnabled, int intervalUs); startMethodTracingFd(String traceFileName, int fd, int bufferSize, int flags, boolean samplingEnabled, int intervalUs, boolean streamingOutput)325 private static native void startMethodTracingFd(String traceFileName, int fd, int bufferSize, 326 int flags, boolean samplingEnabled, int intervalUs, boolean streamingOutput); startMethodTracingFilename(String traceFileName, int bufferSize, int flags, boolean samplingEnabled, int intervalUs)327 private static native void startMethodTracingFilename(String traceFileName, int bufferSize, int flags, boolean samplingEnabled, int intervalUs); 328 329 /** 330 * Determine whether method tracing is currently active and what type is 331 * active. 332 * 333 * @hide 334 */ 335 @SystemApi(client = MODULE_LIBRARIES) getMethodTracingMode()336 public static native int getMethodTracingMode(); 337 338 /** 339 * Stops method tracing. 340 * 341 * @hide 342 */ 343 @SystemApi(client = MODULE_LIBRARIES) stopMethodTracing()344 public static native void stopMethodTracing(); 345 346 /** 347 * Get an indication of thread CPU usage. The value returned indicates the 348 * amount of time that the current thread has spent executing code or 349 * waiting for certain types of I/O. 350 * <p> 351 * The time is expressed in nanoseconds, and is only meaningful when 352 * compared to the result from an earlier call. Note that nanosecond 353 * resolution does not imply nanosecond accuracy. 354 * 355 * @return the CPU usage. A value of -1 means the system does not support 356 * this feature. 357 * 358 * @hide 359 */ 360 @SystemApi(client = MODULE_LIBRARIES) 361 @FastNative threadCpuTimeNanos()362 public static native long threadCpuTimeNanos(); 363 364 /** 365 * Starts counting the number and aggregate size of memory allocations. 366 * 367 * @hide 368 */ 369 @SystemApi(client = MODULE_LIBRARIES) startAllocCounting()370 public static native void startAllocCounting(); 371 372 /** 373 * Stops counting the number and aggregate size of memory allocations. 374 * 375 * @hide 376 */ 377 @SystemApi(client = MODULE_LIBRARIES) stopAllocCounting()378 public static native void stopAllocCounting(); 379 380 /** 381 * Returns information on the number of objects allocated by the runtime between a 382 * {@link #startAllocCounting() start} and {@link #stopAllocCounting() stop}. 383 * 384 * @param kind either {@code KIND_GLOBAL_*} or {@code KIND_THREAD_*}. 385 * 386 * @hide 387 */ 388 @SystemApi(client = MODULE_LIBRARIES) getAllocCount(int kind)389 public static native int getAllocCount(int kind); 390 391 /** 392 * Resets counting the number and aggregate size of memory allocations for the given kinds. 393 * 394 * @param kinds a union of {@code KIND_GLOBAL_*} and {@code KIND_THREAD_*}. 395 * 396 * @hide 397 */ 398 @SystemApi(client = MODULE_LIBRARIES) resetAllocCount(int kinds)399 public static native void resetAllocCount(int kinds); 400 401 /** 402 * This method exists for binary compatibility. It was part of 403 * the allocation limits API which was removed in Android 3.0 (Honeycomb). 404 * 405 * @hide 406 */ 407 @Deprecated setAllocationLimit(int limit)408 public static int setAllocationLimit(int limit) { 409 return -1; 410 } 411 412 /** 413 * This method exists for binary compatibility. It was part of 414 * the allocation limits API which was removed in Android 3.0 (Honeycomb). 415 * 416 * @hide 417 */ 418 @Deprecated setGlobalAllocationLimit(int limit)419 public static int setGlobalAllocationLimit(int limit) { 420 return -1; 421 } 422 423 /** 424 * Count the number of instructions executed between two points. 425 * 426 * @hide 427 */ 428 @Deprecated startInstructionCounting()429 public static void startInstructionCounting() {} 430 431 /** 432 * 433 * @hide 434 */ 435 @Deprecated stopInstructionCounting()436 public static void stopInstructionCounting() {} 437 438 /** 439 * 440 * @hide 441 */ 442 @Deprecated getInstructionCount(int[] counts)443 public static void getInstructionCount(int[] counts) {} 444 445 /** 446 * 447 * @hide 448 */ 449 @Deprecated resetInstructionCount()450 public static void resetInstructionCount() {} 451 452 /** 453 * Dumps a list of loaded class to the log file. 454 * 455 * @param flags a union of {@link android.os.Debug.SHOW_FULL_DETAIL}, 456 * {@link android.os.Debug.SHOW_CLASSLOADER}, and {@link android.os.Debug.SHOW_INITIALIZED}. 457 * 458 * @hide 459 */ 460 @SystemApi(client = MODULE_LIBRARIES) 461 @FastNative printLoadedClasses(int flags)462 public static native void printLoadedClasses(int flags); 463 464 /** 465 * Gets the number of loaded classes. 466 * 467 * @return the number of loaded classes 468 * 469 * @hide 470 */ 471 @SystemApi(client = MODULE_LIBRARIES) 472 @FastNative getLoadedClassCount()473 public static native int getLoadedClassCount(); 474 475 /** 476 * Dumps "hprof" data to the specified file. This may cause a GC. 477 * 478 * The VM may create a temporary file in the same directory. 479 * 480 * @param filename Full pathname of output file (e.g. "/sdcard/dump.hprof"). 481 * @throws UnsupportedOperationException if the VM was built without 482 * HPROF support. 483 * @throws IOException if an error occurs while opening or writing files. 484 * 485 * @hide 486 */ 487 @SystemApi(client = MODULE_LIBRARIES) dumpHprofData(String filename)488 public static void dumpHprofData(String filename) throws IOException { 489 if (filename == null) { 490 throw new NullPointerException("filename == null"); 491 } 492 dumpHprofData(filename, null); 493 } 494 495 /** 496 * Collects "hprof" heap data and sends it to DDMS. This may cause a GC. 497 * 498 * @throws UnsupportedOperationException if the VM was built without 499 * HPROF support. 500 * 501 * @hide 502 */ 503 @SystemApi(client = MODULE_LIBRARIES) dumpHprofDataDdms()504 public static native void dumpHprofDataDdms(); 505 506 /** 507 * Dumps "hprof" heap data to a file, by name or descriptor. 508 * 509 * @param fileName Name of output file. If fd is non-null, the 510 * file name is only used in log messages (and may be null). 511 * @param fd Descriptor of open file that will receive the output. 512 * If this is null, the fileName is used instead. 513 * @throws {@link IOException} if an error occurs while opening or writing files. 514 * 515 * @hide 516 */ 517 @SystemApi(client = MODULE_LIBRARIES) dumpHprofData(String fileName, FileDescriptor fd)518 public static void dumpHprofData(String fileName, FileDescriptor fd) 519 throws IOException { 520 dumpHprofData(fileName, fd != null ? fd.getInt$() : -1); 521 } 522 dumpHprofData(String fileName, int fd)523 private static native void dumpHprofData(String fileName, int fd) 524 throws IOException; 525 526 /** 527 * Dumps the contents of the VM reference tables (e.g. JNI locals and 528 * globals) to the log file. 529 * 530 * @hide 531 */ 532 @UnsupportedAppUsage 533 @SystemApi(client = MODULE_LIBRARIES) dumpReferenceTables()534 public static native void dumpReferenceTables(); 535 536 /** 537 * Counts the instances of a class. 538 * It is the caller's responsibility to do GC if they don't want unreachable 539 * objects to get counted. 540 * 541 * @param klass the class to be counted. 542 * @param assignable if true, any instance whose class is assignable to 543 * {@code klass}, as defined by {@link Class#isAssignableFrom}, 544 * is counted. If false, only instances whose class is 545 * equal to {@code klass} are counted. 546 * @return the number of matching instances. 547 * 548 * @hide 549 */ 550 @SystemApi(client = MODULE_LIBRARIES) countInstancesOfClass(Class klass, boolean assignable)551 public static native long countInstancesOfClass(Class klass, boolean assignable); 552 553 /** 554 * Counts the instances of classes. 555 * It is the caller's responsibility to do GC if they don't want unreachable 556 * objects to get counted. 557 * 558 * @param classes the classes to be counted. 559 * @param assignable if true, any instance whose class is assignable to 560 * {@code classes[i]}, as defined by {@link Class#isAssignableFrom}, 561 * is counted. If false, only instances whose class is 562 * equal to {@code classes[i]} are counted. 563 * @return an array containing the number of matching instances. The value 564 * for index {@code i} is the number of instances of 565 * the class {@code classes[i]} 566 * 567 * @hide 568 */ 569 @SystemApi(client = MODULE_LIBRARIES) countInstancesOfClasses(Class[] classes, boolean assignable)570 public static native long[] countInstancesOfClasses(Class[] classes, boolean assignable); 571 572 /* Map from the names of the runtime stats supported by getRuntimeStat() to their IDs */ 573 private static final HashMap<String, Integer> runtimeStatsMap = new HashMap<>(); 574 575 static { 576 runtimeStatsMap.put("art.gc.gc-count", 0); 577 runtimeStatsMap.put("art.gc.gc-time", 1); 578 runtimeStatsMap.put("art.gc.bytes-allocated", 2); 579 runtimeStatsMap.put("art.gc.bytes-freed", 3); 580 runtimeStatsMap.put("art.gc.blocking-gc-count", 4); 581 runtimeStatsMap.put("art.gc.blocking-gc-time", 5); 582 runtimeStatsMap.put("art.gc.gc-count-rate-histogram", 6); 583 runtimeStatsMap.put("art.gc.blocking-gc-count-rate-histogram", 7); 584 runtimeStatsMap.put("art.gc.objects-allocated", 8); 585 runtimeStatsMap.put("art.gc.total-time-waiting-for-gc", 9); 586 runtimeStatsMap.put("art.gc.pre-oome-gc-count", 10); 587 } 588 589 /** 590 * Returns the value of a particular runtime statistic or {@code null} if no 591 * such runtime statistic exists. 592 * 593 * @param statName the name of the runtime statistic to look up. 594 * 595 * @return the value of the runtime statistic. 596 * 597 * @hide 598 */ 599 @SystemApi(client = MODULE_LIBRARIES) getRuntimeStat(String statName)600 public static String getRuntimeStat(String statName) { 601 if (statName == null) { 602 throw new NullPointerException("statName == null"); 603 } 604 Integer statId = runtimeStatsMap.get(statName); 605 if (statId != null) { 606 return getRuntimeStatInternal(statId); 607 } 608 return null; 609 } 610 611 /** 612 * Returns a map of the names/values of the runtime statistics 613 * that {@link #getRuntimeStat()} supports. 614 * 615 * @return a map of the names/values of the supported runtime statistics. 616 * 617 * @hide 618 */ 619 @SystemApi(client = MODULE_LIBRARIES) getRuntimeStats()620 public static Map<String, String> getRuntimeStats() { 621 HashMap<String, String> map = new HashMap<>(); 622 String[] values = getRuntimeStatsInternal(); 623 for (String name : runtimeStatsMap.keySet()) { 624 int id = runtimeStatsMap.get(name); 625 String value = values[id]; 626 map.put(name, value); 627 } 628 return map; 629 } 630 getRuntimeStatInternal(int statId)631 private static native String getRuntimeStatInternal(int statId); getRuntimeStatsInternal()632 private static native String[] getRuntimeStatsInternal(); 633 634 /** 635 * Attaches an agent to the VM. 636 * 637 * @param agent The path to the agent .so file plus optional agent arguments. 638 * @param classLoader The classloader to use as a loading context. 639 * 640 * @throws IOException if an error occurs while opening {@code agent} file. 641 * 642 * @hide 643 */ 644 @SystemApi(client = MODULE_LIBRARIES) attachAgent(String agent, ClassLoader classLoader)645 public static void attachAgent(String agent, ClassLoader classLoader) throws IOException { 646 nativeAttachAgent(agent, classLoader); 647 } 648 nativeAttachAgent(String agent, ClassLoader classLoader)649 private static native void nativeAttachAgent(String agent, ClassLoader classLoader) 650 throws IOException; 651 652 /** 653 * Exempts a class from any future non-SDK API access checks. 654 * Methods declared in the class will be allowed to perform 655 * reflection/JNI against the framework completely unrestricted. 656 * Note that this does not affect uses of non-SDK APIs that the class links against. 657 * Note that this does not affect methods declared outside this class, e.g. 658 * inherited from a superclass or an implemented interface. 659 * 660 * @param klass The class whose methods should be exempted. 661 * 662 * @hide 663 */ 664 @UnsupportedAppUsage allowHiddenApiReflectionFrom(Class<?> klass)665 public static native void allowHiddenApiReflectionFrom(Class<?> klass); 666 667 /** 668 * Sets the number of frames recorded for allocation tracking. 669 * 670 * @param stackDepth The number of frames captured for each stack trace. 671 * 672 * @hide 673 */ 674 @SystemApi(client = MODULE_LIBRARIES) setAllocTrackerStackDepth(int stackDepth)675 public static native void setAllocTrackerStackDepth(int stackDepth); 676 } 677