Module java.base
Package java.lang.classfile

# Enum ClassFile.ConstantPoolSharingOption

≠
public static final enum ConstantPoolSharingOption
extends java.lang.Enum<java.lang.classfile.ClassFile.ConstantPoolSharingOption>
implements java.lang.classfile.ClassFile.Option
Comparing master and cf

All Implemented Interfaces:
  `Serializable, ClassFile.Option, Comparable<ClassFile.ConstantPoolSharingOption>, Constable`

Enclosing interface:
  `ClassFile`

public static enum ClassFile.ConstantPoolSharingOption extends Enum<ClassFile.ConstantPoolSharingOption> implements ClassFile.Option
Option describing whether to preserve extend from the original constant pool when transforming a `class` file. Reusing the constant pool The default is `SHARED_POOL` to extend from the original constant pool.

This option affects all overloads of `transformClass` . Extending from the original constant pool keeps the indices into the constant pool intact, which Moved to a paragraph.enables significant optimizations in processing time and minimizes differences between the original and transformed `Moved to a paragraph. class` Moved to a paragraph. files, but may result in a bigger transformed `Moved to a paragraph.class` Moved to a paragraph. file when many elements of the original `Moved to a paragraph.class` Moved to a paragraph. file are dropped and many original constant pool entries become unused.

Default is `SHARED_POOL` to preserve the original constant pool

An alternative to this option is to use `ClassFile.build(ClassEntry, ConstantPoolBuilder, Consumer)` directly. It allows extension from arbitrary constant pools, and may be useful if a built `class` file reuses structures from multiple original `class` filesMoved to a paragraph..

Since:
  24
See Also:
  - `ConstantPoolBuilder`
  - `ClassFile.build(ClassEntry, ConstantPoolBuilder, Consumer)`
  - `ClassFile.transformClass(ClassModel, ClassTransform)`

## Enum Constants

- =
  NEW_POOL
- ≠
  SHARED_POOL
  Comparing master and cf

  ### SHARED_POOL

  public static final ClassFile.ConstantPoolSharingOption SHARED_POOL
  Preserves Extend the new constant pool from the original constant pool when transforming the `class` file.

  These two transformations below are equivalent:

      ClassModel originalClass = ...
      ClassDesc resultClassName = ...
      ClassTransform classTransform = ...
      var resultOne = ClassFile.of(ConstantPoolSharingOption.SHARED_POOL)
              .transformClass(originalClass, resultClassName, classTransform);
      var resultTwo = ClassFile.of().build(resultClassName, ConstantPoolBuilder.of(originalClass),
              clb -> clb.transform(originalClass, classTransform));

  See Also:
    - `ConstantPoolBuilder::of(ClassModel)`

## Methods

- =
  public static java.lang.classfile.ClassFile.ConstantPoolSharingOption valueOf(java.lang.String arg0)
- =
  public static java.lang.classfile.ClassFile.ConstantPoolSharingOption[] values()

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
ClassFile.ConstantPoolSharingOption |  |  |  |  |  |  | 4 | 3 | 2 | 9
SHARED_POOL |  |  |  |  |  |  | 1 | 1 |  | 2
Total |  |  |  |  |  |  | 5 | 4 | 2 | 11