# FramesComputationMode

[View Source](https://cs.android.com/search?q=file:com/android/build/api/instrumentation/FramesComputationMode.kt+class:com.android.build.api.instrumentation.FramesComputationMode) Added in 4.2.0


```
enum FramesComputationMode : Enum<FramesComputationMode>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||
| ↳ | [kotlin.Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html)\<[FramesComputationMode](https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode)\> ||
|   | ↳ | [com.android.build.api.instrumentation.FramesComputationMode](https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode) |

*** ** * ** ***

Indicates the frame computation mode that will be applied to the bytecode of the classes instrumented by ASM visitors registered through Component.transformClassesWith.

The default mode is to `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#COPY_FRAMES`.

## Summary

| ### Enum Values |
|---|---|
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#COMPUTE_FRAMES_FOR_ALL_CLASSES` | Stack frames and the maximum stack sizes will be skipped when reading the original classes, and will **not** be computed by `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html`. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#COMPUTE_FRAMES_FOR_INSTRUMENTED_CLASSES` | Stack frames and the maximum stack sizes will be skipped when reading the original classes, and will be instead computed from scratch by `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html` based on the classpath of the original classes. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS` | Stack frames and the maximum stack size will be computed by `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html` for any modified or added methods based on the classpath of the original classes. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#COPY_FRAMES` | Stack frames and the maximum stack sizes will be copied from the original classes to the instrumented ones, i.e. frames and maxs will be read and visited by the class visitors and then to the `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html` where they will be written without modification. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#valueOf(kotlin.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Returns the enum constant of this type with the specified name. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html<https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |

| ### Public properties |
|---|---|
| `kotlin.enums.EnumEntries<https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/instrumentation/FramesComputationMode#entries()` Returns an immutable list containing the constants of this enum type, in the order they're declared. |

## Enum Values

### COMPUTE_FRAMES_FOR_ALL_CLASSES

```
val FramesComputationMode.COMPUTE_FRAMES_FOR_ALL_CLASSES: FramesComputationMode
```

Stack frames and the maximum stack sizes will be skipped when reading the original classes, and will **not** be computed by `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html`. Instead, when the whole instrumentation process is finished for all the classes, there will be another pass where the frames are computed for all classes based on the classpath of the instrumented classes. This means that the frames will be computed for all classes non-incrementally regardless of which classes changed or which classes were instrumented.

Using this mode will have a large impact on the build speed, use only when it's absolutely necessary.

Use this mode if your instrumentation process requires recomputing frames and/or maxs, and there will be two classes A and B, where the lowest common superclass will **not** be the same before and after instrumentation.

For example, the instrumentation process could be

- Changing the superclass of a subset of classes, that will result in changing the lowest common superclass of at least two classes.

### COMPUTE_FRAMES_FOR_INSTRUMENTED_CLASSES

```
val FramesComputationMode.COMPUTE_FRAMES_FOR_INSTRUMENTED_CLASSES: FramesComputationMode
```

Stack frames and the maximum stack sizes will be skipped when reading the original classes, and will be instead computed from scratch by `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html` based on the classpath of the original classes.

Use this mode if your instrumentation process requires recomputing frames and/or maxs for all instrumented classes, and for any two classes A and B, the lowest common superclass will be the same before and after instrumentation.

For example, the instrumentation process could be

- Injecting code without visiting the frames and/or maxs for the injected code.

### COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS

```
val FramesComputationMode.COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS: FramesComputationMode
```

Stack frames and the maximum stack size will be computed by `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html` for any modified or added methods based on the classpath of the original classes. This means that neither the maximum stack size nor the stack frames will be computed for methods that are copied as is in the new class.

Use this mode if your instrumentation process requires recomputing frames and/or maxs only for the modified methods in each class.

For example, the instrumentation process could be

- Injecting code without visiting the frames and/or maxs for the injected code.

### COPY_FRAMES

```
val FramesComputationMode.COPY_FRAMES: FramesComputationMode
```

Stack frames and the maximum stack sizes will be copied from the original classes to the instrumented ones, i.e. frames and maxs will be read and visited by the class visitors and then to the `https://asm.ow2.io/javadoc/org/objectweb/asm/ClassWriter.html` where they will be written without modification.

This is the fastest mode as it doesn't require computing frames which can be an expensive operation.

Use this mode if your instrumentation process doesn't require recomputing frames or maxs.

For example, the instrumentation process could be

- Adding an annotation to a method

- Adding an interface to a class

- Injecting code and also manually calculating and visiting the frames and maxs for the injected code.

## Public functions

### valueOf

Added in 4.2.0

```
fun valueOf(value: String): FramesComputationMode
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Throws |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-illegal-argument-exception/index.html` | if this enum type has no constant with the specified name |

### values

Added in 4.2.0

```
fun values(): Array<FramesComputationMode>
```

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.

The function returns a new instance of the array on every call. The array could be mutated, so working with it may also require defensive copying. Consider using `entries` property as a more efficient alternative returning an immutable list of enum entries.

## Public properties

### entries

```
val entries: kotlin.enums.EnumEntries<FramesComputationMode>
```

Returns an immutable list containing the constants of this enum type, in the order they're declared.