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